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
Configclass withinsoftware/core/config.pyto 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.yamlfile, environment variables (defined in a.envfile), 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.pyas a fallback.
Global Configuration Object
- A global
configobject 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.yamlandconfig-template.envfor easier configuration setup.
Implementation Details
- [x] Integrate Pydantic and Pydantic Settings for data validation and settings management.
- [x] Add
software/core/models.pyto reflect 01's configuration state. - [x] Add support for
config.yamland centralized.envloading. - [x] Integrate
TyperCLI commands withconfigobject. CLI takes precedence over all other configuration sources. - [x] Modify codebase to utilize the global
configobject 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.