YACS is a lightweight Python library for defining and managing system configurations, particularly useful in scientific experimentation for reproducibility. It provides a hierarchical CfgNode object for structured configuration and supports loading configurations from both Python files and YAML files. The current version is 0.1.8, with a relatively active release cadence.
pip install yacsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to define a default configuration using `CfgNode`, retrieve a mutable copy, and then merge overrides from a YAML file and a list of command-line style options. It also shows the recommended practice of freezing the configuration to ensure reproducibility.
Review existing configurations and code for usage of non-string keys. If present, ensure they are compatible with the new behavior or adapt them accordingly.
When using YACS, consolidate all command-line overrides through `cfg.merge_from_list(opts)` to maintain a single source of truth for configuration values. Avoid redundant argument parsing for values already managed by YACS.
Always call `cfg.freeze()` on your primary configuration object once all modifications and merges are complete, typically at the start of your application logic.
Verify your `pip install` commands and import statements (`from yacs.config import CfgNode`) to ensure you're using the correct configuration library.
Ensure that any Python configuration file intended for YACS loading exports a variable named `cfg` (e.g., `cfg = CN()` or `cfg = {'KEY': 'VALUE'}`) at the module level.from yacs.config import CfgNode
cfg.defrost() cfg.FOO.BAR = 2 cfg.freeze()
from yacs.config import CfgNode
cfg1 = CfgNode({'A': 1})
cfg2 = CfgNode({'B': 2})
cfg1.merge_from_other_cfg(cfg2)from yacs.config import CfgNode
my_dict = {'A': 1, 'B': {'C': 2}}
cfg = CfgNode(my_dict)