Registry / serialization / dynamic-yaml

dynamic-yaml

JSON →
library2.0.0pypypi✓ verified 24d ago

Dynamic-yaml (version 2.0.0) is a Python library that enhances standard YAML with self-referential and dynamic string resolution capabilities, allowing YAML entries to reference other parts of the configuration tree using Python's string formatting syntax. It is actively maintained with releases driven by feature development, with the latest major version released on April 9, 2024.

pip install dynamic-yaml
INSTALL
IMPORT
SIG · DYNAMIC-YAML
D
dynamic-yaml
serializationpythonv2.0.0
Install
1.7s avg
Import
147ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.150s · 19.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.144s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DynamicYamlLoader
from dynamic_yaml import DynamicYamlLoader
from dynamic_yaml import DynamicYaml
load
from dynamic_yaml import load
dump
from dynamic_yaml import dump

Demonstrates loading a YAML string with self-referential keys and accessing the dynamically resolved values. It also shows how updating a referenced parameter automatically re-resolves dependent values, a feature introduced in v1.1.0.

import os import yaml from dynamic_yaml import DynamicYaml, load # Simulate a YAML file content yaml_content = """ project_name: hello-world dirs: home: /home/user venv: "{dirs.home}/venvs/{project_name}" bin: "{dirs.venv}/bin" output: "{dirs.venv}/output-{parameters.parameter1}" parameters: parameter1: test_value """ # Load the YAML content, enabling dynamic resolution config = load(yaml_content) # Access resolved values using attribute access print(f"Project Name: {config.project_name}") print(f"Virtual Environment Path: {config.dirs.venv}") print(f"Output Path: {config.output}") # Demonstrate changing a parameter and re-resolving (dynamic update) config.parameters.parameter1 = "new_test" print(f"Updated Output Path after parameter change: {config.output}")
Debug
Known issues
gotchaString scalars containing curly braces (`{`, `}`) must be explicitly quoted if they are not intended for dynamic resolution. Without quotes, `dynamic-yaml` might attempt to resolve them, or standard YAML parsing might interpret them as mapping objects, leading to unexpected behavior.
fix
Enclose any literal strings that contain curly braces with single or double quotes (e.g., `my_literal: '{not_a_variable}'`).
affects: All
gotchaWhen accessing keys that share names with built-in dictionary attributes (e.g., 'items', 'keys', 'values'), attribute access (`config.items`) will not work as expected. These values must be accessed using item notation (`config['items']`).
fix
Use `config['key_name']` for keys that might clash with standard dictionary methods or attributes.
affects: All
Upgrade
Version history
2.0.0latest on PyPI · released Apr 9, 2024
Audit
Dependencies
PyYAMLrequiredRequired for underlying YAML parsing and manipulation.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
dynamic-yaml — pip install dynamic-yaml · libregistry