Skip to main content
Pre-release

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

cfgx

PyPI version

Python configs with ordered composition, computed values, and CLI overrides. Loading produces an ordinary dictionary. Configuration logic stays in Python.

Documentation

pip install cfgx

Define a base:

# base.py
from cfgx import final

config = {
    "steps": 96_000,
    "lr": 3e-4,
    "backbone_lr": final.lr * 0.1,
    "cooldown_steps": final.steps // 10,
}

Compose a variant with a tuple of sources:

# finetune.py
from cfgx import value

config = "base.py", {"steps": 48_000, "lr": value * 0.5}

Load it with optional overrides:

from cfgx import load

cfg = load("finetune.py", overrides=["lr=expr:value * 0.1"])
assert cfg["steps"] == 48_000
assert cfg["backbone_lr"] == cfg["lr"] * 0.1

Overrides contribute ordinary layers: optimizer.lr=1e-4 adds {"optimizer": {"lr": replace(1e-4)}}, and optimizer.decay!= adds {"optimizer": {"decay": delete}}. Use expr:{...} for a complete layer.

Dictionaries merge recursively, including computed dictionaries. Lists and tuples replace earlier sequences. Use replace(x) to replace a dictionary and delete to remove a dictionary entry.

  • final.lr reads the complete config, including later files and overrides.
  • value reads the inherited value at the current location.
  • previous.lr reads earlier definitions at another path.
  • final(1).lr reads a sibling; previous(1).lr reads its inherited definition.
  • expr.map(fn) transforms a resolved value. expr.map("x * 2") is shorthand.
  • computed(lambda get: ...) supports dynamic, conditional reads with get(expr).
  • .default(...), .keys(), .len(), and .exists() compose with other expressions.
from cfgx import computed, delete, final

config = {
    "resume": False,
    "checkpoint": computed(
        lambda get: get(final.checkpoint_path) if get(final.resume) else delete
    ),
}

Exact built-in dictionaries, lists, and tuples are rebuilt independently for each output location. Other objects are opaque and retain identity. Avoid side effects when working with opaque values or unknown types.

See composition, expressions, overrides, and the resolution contract. Training example demonstrates a compact setup with model and dataset composition, learning-rate scaling, computed checkpoints, and dataset transformations.

Snapshots and formatting remain available through dump, dumps, and format. A snapshot preserves resolved values, not their formulas.

Metadata

Release files for cfgx 0.6.0a2

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

Source distribution (sdist)

Source distribution for cfgx 0.6.0a2
File Size Uploaded
cfgx-0.6.0a2.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cfgx 0.6.0a2
File Interpreter ABI Platform
cfgx-0.6.0a2-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / cfgx-0.6.0a2.tar.gz

Download URL cfgx-0.6.0a2.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
54253a0c1d05c992a6234ef9fa569015bd7aea4179230eac675d3c4736918310
BLAKE2b-256 checksum
How to use checksums
954e2b4542b8eb0eb912eca504bce57a12460b31e45928e1b97d9929e81713f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cfgx-0.6.0a2-py3-none-any.whl

Download URL cfgx-0.6.0a2-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a0a847d8641344d274565ef40bfe23ab466c4a8d1af21f666b8e27bf46eefb9
BLAKE2b-256 checksum
How to use checksums
12ab3054654e658f7f7b0bc7bcd49a1db9af97def8e736308cd7417a44cf7d72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
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