Skip to main content

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 config
  • config/config.development.yaml — environment override
  • config/.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
  • .env file
  • config.{env}.yaml
  • config.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.
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

  1. 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
  1. 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-diff in 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.toml or setup.cfg as extras. Install with:
pip install dco[aws]

Extending & contribution

  • Tests: run pytest to verify functionality. New features should include unit tests and CLI integration tests.
  • Linting & hooks: the repo uses ruff, black, isort, and mypy; pre-commit hooks will run these checks.

Troubleshooting

  • "Module found twice" mypy error when running tests locally usually means examples must be a package — ensure examples/__init__.py exists.
  • If jsonschema yields missing stubs for mypy, install types-PyYAML or run mypy --install-types --non-interactive in developer environments.

Support and maintenance

  • For packaging and releases: ensure pyproject.toml contains 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.md with commit and release workflows, or
  • add a Makefile or scripts/ 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 Distribution

dco-0.0.1.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dco-0.0.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file dco-0.0.1.tar.gz.

File metadata

  • Download URL: dco-0.0.1.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for dco-0.0.1.tar.gz
Algorithm Hash digest
SHA256 14f230562f654dd4c409e1ee0a04282e1ae3d01cbdc6b1d156256b81325b3754
MD5 8a64b5ef44f9eb704980bac43d7019f3
BLAKE2b-256 29d953b1c5bd11235e1c36ec087499c0064e4adf99fffef1342afab887071b0d

See more details on using hashes here.

File details

Details for the file dco-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: dco-0.0.1-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

Hashes for dco-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22fe1ac5c3780891a3eec272416de01de3e7df9a9b26f067b21a74b53b9ad7ac
MD5 d7210872800e38caa51ac47ce951ae6f
BLAKE2b-256 f52da3edbff5b993a4f091561d9177bab9709d65de4c4b63686bac857d4e93ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page