01
01 copied to clipboard
Add app configuration management
This PR introduces a configuration management system for 01 aimed at simplifying the configuration process.
Overview of Changes
Config
Class
- Implemented a
Config
class withinsoftware/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 withinsoftware/core/models.py
as a fallback.
Global Configuration Object
- A global
config
object is instantiated withinsoftware/__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
andconfig-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 withconfig
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.