YAML CONFIG OVERRIDE
Why?
YAML Config Override is an extremely lightweight command line interface to your YAML configuration file. Just create a yaml config file, and yaml_config_override will add command line arguments to it automatically. No need to write hundreds of argparse lines!
Installation:
pip install yaml_config_override
Example?
Suppose you have a YAML file test.yaml:
outer:
x: 0
inner:
y: 1
eveninner:
z: abc
then you can use it in the code main.py:
from yaml_config_override import add_arguments
import yaml
from pathlib import Path
my_config_path = 'test.yaml'
conf = yaml.safe_load(Path(my_config_path).read_text())
conf = add_arguments(conf)
print(conf)
Now you can call main.py as follows:
python main.py --outer.x 2 --outer.inner.eveninner.z hello
Your program output will be:
{'outer': {'x': 2, 'inner': {'y': 1, 'eveninner': {'z': 'hello'}}}}
Alternatively if you want to pass the config file as a command line argument you can modify the code as follows:
from yaml_config_override import add_arguments
conf = add_arguments()
Now you call main.py as :
python main.py --config test.yaml --outer.x 2 --outer.inner.eveninner.z hello
Metadata
Release files for yaml-config-override 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yaml_config_override-0.5.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yaml_config_override-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.8 kB
Release files / yaml_config_override-0.5.tar.gz
| Download URL | yaml_config_override-0.5.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfcbbc6234f6be831913959fe5bba847d3bd48c6a91d4b31e59804ebf61412ad
|
|
BLAKE2b-256 checksum How to use checksums |
f038d46ae9846a7e343977d6e220c237ef4cde4a76f1b5ee545bb388c6c45254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.9 Linux/5.15.0-60-generic
|
Release files / yaml_config_override-0.5-py3-none-any.whl
| Download URL | yaml_config_override-0.5-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41296cecf2438bbc6737dbf95ee2bf9b5b5b9006c6d7ca07408449663f8063b4
|
|
BLAKE2b-256 checksum How to use checksums |
587e8cfc09d70cebdf732df6defcef289098cec7a3dedc5edc5fc41638f894b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.9 Linux/5.15.0-60-generic
|