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.
Install & Compatibility
Where this runs
tested against v0.11.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.112s · 21.4MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.0s · import 0.101s · 23MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from draccus import field
from draccus import ConfigType
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`.
from dataclasses import dataclass
import draccus
@dataclass
class TrainConfig:
"""Training Config for Machine Learning"""
workers: int = 8 # The number of workers for training
exp_name: str = 'default_exp' # The experiment name
@draccus.wrap()
def main(cfg: TrainConfig):
print(f"Training {cfg.exp_name} with {cfg.workers} workers...")
if __name__ == "__main__":
main()
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.