Skip to content

coleman.spec.io

YAML config loading and resolved spec persistence.

coleman.spec.io

Spec I/O — load from YAML, save resolved canonical JSON.

Functions:

Name Description
load_spec

Load and validate a RunSpec from a YAML file.

load_sweep_spec

Load and validate an optional top-level SweepSpec from YAML.

save_resolved

Write the resolved spec as deterministic JSON.

load_spec

load_spec(path, *, packs_dir=None)

Load a :class:RunSpec from a YAML config file.

Pack references (packs: key) are resolved and deep-merged before validation.

Parameters:

Name Type Description Default
path str | Path

Path to the YAML config file.

required
packs_dir str | Path | None

Root directory for config packs. When None (the default), the directory is derived as <config_dir>/packs so that configs remain relocatable regardless of the working directory.

None

Returns:

Type Description
RunSpec

Validated run specification.

Raises:

Type Description
FileNotFoundError

If path or a referenced pack does not exist.

ValidationError

If the resolved dict fails schema validation.

load_sweep_spec

load_sweep_spec(path, *, packs_dir=None)

Load an optional top-level sweep section from a YAML config.

Parameters:

Name Type Description Default
path str | Path

Path to the YAML config file.

required
packs_dir str | Path | None

Root directory for config packs. When None (the default), the directory is derived as <config_dir>/packs.

None

Returns:

Type Description
SweepSpec | None

Validated sweep configuration, or None when the YAML has no top-level sweep section.

save_resolved

save_resolved(spec, path, *, redact_sensitive=True)

Persist spec as canonical JSON.

Parameters:

Name Type Description Default
spec RunSpec

Resolved run specification.

required
path str | Path

Destination file path.

required
redact_sensitive bool

If True, redact likely sensitive values before persisting.

True

Returns:

Type Description
Path

The written file path.