coleman.api¶
Library-first public API for driving experiments programmatically.
coleman.api ¶
coleman.api - Library-first public API.
External projects can pip install coleman and drive experiments
programmatically via :func:run, :func:run_many, or :func:sweep.
Functions:
| Name | Description |
|---|---|
run |
Execute a single experiment from a resolved |
run_many |
Execute multiple specs, optionally in parallel. |
sweep |
Expand a base spec × sweep definition and return concrete specs. |
load_spec |
Load and validate a |
save_resolved |
Persist a resolved spec as canonical JSON. |
RunResult ¶
Lightweight container for the outcome of a single run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
Deterministic run identifier. |
required |
spec
|
RunSpec
|
The resolved spec that was executed. |
required |
metrics
|
dict[str, Any]
|
Summary metrics collected during the run. |
None
|
artifacts_dir
|
str | None
|
Path to the run's artefact directory, if any. |
None
|
__init__ ¶
Initialise a RunResult.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
Deterministic run identifier. |
required |
spec
|
RunSpec
|
The resolved spec that was executed. |
required |
metrics
|
dict[str, Any] or None
|
Summary metrics. Defaults to empty dict. |
None
|
artifacts_dir
|
str or None
|
Path to the run artefact directory, if any. |
None
|
load_spec ¶
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
|
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. |
run ¶
Execute a single experiment from a resolved spec.
This is the canonical evaluation entry-point. Both the CLI and library callers route through here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
RunSpec
|
Fully resolved run specification. |
required |
Returns:
| Type | Description |
|---|---|
RunResult
|
Outcome container with deterministic |
run_many ¶
Execute multiple specs, optionally in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specs
|
list[RunSpec]
|
List of resolved run specifications. |
required |
max_workers
|
int
|
Maximum number of parallel workers ( |
1
|
Returns:
| Type | Description |
|---|---|
list[RunResult]
|
Results in the same order as specs. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If duplicate |
run_with_extension ¶
Execute one run using runner extension callbacks without replacing orchestration.
save_resolved ¶
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
|
Returns:
| Type | Description |
|---|---|
Path
|
The written file path. |