### Install nshconfig v3 alpha Source: https://nima.sh/nshconfig/_sources/installation.md.txt Install the nshconfig v3 alpha release. Supports Python 3.10-3.14 and Pydantic 2.13 through the latest 2.x. For trusted notebook transport, install nshconfig[transport] with the same version constraint. ```bash pip install 'nshconfig==3.0.0a0' ``` -------------------------------- ### Example project directory structure Source: https://nima.sh/nshconfig/_sources/guides/project-layout.md.txt Shows a recommended layout with schemas.py, presets.py, experiments/wide.py, and train.py. Use ordinary Python modules for schemas, preset helpers, experiments, and execution. ```text project/ schemas.py presets.py experiments/ wide.py train.py ``` -------------------------------- ### Serialize and restore config with cloudpickle Source: https://nima.sh/nshconfig/_sources/guides/transport.md.txt Use this snippet to serialize a draft configuration and its finalized version with cloudpickle, then restore both objects. Requires the optional `transport` extra to be installed. The restored objects preserve the editable/final distinction, interpolation rules, and child ownership. ```python import cloudpickle payload = cloudpickle.dumps((draft, draft.finalize())) restored_draft, restored_final = cloudpickle.loads(payload) ``` -------------------------------- ### Define config with interpolation and draft/finalize workflow Source: https://nima.sh/nshconfig/_sources/quickstart.md.txt Shows how to define a config with an interpolated field that references the root config's width, create an editable draft, finalize it, and verify that the interpolated value is frozen after finalization. Note that .draft() allows required fields to be unset, while normal constructors statically check required arguments. ```python import nshconfig as C class Model(C.Config): width: int = C.interp(lambda c: c.root(Run).width) class Run(C.Config): name: str width: int = 128 model: Model = Model() config = Run.draft() config.name = "example" config.width = 256 assert config.model.width == 256 ready = config.finalize() config.width = 512 assert ready.model.width == 256 ``` -------------------------------- ### Define config classes and use draft/finalize with interpolation Source: https://nima.sh/nshconfig/quickstart.html Defines Model and Run config classes. Model.width interpolates from the root Run config. Creates a draft, sets required fields, finalizes, and verifies the interpolated value. Note that .draft() allows unset required fields, but reading them fails at runtime. ```python import nshconfig as C class Model(C.Config): width: int = C.interp(lambda c: c.root(Run).width) class Run(C.Config): name: str width: int = 128 model: Model = Model() config = Run.draft() config.name = "example" config.width = 256 assert config.model.width == 256 ready = config.finalize() config.width = 512 assert ready.model.width == 256 ``` -------------------------------- ### Dispatch publish workflow with gh Source: https://nima.sh/nshconfig/guides/publishing.html Manually dispatch the publish workflow on the main branch with the exact version to release. The version must match pyproject.toml and the workflow will fail if CI has not passed or the version is invalid. ```bash gh workflow run publish.yml --repo nimashoghi/nshconfig --ref main -f version=3.0.0a0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.