Yacman is a Python library designed for managing YAML configuration files. It provides a robust YAML configuration manager with features for merging multiple configuration layers, validation, and atomic updates. The library recently released version 1.0.0, which introduced significant changes to constructor patterns and enhanced multi-process locking mechanisms, and maintains a consistent release cadence with active development.
pip install yacmanVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `YAMLConfigManager` from a dictionary, access and modify configuration values, and safely write changes to a file using the `write_lock` context manager and `rebase_and_write` method. Note the direct initialization `YAMLConfigManager(data)` is primarily for dictionary data; for file-based configuration, you would typically use `YAMLConfigManager(filepath='your_config.yaml')`.
Update your code to use the new constructor methods, e.g., `ym = YAMLConfigManager.from_dict(data)` or `ym = YAMLConfigManager.from_file('path/to/config.yaml')`.Replace `with ym as locked_ym:` with `with write_lock(ym) as locked_ym:` or `with read_lock(ym) as locked_ym:`. Additionally, for write operations, ensure you call `locked_ym.rebase()` before `locked_ym.write()` or use the convenience method `locked_ym.rebase_and_write()` for multi-process safety.
Simply update your imports to `from yacman import YAMLConfigManager` and adjust usage according to the new constructor and locking patterns.
Always use `locked_ym.rebase_and_write()` or explicitly call `locked_ym.rebase()` followed by `locked_ym.write()` within a `write_lock` context.
Remove the `FutureYAMLConfigManager` import. In yacman v1.0.0, simply use `from yacman import YAMLConfigManager`.
Use the appropriate class method for initialization, e.g., `ym = YAMLConfigManager.from_dict(data)` for dictionary input or `ym = YAMLConfigManager.from_file('path/to/config.yaml')` for file input.Ensure all write operations are performed within a `with write_lock(ym) as locked_ym:` block. For example, `with write_lock(ym) as locked_ym: locked_ym.rebase_and_write()`.