Skip to main content

ModYaml

ModYaml is a Python module designed for advanced YAML configuration management, offering modular, flexible, and powerful configuration capabilities.

Purpose

The primary purpose of ModYaml is to enhance YAML configurations by providing:

  1. Modular configuration through file inclusion
  2. Support for various file sources (local, remote, cloud storage)
  3. Environment variable interpolation
  4. Jinja2 templating support

These features allow for more dynamic, reusable, and environment-aware configurations.

Syntax

ModYaml extends standard YAML syntax with the !include directive:

key: !include path/to/another/file.yaml

The path/to/another/file.yaml can be: A local file path A URL (http, https, ftp, etc.) A cloud storage path (s3://, gs://, etc.)

ModYaml uses fsspec (Filesystem Specification) to handle file access, supporting a wide range of file systems and protocols.

database:
  !include configs/database.yaml
logging:
  !include https://example.com/logging-config.yaml
cloud_settings:
  !include gs://my-bucket/cloud-config.yaml

Processing Stages

ModYaml processes your configuration in the following stages:

  1. File Loading: The main YAML file is loaded, and all !include directives are resolved recursively.
  2. YAML Parsing: The complete YAML structure (including included files) is parsed into a Python dictionary.
  3. Jinja2 Templating: The parsed YAML is rendered as a Jinja2 template, allowing for dynamic content generation.
  4. Environment Variable Interpolation: Environment variables are interpolated into the configuration.
  5. Final Parsing: The resulting string is parsed again as YAML to produce the final configuration dictionary.

Using Environment Variables

Environment variables can be used in your YAML files for flexible configuration and debugging. They are accessible in the Jinja2 templating stage.

Example:

debug_mode: {{ DEBUG | default('false') }}
database_url: {{ DB_URL | default('localhost:5432') }}

Debugging configs

It is possible to trigger the config flow processing debug to standard logger. In order to do this, the following environment variables can be used:

# Dump Collected YAML after includes proocessing
export MODYAML_DEBUG_STAGE_1=1 
# Dump the YAML contents after jinja2 processing (including env vars substitution)
export MODYAML_DEBUG_STAGE_2=1
# Dump the resulted dict as loaded from yaml
export MODYAML_DEBUG_STAGE_3=1

Metadata

Release files for modyaml 0.0.post11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modyaml 0.0.post11
File Size Uploaded Provenance Actions
modyaml-0.0.post11.tar.gz 3.4 kB Without provenance Details for modyaml-0.0.post11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for modyaml 0.0.post11
File Interpreter ABI Platform Actions
modyaml-0.0.post11-py3-none-any.whl Python 3 none any Details for modyaml-0.0.post11-py3-none-any.whl

Total release size: 6.3 kB

Release files / modyaml-0.0.post11.tar.gz

Download URL modyaml-0.0.post11.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
80a812598a2a0cd6cca955d7e4262fd4eeaac05d5c6626e9dcf8c4eeafe1fb69
BLAKE2b-256 checksum
How to use checksums
6bc5f3e098fca154184ebe3871c4db4ac13372349f837d588be8aefd5bc803ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / modyaml-0.0.post11-py3-none-any.whl

Download URL modyaml-0.0.post11-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56e29a4454c59b816f005871859415d3eceb1aaecf4c7a486c56fe04374f5cf9
BLAKE2b-256 checksum
How to use checksums
7caac99ca95db236ac7b74e2157498d3de2ceccca31e95f01071d3b7f308755d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for modyaml 0.0.post11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page