Skip to main content

Configuration library for the molcrafts ecosystem

Project description

 molcfg

Layered configuration for Python — predictable loading, merging, validation, and source tracking.

CI PyPI Python License Ruff

Documentation  ·  Quick start  ·  Ecosystem

molcfg loads configuration from dicts, files, environment variables, and CLI arguments into a single layered Config, remembering where every value came from. It adds schema validation, string-tag construction, interpolation, and thread-safe access on top.

Capabilities

Module Capability
config Config container — attribute and dotted-path access, freeze, snapshot/rollback, change notification, JSON/TOML/YAML round-trip
source Config sources — DictSource, JsonFileSource, TomlFileSource, YamlFileSource, EnvSource, CliSource behind a common Source interface
merge OVERRIDE / APPEND / DEEP_MERGE strategies, ConfigLoader for layered loading, and ProfileLoader for profile-based config
validation Type-and-constraint validation — Range, OneOf, Pattern, Length descriptors, Build, and the validate entry point
registry Registry — maps string keys (e.g. "silu") to factories, resolving short and long forms into classes or instances
concurrency ThreadSafeConfig wrapper, POSIX FileLock, and the ${path} / ${env:VAR} interpolate engine
paths project_config_dir — resolves and creates the shared ~/.molcrafts/<name>/config/ directory
errors Exception hierarchy — ConfigError, FrozenConfigError, CircularReferenceError, ValidationError

Install

pip install molcrafts-molcfg

Requires Python 3.12+. The only runtime dependency is pyyaml.

Quick start

from molcfg import CliSource, ConfigLoader, DictSource, EnvSource

cfg = ConfigLoader([
    DictSource({"db": {"host": "localhost", "port": 5432}}, name="defaults"),
    EnvSource(prefix="APP", name="env"),
    CliSource(["--db.port=6432"], name="cli"),
]).load()

assert cfg["db.port"] == 6432
assert cfg.meta("db.port") == {"source": "cli", "history": ("defaults", "cli")}

Documentation

Full documentation lives in docs/:

MolCrafts ecosystem

Project Role
molpy Python toolkit — the shared molecular data model & workflow layer
molrs Rust core — molecular data structures & compute kernels (native + WASM)
molpack Packmol-grade molecular packing (Rust + Python)
molvis WebGL molecular visualization & editing
molexp Workflow & experiment-management platform
molnex Molecular machine-learning framework
molq Unified job queue — local / SLURM / PBS / LSF
molcfg Layered configuration library — this repo
mollog Structured logging, stdlib-compatible
molhub Molecular dataset hub
molmcp MCP server for the ecosystem
molrec Atomistic record specification

Contributing

See CONTRIBUTING.md.

License

BSD-3-Clause — see LICENSE.


Crafted with 💚 by MolCrafts

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

molcrafts_molcfg-1.4.2.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

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

molcrafts_molcfg-1.4.2-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file molcrafts_molcfg-1.4.2.tar.gz.

File metadata

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

File hashes

Hashes for molcrafts_molcfg-1.4.2.tar.gz
Algorithm Hash digest
SHA256 75c351ca03c78552487d4866394d1ef63c07e2f853ba02f91ec2991e8c19e3dd
MD5 38bd3b8758207c1204ba0f67e8cfef60
BLAKE2b-256 5c2726d42088d70c0da60277ad720e65c9bd5f786a75a5f670aad595ac8fa450

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molcfg-1.4.2.tar.gz:

Publisher: release.yml on MolCrafts/molcfg

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

File details

Details for the file molcrafts_molcfg-1.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for molcrafts_molcfg-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 30170debb26ca77afc24ca543aaf259e801be0ad729df1a44f4af53bd60c20f6
MD5 70e245fea9fe7b44ce3ec531fa6c81ea
BLAKE2b-256 e5ae195b755fa697ee1fdb3bcdf7d525dc1e1a07f19bab9c6b02c70801d93d46

See more details on using hashes here.

Provenance

The following attestation bundles were made for molcrafts_molcfg-1.4.2-py3-none-any.whl:

Publisher: release.yml on MolCrafts/molcfg

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