Skip to main content

Easy overriding of YAML configs

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaml_config_override-0.3.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaml_config_override-0.3-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file yaml_config_override-0.3.tar.gz.

File metadata

  • Download URL: yaml_config_override-0.3.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.9 Linux/5.15.0-60-generic

File hashes

Hashes for yaml_config_override-0.3.tar.gz
Algorithm Hash digest
SHA256 b406c6d6e924b5e9c21696c9ff5b56b74230895ca93890feedd0070d27649e1a
MD5 f29f3c71e096253b58a1967341efcd2e
BLAKE2b-256 1163715c2c9d4bbe212b11615faab6fed9c1790c1af3eb1f9e6fbb46c3c02b6f

See more details on using hashes here.

File details

Details for the file yaml_config_override-0.3-py3-none-any.whl.

File metadata

  • Download URL: yaml_config_override-0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.9 Linux/5.15.0-60-generic

File hashes

Hashes for yaml_config_override-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d46254ab5d1fb17cb1225a831e3e0bb10cb53714573f19d003fcf3c825a9cf1b
MD5 9644c34b1b120fcf4af5aa81d01ce0c7
BLAKE2b-256 9465d815a32f85bbe5b5618790cb64f0bce1e75aa7e65410e872b5cf357eda3e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page