Dynamic Config Orchestrator - layered typed configuration loader
Project description
DCO — Dynamic Config Orchestrator
DCO is a small, opinionated toolbox to load, validate and document typed configuration for Python services.
This manual explains how to install and use DCO locally and in CI, describes the CLI commands, configuration layout, and best practices for secure use.
Quick goals:
- Typed config using Pydantic models
- Layered loading (files, environment, .env, secrets, env vars)
- Schema export, scaffold & docs generation from Pydantic models
- Small CLI for validation, inspection and developer tooling
Supported Python versions: 3.10, 3.11, 3.12
Table of contents
- Installation
- Configuration layout
- CLI reference and examples
- Generating docs & schema
- CI and packaging
- Security & secrets handling
- Contributing
Installation
- From source (developer):
git clone <repo-url>
cd DCO
pip install -e .
- As a wheel (release):
pip install dco
Note: optional features (AWS/Vault integrations) are provided by optional dependencies — see pyproject.toml for extras groups if present.
Configuration layout
DCO expects a config directory (or a path supplied via --config-dir) with layered files. Example layout:
config/config.yaml— base configconfig/config.development.yaml— environment overrideconfig/.env— dotenv file (APP_ prefixed envs are parsed to nested config)
Environment variable precedence (high -> low):
- explicit program overrides (when using API)
- environment variables (prefixed, e.g.
APP_DB__HOST) - secrets provider
.envfileconfig.{env}.yamlconfig.yaml
Keys using double-underscore map to nested dictionaries (e.g. APP_DB__HOST=host -> {"db": {"host": "host"}}).
CLI Reference
Run dco --help for a quick list. Below are the primary commands with examples.
dco validate <model>- Validate the merged configuration (files + .env + env vars) against a Pydantic model.
- Example:
dco --config-dir examples/simple_app/config validate examples.simple_app.app:AppSettings
dco dump <model>- Print merged configuration as JSON.
dco --config-dir examples/simple_app/config dump examples.simple_app.app:AppSettings
dco schema <model> [--format json|yaml]- Export JSON Schema for a model.
dco schema examples.simple_app.app:AppSettings --format json > schema.json
dco scaffold <model> [--format json|yaml] [--out FILE]- Generate a config template/scaffold from the model schema.
dco scaffold examples.simple_app.app:AppSettings --format yaml --out config.template.yaml
dco validate-file <model> <config_file>- Validate an explicit JSON/YAML file against the model schema using
jsonschema.
- Validate an explicit JSON/YAML file against the model schema using
dco validate-file examples.simple_app.app:AppSettings examples/simple_app/config/config.yaml
dco validate-merged <model>- Convenience command: load merged config using loader semantics and validate the resulting runtime configuration against the model schema.
dco --config-dir examples.simple_app/config validate-merged examples.simple_app.app:AppSettings
dco schema-diff <old_schema> <new_schema>- Compare two schema files and report breaking/non-breaking changes (useful in PR gating).
dco schema-diff old_schema.json new_schema.json
dco docs <model> [--out FILE] [--title TITLE]- Render Markdown documentation derived from model JSON Schema.
PYTHONPATH=src dco docs examples.simple_app.app:AppSettings --out docs/app_settings.md --title "AppSettings Configuration"
dco watch <model>- Watch configuration directory and print reloads (development only). Secrets are redacted in watch output.
dco --config-dir examples/simple_app/config watch examples.simple_app.app:AppSettings
Notes on model reference
Models are referenced as module.path:ModelName, for example examples.simple_app.app:AppSettings. You may also provide a filesystem path like ./examples/simple_app/app.py:AppSettings.
Examples
- Scaffold + edit + validate:
dco scaffold examples.simple_app.app:AppSettings --format yaml > config.template.yaml
# edit config.template.yaml to fill required fields
dco validate-file examples.simple_app.app:AppSettings config.template.yaml
- Generate docs in CI:
PYTHONPATH=src dco docs examples.simple_app.app:AppSettings --out docs/app_settings.md --title "AppSettings"
CI & Packaging (recommendations)
- Build wheel and smoke-test in CI before publishing. Example sequence in CI:
python -m build --wheel --outdir dist
pip install dist/*.whl
python -c "import dco; print(dco.__version__)"
- Use
dco schema-diffin a gating job to prevent breaking schema changes on PRs.
Security & Secrets Handling
- Do NOT print secrets or write them into generated docs. Use
filter_secrets_for_logging()to redact secrets before any printing of config content. Example:
from dco.utils import filter_secrets_for_logging
mapping = model_to_mapping(settings)
print(filter_secrets_for_logging(mapping))
- Never commit real secret values to the repo. Use CI secret stores for deployment credentials.
Packaging metadata and extras
- Optional dependencies (e.g., AWS/Vault support) are declared in
pyproject.tomlorsetup.cfgas extras. Install with:
pip install dco[aws]
Extending & contribution
- Tests: run
pytestto verify functionality. New features should include unit tests and CLI integration tests. - Linting & hooks: the repo uses
ruff,black,isort, andmypy; pre-commit hooks will run these checks.
Troubleshooting
- "Module found twice" mypy error when running tests locally usually means
examplesmust be a package — ensureexamples/__init__.pyexists. - If
jsonschemayields missing stubs for mypy, installtypes-PyYAMLor runmypy --install-types --non-interactivein developer environments.
Support and maintenance
- For packaging and releases: ensure
pyproject.tomlcontains correct metadata (version, classifiers, long_description) and test building a wheel in CI. - Add schema gating and packaging jobs in CI to keep the project safe for consumers.
If you want, I can also:
- add an Examples section with a step-by-step guide for
examples/simple_app, - create a
CONTRIBUTING.mdwith commit and release workflows, or - add a
Makefileorscripts/helpers to automate docs and packaging tasks.
Happy to proceed with any of those next steps.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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.3-py3-none-any.whl.
File metadata
- Download URL: dco-0.0.3-py3-none-any.whl
- Upload date:
- Size: 16.2 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 |
73634d3b2cd77787ff6813e2f01b565f574577d8ab0e88d75adb5557bc4f66ca
|
|
| MD5 |
47c03214161b7dbce28f7070994f8213
|
|
| BLAKE2b-256 |
670c42f90ba802fa167d1f761efa96d4f3776e8ed1808cdb84236deac389e7ea
|