Skip to content

Loads yaml configuration file(s), with schema validation and environment variable interpolation

License

Notifications You must be signed in to change notification settings

Amsterdam/config_loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datapunt Config Loader

image

image

Usage

Module that loads configuration settings from a yaml file.

import config_loader
import logging

CONFIG = config_loader.load(
    'path/to/config_file.yaml',
    'path/to/schema_file.yaml'
)
logging.config.dictConfig(CONFIG['logging'])

# Optionally:
CONFIG = config_loader.freeze(CONFIG)

This package comes with an example YAML schema file schema_example.yaml that contains, among other things, a schema definition for a dict that can be passed into logging.config.dictConfig.

Contributing

To get your development environment up and running:

# Clone the repository:
git clone git@github.com:Amsterdam/config_loader.git
cd config_loader

# Create and activate a virtual environment, for example:
python3.6 -m venv --copies --prompt authz_admin .venv
source ./.venv/bin/activate

make          # defaults to `make dist`
make dist
make release  # Don't forget to version bump in setup.py first.
make build
make test
make testcov
make clean

Conventions

  • We use PyTest for tests.
  • PyTest can be integrated with SetupTools (see https://docs.pytest.org/en/latest/goodpractices.html). We don’t do this.
  • Common commands for builds, distributing, packaging, documentation etcetera are in Makefile and sphinx/Makefile.
  • RST files and docstrings are indented with 4 spaces.
  • Globals must be immutable.
  • We follow Google’s formatting standard in docstrings.
  • Docstrings are formatted like this:

    """This is a one-line docstring."""
    """One line description, terminated with a period.
    
    More info, with a trailing empty line.
    
    """

About

Loads yaml configuration file(s), with schema validation and environment variable interpolation

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published