Skip to main content

MXM configuration loader and context resolver

Project description

mxm-config

Version License Python Checked with pyright

Purpose

mxm-config provides a unified way to install, load, layer, and resolve configuration across all Money Ex Machina (MXM) packages and applications.
It separates configuration from secrets and runtime metadata, enforces deterministic layering, and ensures every run has a transparent, reproducible view of its operating context.


Design Principles

  • Separation of concerns

    • Configuration ≠ secrets ≠ runtime.
    • Secrets are handled by mxm-secrets.
    • Runtime metadata will be handled by mxm-runtime (planned).
  • Determinism

    • Configuration is layered in a fixed, documented order.
    • Reproducible runs: the same context always produces the same resolved config.
  • Transparency

    • Configs are plain YAML files, no hidden state.
    • Merging order is explicit and testable.
  • Extensibility

    • Layers are minimal and orthogonal.
    • New packages can register defaults without breaking existing ones.

Configuration Layers

At runtime, configuration is resolved by merging up to six layers in order of precedence (lowest → highest):

  1. default.yaml
    Baseline shipped with the package.
    Always present.

  2. environment.yaml
    Deployment mode (dev, prod, …).
    Each environment is a block inside this file.

  3. machine.yaml
    Host-specific overrides (paths, mounts, resources).

  4. profile.yaml
    Role or user context (research, trading, …).

  5. local.yaml
    Local scratchpad for ad-hoc tweaks.
    Ignored by version control.

  6. Explicit overrides (dict)
    Passed directly in code, applied last.


Installing Configs

Use the installer to copy package-shipped configs into the user’s config root (~/.config/mxm/ by default, override with $MXM_CONFIG_HOME).

from mxm_config.installer import install_all

install_all("mxm_config.examples.demo_config", target_name="demo")

This creates:

~/.config/mxm/demo/default.yaml
~/.config/mxm/demo/environment.yaml
~/.config/mxm/demo/machine.yaml
~/.config/mxm/demo/profile.yaml
~/.config/mxm/demo/local.yaml

Any templates/*.yaml files shipped with the package will also be installed under ~/.config/mxm/<package>/templates/.


Loading Configs

from mxm_config.loader import load_config

cfg = load_config("demo", env="dev", profile="research")

print(cfg.parameters.refresh_interval)
print(cfg.paths.output)
  • Context (mxm_env, mxm_profile, mxm_machine) is injected automatically.
  • All ${...} interpolations are resolved before returning.
  • The returned config is read-only by default.

Example Package

The repo ships a minimal demo package: mxm_config/examples/demo_config

  • default.yaml → valid baseline
  • environment.yaml → defines dev and prod
  • machine.yaml → overrides per host (bridge, wildling, monolith)
  • profile.yaml → defines research, trading
  • local.yaml → local overrides (optional, not versioned)

This serves as a test fixture for installers and loaders.


Testing

Tests use pytest with monkeypatch to isolate config roots and hostnames.

Run with:

poetry run pytest

Roadmap

  • Config schema validation (via omegaconf.structured or pydantic)
  • CLI tool (mxm-config install demo)
  • Environment variable overrides → auto-mapped into overrides dict
  • Integration with mxm-runtime for provenance tracking
  • Config hashing for reproducibility and auditability

License

MIT License. See LICENSE.

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

mxm_config-0.3.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mxm_config-0.3.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file mxm_config-0.3.0.tar.gz.

File metadata

  • Download URL: mxm_config-0.3.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mxm_config-0.3.0.tar.gz
Algorithm Hash digest
SHA256 663de975c5b147e0196653d8af8b3e0502c9456cec4f39894117240dfde1475b
MD5 54e359849cacbb50959f07856fd2ed06
BLAKE2b-256 414087f70fd41559056b5100dbe47e2909431205bb9b04c8c466035181db577c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_config-0.3.0.tar.gz:

Publisher: release.yml on moneyexmachina/mxm-config

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mxm_config-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mxm_config-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mxm_config-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38de8b65bc7fffd979fc9852d4cc21e49a46447ad58ffce47b27d0b4d1d3d5ec
MD5 79a95c9e72290cea4e45e9163d50e3a4
BLAKE2b-256 8c9b353f037621efd7d2f822925e721459285b64504768eab9935561af972ef2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_config-0.3.0-py3-none-any.whl:

Publisher: release.yml on moneyexmachina/mxm-config

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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