A package to manage YAML configuration with command line overrides
Project description
YAML Config Manager
yaml_config_manager
is a Python package to manage YAML configurations with command line overrides. This package allows you to load a configuration from a YAML file and override or add parameters using command line arguments.
Installation
Install the package using pip:
pip install yaml_config_manager
Usage
First, create a configuration YAML file. For example, config.yaml
:
model:
name: "my_model"
hidden_size: 768
training:
batch_size: 32
learning_rate: 0.001
Next, use the yaml_config_manager
package in your Python script:
from yaml_config_manager import load_config
config = load_config()
The configuration file path shoudl be specified using the --config
argument. You can also override or add parameters using --<key>=<value>
syntax. For example:
python your_script.py --config=config.yaml --model.hidden_size=512 --training.batch_size=64
The parameters in the configuration file can be accessed as follows:
model_name = config.model.name
hidden_size = config.model.hidden_size
...
Handling Edge Cases
- Non-existent keys: If a key specified in the command line does not exist in the YAML file, it will be added to the configuration.
- Nested keys: Nested keys can be overridden or added using the dot notation.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for yaml_config_manager-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6cf58099bf0180e35ad64a40b9b63662e0ca67a4ba4f5bb8308f167069a9b2b |
|
MD5 | 705b4e071d4edb060f5077a5c7502320 |
|
BLAKE2b-256 | 84ba278a0b98ecbf6bdad61892ee04478b0e71d5a698d51019a490346d2eeb4a |
Hashes for yaml_config_manager-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5cecc0e1fa2929dfa68712b7a53c0d1c3e8205bf60c275784b380796563938b |
|
MD5 | 98581f7f75ca623b715879c27c0fa532 |
|
BLAKE2b-256 | 668dfdc46666babc0dd0ddd39f3db54a583aaf4ddaf332edaf0a80dbfe611328 |