diff --git a/README.md b/README.md index bced79c..3761a79 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ WARDEN_DATABASE_PASSWORD="secret" ``` > [!NOTE] -> If a key contains an underscore, you need to replace it by a `-` to set it using environment variables. -> E.g. `qpu.retry_max` can be set with the `WARDEN_QPU_RETRY-MAX` environment variable. +> If a key contains an underscore, you need to remove any `_` in its name to set it using environment variables. +> E.g. `qpu.retry_max` can be set with the `WARDEN_QPU_RETRYMAX` environment variable. The following options are configurable: @@ -94,7 +94,7 @@ Warden's access to the PASQAL QPU can be configured through the YAML config or e | Path | Variable | Description | Default | Required | Example Value | |------------------|-------------------------|--------------------------------------|-------------------------|----------|---------------------------| | `qpu.uri` | `WARDEN_QPU_URI` | PASQAL QPU API uri | `http://localhost:8005` | Yes | `http://127.0.0.1:8005` | -| `qpu.tls_verify` | _(YAML only)_ | TLS verification for an https backend | `system` | No | `system` | +| `qpu.tls_verify` | `WARDEN_QPU_TLSVERIFY` | TLS verification for an https backend | `system` | No | `system` | `qpu.tls_verify` only applies when `qpu.uri` uses `https`. It accepts: diff --git a/tests/test_config.py b/tests/test_config.py index 2e40340..40dc981 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -30,15 +30,15 @@ def test_config_env_vars_use_warden_prefix(monkeypatch, tmp_path): assert config.api.host == "127.0.0.1" -def test_config_env_vars_kebab_case(monkeypatch, tmp_path): +def test_config_env_vars_nocase(monkeypatch, tmp_path): """ - Test that the parameters with underscores can be set with the kebab-case - env-variable alternative + Test that the parameters with underscores can be set by removing underscores + in the env-variable alternative """ monkeypatch.chdir(tmp_path) - monkeypatch.setenv("WARDEN_SCHEDULER_QPU-POLLING-INTERVAL-S", "999") - monkeypatch.setenv("WARDEN_QPU_RETRY-MAX", "999") - monkeypatch.setenv("WARDEN_API_AUTHORIZED-USERS", '[1001, "9999"]') + monkeypatch.setenv("WARDEN_SCHEDULER_QPUPOLLINGINTERVALS", "999") + monkeypatch.setenv("WARDEN_QPU_RETRYMAX", "999") + monkeypatch.setenv("WARDEN_API_AUTHORIZEDUSERS", '[1001, "9999"]') config = Config() @@ -49,8 +49,8 @@ def test_config_env_vars_kebab_case(monkeypatch, tmp_path): def test_config_parse_lists_from_env(monkeypatch, tmp_path): monkeypatch.chdir(tmp_path) - monkeypatch.setenv("WARDEN_API_AUTHORIZED-USERS", '[1001, "9999"]') - monkeypatch.setenv("WARDEN_API_ADMIN-USERS", '[1001, "9999"]') + monkeypatch.setenv("WARDEN_API_AUTHORIZEDUSERS", '[1001, "9999"]') + monkeypatch.setenv("WARDEN_API_ADMINUSERS", '[1001, "9999"]') config = Config() diff --git a/warden/lib/config/config.py b/warden/lib/config/config.py index 47b6c59..4173f9c 100644 --- a/warden/lib/config/config.py +++ b/warden/lib/config/config.py @@ -25,15 +25,15 @@ API_PREFIX = "/api/v1" -def to_kebab(snake: str) -> str: - return snake.replace("_", "-") +def to_nocase(snake: str) -> str: + return snake.replace("_", "") class WardenSettings(BaseSettings): - # Give kebab-case aliases to all fields but still allow validating by field name + # Give nocase aliases to all fields but still allow validating by field name model_config = SettingsConfigDict( validate_by_name=True, - alias_generator=AliasGenerator(validation_alias=to_kebab), + alias_generator=AliasGenerator(validation_alias=to_nocase), )