Draccus is a Python library that provides a slightly opinionated framework for simple dataclass-based configurations, built as a fork of Pyrallis. It extends Pyrallis with advanced features such as support for subtyping configurations, the ability to include config files within other config files, and enhanced handling for containers of configurations. The current version is 0.11.5.
pip install draccusVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to define a simple dataclass for configuration and use the `@draccus.wrap()` decorator to parse command-line arguments or YAML files into an instance of that dataclass. Run it from the command line, for example: `python your_script.py --exp_name=my_first_exp --workers=4`.
Consult Draccus documentation for differences, especially when using ChoiceRegistry, nested config files, or containers of configs. Prefer `draccus`'s own decorators and functions over direct `pyrallis` imports if you intend to use Draccus-specific features.
Ensure that `draccus.wrap()` is applied directly to your main entry point function, and let it handle the configuration injection. If explicit parsing is needed for a sub-component, consider making it a separate, unwrapped function or using `draccus.parse()` directly where appropriate.
Refactor your main application entry point to use the `@draccus.wrap()` decorator for a more streamlined and idiomatic approach to configuration management.