01 icon indicating copy to clipboard operation
01 copied to clipboard

Add app configuration management

Open jcp opened this issue 11 months ago • 0 comments

This PR introduces a configuration management system for 01 aimed at simplifying the configuration process.

Overview of Changes

Config Class

  • Implemented a Config class within software/core/config.py to centralize configuration management. This class uses Pydantic and Pydantic Settings for validation and settings management.

Hierarchical Configuration Options

  • Introduced dynamic configuration capabilities through multiple sources: a config.yaml file, environment variables (defined in a .env file), and command-line arguments. These sources adhere to a specific order of precedence: command-line arguments > environment variables > config.yaml. Default configurations are defined within software/core/models.py as a fallback.

Global Configuration Object

  • A global config object is instantiated within software/__init__.py, ensuring configurations are universally accessible across the application. This provides a more unified and consistent method to manage configurations.

Configuration Templates

  • Added two starter templates: config-template.yaml and config-template.env for easier configuration setup.

Implementation Details

  • [x] Integrate Pydantic and Pydantic Settings for data validation and settings management.
  • [x] Add software/core/models.py to reflect 01's configuration state.
  • [x] Add support for config.yaml and centralized .env loading.
  • [x] Integrate Typer CLI commands with config object. CLI takes precedence over all other configuration sources.
  • [x] Modify codebase to utilize the global config object for configuration access.
  • [x] Add tests and documentation to reflect new configuration system.

As a note, this change was designed to be minimally invasive. But further integration with the existing code can greatly reduce complexity and points of failure.

jcp avatar Mar 23 '24 22:03 jcp