Skip to content

Improve configuration management #462

@Shillaker

Description

@Shillaker

Context

Config is currently managed via two files: boaviztapi/data/config.yml, and tests/data/config.yml.

There are a couple of issues with the current setup:

  • It's not possible to override config at runtime (e.g. with environment variables)
  • The two existing YAML files are almost identical
  • The ALLOWED_ORIGINS and SPECIAL_MESSAGE parameters are configurable via environment variables, but is managed inline in main.py here and here
  • The doc has a small typo, referencing config.json

Changes

  • Allow overriding default config values with environment variables
  • Have a single definition of the default config values, and override for tests only where necessary
  • Update doc to reflect changes

We could use pydantic-settings to manage the settings, and the pytest-env package could be used to modify environment variables for all tests.

We could also move the configuration of our data directories to this config, as they are currently handled in Python code here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions