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.5.tar.gz (2.6 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.5-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yaml_config_override-0.5.tar.gz
  • Upload date:
  • Size: 2.6 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.5.tar.gz
Algorithm Hash digest
SHA256 cfcbbc6234f6be831913959fe5bba847d3bd48c6a91d4b31e59804ebf61412ad
MD5 07c299296de9f56f9d3ee180ebb1f5ef
BLAKE2b-256 f038d46ae9846a7e343977d6e220c237ef4cde4a76f1b5ee545bb388c6c45254

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yaml_config_override-0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 41296cecf2438bbc6737dbf95ee2bf9b5b5b9006c6d7ca07408449663f8063b4
MD5 89b3a72172971dd4b946af96c004219a
BLAKE2b-256 587e8cfc09d70cebdf732df6defcef289098cec7a3dedc5edc5fc41638f894b8

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