Skip to main content

Dataclass-driven configuration helpers with metadata, validation, path access, argparse integration, and documentation generation.

Project description

dc_options

Dataclass-first configuration helpers with validation, metadata, argparse wiring, and documentation export. dc_options lets you describe nested option trees using familiar dataclasses while automatically generating CLIs, enforcing constraints, and producing Markdown/reference docs.

Features

  • Declarative configuration via dataclasses and an option() helper carrying labels, ranges, choices, and UI hints.
  • Strict loading/saving from JSON using dacite with metadata validation baked in.
  • Path-based getters/setters (cfg.get("training.lr")) for ergonomic CLI or scripting overrides.
  • Argparse integration that maps metadata to command-line flags.
  • Documentation export using Jinja2 templates so UI teams and docs stay synced with code.

Project Layout

dc_options/         Core package (Options base class, metadata helper, docs template)
examples/           Minimal usage sample for experimentation
tests/              Pytest suites covering dump, path helpers, validation, etc.
pyproject.toml      uv/PEP 621 project definition
AGENTS.md           Contributor guide and workflow expectations

Getting Started

uv sync                             # install deps in .venv
uv run python examples/minimal.py   # inspect nested configs & path helpers
uv run python examples/argparse_example.py --serve.port 9090 --workers 4
uv run pytest tests -q              # run the test suite

To pull configuration from JSON or args:

from dc_options import Options, option

@dataclass
class Train(Options):
    epochs: int = option(default=10, min=1, label="Epochs")

cfg = Train.load("train.json")
cfg.validate()
parser = Train.build_argparser()
cfg.apply_cli_overrides(parser.parse_args())

Examples

  • examples/minimal.py shows nested option classes, validation, and get/set helpers that operate on dot paths.
  • examples/argparse_example.py demonstrates combining JSON loading with CLI overrides using build_argparser.

Documentation

  • Update option metadata before exporting docs; the default template lives in dc_options/docs_template.md.j2.
  • Generate fresh docs with uv run python - <<'PY' ... Options.export_docs(...).
  • Preview site content through MkDocs (mkdocs serve) if documentation is published.

Contributing

Follow AGENTS.md for project structure tips, coding style, testing expectations, and git hygiene. Every feature or fix should ship with regression tests and refreshed docs whenever CLI behavior or configuration metadata changes.

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

dc_options-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

dc_options-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file dc_options-0.1.0.tar.gz.

File metadata

  • Download URL: dc_options-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dc_options-0.1.0.tar.gz
Algorithm Hash digest
SHA256 140c7b2a47cb7c5dbc4db1fc96747d449ad288a83f049281e545a90a054ef06d
MD5 fc7176a3fd20a344ff1f03fa67855617
BLAKE2b-256 810aa8ab4cb91cf17fe989c21dafc0ce369e838d985d0a2a35f1bc1e50349559

See more details on using hashes here.

File details

Details for the file dc_options-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dc_options-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dc_options-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfa2235e80d2b6bb12305473ba266b2a76e02c3f61249b055bd62f08da893c17
MD5 71ad3973adb73c32363e4cc591dedd8a
BLAKE2b-256 7acb8e97f4db3adad7ed05861faa6b2e91c4daf9289643990571c4f520dbcc59

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