Dynamic Config Orchestrator - layered typed configuration loader
Project description
✅ DCO – Dynamic Config Orchestrator
✅ DCO – Dynamic Config Orchestrator
Zero-hardcoded configs. Automatic merging. Schema-driven validation. Secrets integration. Developer-friendly.
DCO is a Python package designed to eliminate hardcoded configuration from backend applications by providing:
- Dynamic config loading
- Automatic merging across environments
- Env var + .env + YAML/JSON support
- Secrets provider abstraction (AWS, Vault, custom)
- JSON Schema generation
- Config scaffolding
- Schema diffing (detect breaking changes!)
- CLI for validation, dumping, watching
- Full Pydantic model integration
- CI-friendly commands for teams
Stop maintaining messy settings.py files, duplicated YAMLs, and inconsistent environment config. DCO centralizes everything with a clean, predictable, and IDE-friendly workflow.
✨ Features
🚀 Dynamic Config Loading
Automatically merges:
config.yamlconfig.<env>.yaml.env- environment variables (e.g.
APP__DB__HOST) - secret provider values
- Pydantic defaults
🔄 Hot Reload (dev only)
Watch config directory and reload settings on file change.
🔐 Secrets Providers
Optional built-in integrations:
- AWS Secrets Manager
- AWS SSM
- HashiCorp Vault
- or implement your own with a simple interface.
🛡 JSON Schema + CI Validation
Generate schema from your Pydantic model. Validate real config files or the merged effective config.
🛠 CLI Tools
dco dump– print merged configdco validate– validate merged configdco validate-file– validate a specific YAML/JSON filedco scaffold– auto-generate starter config filedco schema– export JSON/YAML schemadco schema-diff– detect breaking config changesdco watch– file watcher for dev reloadingdco docs– generate Markdown docs from schema
🔧 Zero Hardcoding
No more:
- hardcoded hosts
- hardcoded ports
- duplicated YAMLs
- manual “dev/stage/prod” handling
📦 Installation
Stable release:
pip install dco
Latest GitHub version:
pip install "git+https://github.com/safvan041/DCO.git#egg=dco"
🚀 Quick Start
- Define your settings using Pydantic
# settings.py
from pydantic import BaseModel
from dco import ConfigLoader
class DatabaseSettings(BaseModel):
host: str
port: int = 5432
class AppSettings(BaseModel):
debug: bool = False
db: DatabaseSettings
- Create a config directory
config/
config.yaml
config.development.yaml
.env
Example config.yaml:
debug: false
db:
host: "localhost"
port: 5432
Example .env:
DB__PASSWORD=supersecret
- Load configuration in your app
from settings import AppSettings
from dco import ConfigLoader
loader = ConfigLoader(AppSettings, config_dir="config")
settings = loader.load()
print(settings.debug)
print(settings.db.host)
- Switch environments
export DCO_ENV=development
python app.py
🧰 CLI Usage
Dump merged config
dco --config-dir=config dump settings:AppSettings
Validate merged config
dco --config-dir=config validate settings:AppSettings
Validate a single file
dco validate-file settings:AppSettings config/config.yaml
Generate JSON Schema
dco schema settings:AppSettings --out app.schema.json
Generate YAML Schema
dco schema settings:AppSettings --format yaml --out app.schema.yaml
Auto-generate config scaffold
dco scaffold settings:AppSettings --format yaml --out example.config.yaml
Detect breaking schema changes
dco schema-diff old.schema.json new.schema.json
Generate Markdown docs
dco docs settings:AppSettings --out docs/app_settings.md
Watch config for live reload (dev)
dco watch settings:AppSettings
🔐 Secrets Providers
Configure via:
from dco.secrets import AwsSecretsManagerProvider
loader = ConfigLoader(
AppSettings,
secrets_provider=AwsSecretsManagerProvider(prefix="myapp/")
)
settings = loader.load()
Or build your own provider:
from dco.secrets import SecretProvider
class MyProvider(SecretProvider):
def get_secret(self, path: str) -> str:
return "value"
🧪 Testing
pytest -q
Or run example integration test:
PYTHONPATH=src python examples/simple_app/test_integration.py
📄 Configuration File Rules
- Environment-specific files override base config
.envoverrides YAML- Env vars override
.env - Secrets override everything
- Model defaults apply if key missing
- Type validation enforced by Pydantic
- Schema ensures structural correctness
📚 Tips for Real Projects
- Commit your schema (JSON) to detect breaking changes in CI
- Use schema-diff in pull requests
- Use dco scaffold to bootstrap new services
- Use Env vars like DB__HOST to override nested settings
- Use watch during development for auto-reload
- Keep .env out of production; use secrets provider instead
Lenient YAML parsing
- Opt-in: DCO can attempt a conservative sanitization when YAML parsing fails due to simple indentation mistakes (for example, a single accidental leading space before a top-level key). This behavior is disabled by default.
- How to enable: pass
--lenient-yamlto CLI commands that load merged config (dump,validate,watch,validate-merged) or setlenient_yaml=Truewhen constructingConfigLoaderin code. - Warning: This mode can hide real config errors. Use it only for migration or development when you must accept messy legacy configs.
🤝 Contributing
Pull requests welcome! Please run:
ruff check .
black .
pytest -q
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dco-0.0.5.tar.gz.
File metadata
- Download URL: dco-0.0.5.tar.gz
- Upload date:
- Size: 31.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ab327faf2cf7978063da9a8cebdcdf6a1e3b05706d61e3373262491b912257
|
|
| MD5 |
fb6f1e39f87a26ebb9e2efc91f184010
|
|
| BLAKE2b-256 |
2dd2d3c895b6abca5a8ffe28b7b6e50a3db559ec20cd823d3da53c3cb9bc4dc4
|
File details
Details for the file dco-0.0.5-py3-none-any.whl.
File metadata
- Download URL: dco-0.0.5-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46ae4eea5a783e24f988fb87c0a497619e64b9e28e300eb89c70355d9aadb4e1
|
|
| MD5 |
d16576d7f34f62226ccdb3ae76108c93
|
|
| BLAKE2b-256 |
a9179e580bcc154f7d4a7d460e4bd4fb2a4d7f85b43d6aa7f7f12fe44a5ea2a6
|