Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PYAMLO: YAML Configuration Loader

PyPI Tests License

PYAMLO is a YAML configuration loader for Python, designed for advanced configuration scenarios. It supports file inclusion, deep merging, environment variable injection, variable interpolation, and direct Python object instantiation from YAML and object instance referencing including their properties.

Features

  • Includes: Merge multiple YAML files using _includes.
  • Merging: Deep merge dictionaries, extend lists (!extend), and patch/replace dictionaries (!patch).
  • Environment Variables: Substitute values using !env VAR_NAME or !env {var: NAME, default: ...}.
  • Variable Interpolation: Reference other configuration values using ${path.to.value} syntax.
  • Object Instantiation: Create Python objects directly from YAML using !@module.path.ClassName or !@module.path.func
  • Instance Referencing: Use ${instance} to reference instantiated objects and their properties. Or ${instance.attr} to reference attributes of instantiated objects.

Example

_includes:
  - examples/base.yml
  - examples/override.yml

testenv: !env MY_TEST_VAR

app:
  name: TestApp
  version: "2.0"

paths:
  base: !@pathlib.Path /opt/${app.name}
  data: !@pathlib.Path
    - ${paths.base}
    - data

services:
  main: !@pyamlo.SystemInfo
  secondary: !@pyamlo.SystemInfo

hostdefault: !@pyamlo.call "${services.main.as_dict}" 

pipeline:
  composite:
    first: ${services.main.host}
    second: ${services.secondary}

logs:
  - !@pathlib.Path /logs/${app.name}/main.log
  - !@pathlib.Path /logs/${app.name}/${services.main.host}.log

Installation

# Using uv (recommended)
uv pip install .[test,docs]

# Using pip
pip install .[test,docs]

Usage

from pyamlo import load_config

config = load_config("examples/test_config.yaml")
print(config)

Development

  • Run tests:
    pytest

  • Build docs:
    mkdocs serve

  • Build package:
    hatch build

License

See LICENSE.

Metadata

Release files for pyamlo 0.1.dev27

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

Source distribution (sdist)

Source distribution for pyamlo 0.1.dev27
File Size Uploaded
pyamlo-0.1.dev27.tar.gz 13.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyamlo 0.1.dev27
File Interpreter ABI Platform
pyamlo-0.1.dev27-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / pyamlo-0.1.dev27.tar.gz

Download URL pyamlo-0.1.dev27.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4f96637eeb14289bb05a556667d19f55e6a4357ccc7b710fd86cdfd8fe22b36f
BLAKE2b-256 checksum
How to use checksums
321d7209ad434dd9453d4c02bdbc45aa840ddbf3522539d834fd69b0c2f437c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / pyamlo-0.1.dev27-py3-none-any.whl

Download URL pyamlo-0.1.dev27-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3b00edd0d69d2d73477230a7e1a3f2a2f209c30f91b22591850943377ab79aa
BLAKE2b-256 checksum
How to use checksums
dfeb1e92f39f54f573c184c33ac62ab9a8e22582d44b97d243de153cff8360f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1
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