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.4.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.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yaml_config_override-0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 d675364dbc0f9d0fe1c1657d3c981779ed61ef4afea5b8311421ebea65c3db05
MD5 f7fec8d0798b0142eb3b222a901d7be4
BLAKE2b-256 1eebb0b02ace9088d3a92239d8dc9c4e742b63839f297b892093a3114ab44aa0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yaml_config_override-0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 db3f501b15559c66ad4ae4809184d371488fdc3647e5b17864033f669983b69f
MD5 42ad77acfa91482c9473862de643b96e
BLAKE2b-256 39a87b6cf78bc06338dc6bde65b42ae5145d0147a3b228da449aab76f1c2c02f

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