Skip to main content

eqxconfig

eqxconfig is a small utility for constructing an Equinox module from TOML without writing a second configuration class. It derives a Pydantic model from the concrete module's annotated __init__ signature, validates the configuration, and calls the unchanged constructor.

TOML
  ↓
dynamically generated Pydantic schema
  ↓
validated constructor arguments
  ↓
Equinox __init__
  ↓
ordinary eqx.Module / JAX PyTree

The package requires Python 3.14 or newer.

Installation

python -m pip install eqxconfig

Usage

import equinox as eqx
import jax

from eqxconfig import ConfigurableModule


class MLP(ConfigurableModule):
    mlp: eqx.nn.MLP

    def __init__(
        self,
        in_size: int,
        out_size: int,
        width_size: int = 128,
        depth: int = 3,
        seed: int = 0,
    ) -> None:
        self.mlp = eqx.nn.MLP(
            in_size=in_size,
            out_size=out_size,
            width_size=width_size,
            depth=depth,
            key=jax.random.key(seed),
        )


model = MLP.from_toml("model.toml")
model_with_overrides = MLP.from_toml(
    "model.toml",
    width_size=512,
    depth=6,
)

model.toml contains constructor arguments at its root:

in_size = 32
out_size = 10
width_size = 256
depth = 4
seed = 42

Precedence is:

__init__ defaults < TOML < explicit from_toml overrides

The final configuration—including constructor defaults, TOML values, and explicit overrides—goes through one Pydantic v2 validation pass. The generated schema preserves annotations and defaults, so Annotated/Field constraints, Literal, unions, enums, constrained types, and nested Pydantic models work normally. Unknown keys are forbidden. Pydantic validation errors, TOML decoding errors, and file access errors retain their standard exception types.

The schema is generated lazily once per Equinox subclass. Constructor parameters must be annotated and must be positional-or-keyword or keyword-only. Positional- only parameters, *args, and **kwargs are deliberately rejected with a TypeError. Constructor defaults must be ordinary Python defaults in the signature; defaults embedded in Field(...), private parameter names, and the reserved name model_config are rejected because they cannot preserve a one-to-one constructor schema. Configuration keys match constructor parameter names; Pydantic validation aliases are not supported in v0.1.

Direct construction remains ordinary Python and Equinox:

model = MLP(in_size=32, out_size=10, width_size=512)

Configuration parsing and module construction happen before JAX transformations. Do not call from_toml inside jax.jit; pass the resulting module into compiled functions as a normal Equinox PyTree.

Development

Install the development dependency group with uv:

uv sync --all-groups

Run the individual checks with:

uv run ruff check .
uv run ruff format --check .
uv run pyrefly check
uv run pytest
uv build
uv run twine check dist/*

The repository uses prek for local hooks. From a fresh checkout:

prek install
prek run --all-files

Releases

The package version lives in pyproject.toml. Update it with uv version, merge the change, and push a matching tag such as v0.1.0. The release workflow builds and validates one wheel and one source distribution, attaches those exact files to a GitHub Release, and publishes the same files to PyPI.

PyPI publishing uses Trusted Publishing, not an API token. Before the first release, the repository owner must:

  1. Create a GitHub environment named pypi (and add any desired deployment protection rules).
  2. In the PyPI project's publishing settings, add a GitHub Trusted Publisher for the actual repository owner and repository name, workflow file release.yml, and environment pypi.

No long-lived PyPI credential should be added to GitHub secrets.

Scope

eqxconfig intentionally handles only root-level TOML-to-constructor configuration. It is not a general configuration framework and does not add environment variables, command-line parsing, remote sources, or configuration work inside JAX transformations.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eqxconfig-1.0.2.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

eqxconfig-1.0.2-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file eqxconfig-1.0.2.tar.gz.

File metadata

  • Download URL: eqxconfig-1.0.2.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for eqxconfig-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d7bf126bf48d279e2f00725e2e49a3b19fdd4479fa7dbd81fc216b0e1161a139
MD5 4609f5260d45e123409b8a1c561ae301
BLAKE2b-256 941a791c803acd21a7ff31d9bc2413400a3087c34a2bf38d6abf80bf492f22b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for eqxconfig-1.0.2.tar.gz:

Publisher: release.yml on varchasgopalaswamy/eqxconfig

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

File details

Details for the file eqxconfig-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: eqxconfig-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for eqxconfig-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 086edbc934aa76ca9ec85c39829b60777aa4a20e817153f606674448b94108f1
MD5 f4af810d167969e34e69d7209a6159b2
BLAKE2b-256 607106003a215cef06a3e6f1a1db18bfa2537af59688773b428f7bd55708e4a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for eqxconfig-1.0.2-py3-none-any.whl:

Publisher: release.yml on varchasgopalaswamy/eqxconfig

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

Release history Release notifications | RSS feed

1.0.3

2 files

This release

1.0.2 This release

2 files

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