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.

Installation

pip install mxm-config

Usage

Installing configuration

from mxm.config import install_config, DefaultsMode

install_config(
    app_id="demo",
    mode=DefaultsMode.shipped,
    shipped_package="mxm.config._data.seeds",
)

Loading configuration

from mxm.config import load_config

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

print(cfg.parameters.refresh_interval)
print(cfg.paths.output)

CLI usage

mxm-config install-config --app-id demo --mode shipped --pkg mxm.config

Design Principles

  • Separation of concerns
    Configuration ≠ secrets ≠ runtime
    Secrets are handled by mxm-secrets
    Runtime metadata will be handled by mxm-runtime (planned)

  • Determinism
    Fixed layering order
    Reproducible resolution

  • Transparency
    Plain YAML files
    Explicit merge order

  • Extensibility
    Orthogonal layers
    Package-level defaults

The App-Owned Config Root

Every MXM application owns a configuration directory:

~/.config/mxm/<app_id>/

This is the single source of truth for runtime configuration.

Override with:

export MXM_CONFIG_HOME=/custom/path

Configuration Layers

Configuration is resolved by merging the following layers (lowest → highest precedence):

  1. default.yaml
  2. environment.yaml
  3. machine.yaml
  4. profile.yaml
  5. local.yaml
  6. explicit overrides

Installing Configs (Python API)

from mxm.config import install_config, DefaultsMode
from importlib.resources import as_file, files

install_config(
    app_id="demo",
    mode=DefaultsMode.shipped,
    shipped_package="mxm.config._data.seeds",
)

with as_file(files("mxm.config._data") / "seeds") as p:
    install_config(app_id="demo", mode=DefaultsMode.seed, seed_root=p)

install_config(app_id="demo", mode=DefaultsMode.empty)

Returns an InstallReport describing all actions taken.

Install Modes

Mode Description
shipped Install packaged defaults
seed Install from local filesystem
empty Create empty config root

Command-Line Interface

mxm-config --help

Example:

mxm-config install-config \
  --app-id demo \
  --mode shipped \
  --pkg mxm.config

Shipped Defaults

Default configuration files are located in:

src/mxm/config/_data/seeds/

These are bundled with the package and used for both runtime defaults and testing.

Development

make check

This runs:

  • Ruff (lint + import sorting)
  • Black (format check)
  • Isort (consistency check)
  • Pyright (type checking)
  • Pytest (tests)

Testing

make test

Tests run in isolated temporary directories and never touch real user configuration.

Roadmap

  • Schema validation (omegaconf.structured, pydantic)
  • Environment variable overrides
  • Integration with mxm-runtime
  • Configuration hashing and provenance tracking

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.5.2.tar.gz (16.9 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.5.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mxm_config-0.5.2.tar.gz
Algorithm Hash digest
SHA256 b55e7bedb581dabc55875da8f9f724b9bbf36462419cf696f789a0f244fa7326
MD5 5134c20f6ba6537822bdf063a231fd91
BLAKE2b-256 7a35606ce3a2b618b2cf12bdd449848888549eee93dcd4f8a6a8cceb79f6456e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_config-0.5.2.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.5.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mxm_config-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dac8c05f3d7a3f364f47e012da15eb6948435f32d6950dc6c64331223005ab27
MD5 06b5b98346e5d7c8513fa9f1b3715002
BLAKE2b-256 607805ae183b46f15a36d94298ff1e2bade1f8da851ececfe3d25aadde55c025

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_config-0.5.2-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