Run¶
Run Options Contract¶
consist.run(...) is a deprecated compatibility wrapper around
Tracker.run(...). It still rejects legacy direct policy kwargs (for example
cache_mode, output_missing, inject_context) with a TypeError.
For new code, prefer tracker.run(...) for single-step execution or
scenario.run(...) inside an active scenario.
Use options objects instead:
cache_options=CacheOptions(...)output_policy=OutputPolicyOptions(...)execution_options=ExecutionOptions(...)
For path-bound steps, ExecutionOptions is also the public surface for
requested input staging:
from pathlib import Path
from consist import ExecutionOptions, Tracker
tracker = Tracker(run_dir="./runs", db_path="./provenance.duckdb")
result = tracker.run(
fn=run_tool,
inputs={"config_path": Path("./configs/baseline.yaml")},
outputs=["report"],
execution_options=ExecutionOptions(
input_binding="paths",
input_materialization="requested",
input_paths={
"config_path": tracker.run_dir / "workspace" / "config.yaml"
},
),
)
That pattern applies equally to Tracker.run(...) and
ScenarioContext.run(...). It keeps canonical artifact identity in
inputs={...} while ensuring the callable sees a real local file at the
requested destination, including on cache hits.
When migrating legacy calls, move direct policy kwargs into the matching options
object: cache behavior goes in CacheOptions(...), output validation and
materialization behavior goes in OutputPolicyOptions(...), and runtime binding
or input-staging behavior goes in ExecutionOptions(...).
Identity kwargs for run/trace surfaces¶
Public identity kwargs for Tracker.run(...), Tracker.trace(...),
ScenarioContext.run(...), ScenarioContext.trace(...), and the deprecated
consist.run(...) / consist.trace(...) wrappers are:
adapter=...identity_inputs=[...]
config_plan= and hash_inputs= are not accepted on these run/trace surfaces.
Passing them raises TypeError (unexpected keyword argument ...).
Run/trace parity is implemented through a shared invocation-resolution path
(resolve_run_invocation), so identity and cache-option validation rules are
consistent across both execution styles.
Execution controls to reach for first¶
Use ExecutionOptions(...) for three common runtime choices:
input_binding="paths"when the callable should own file I/Oinput_binding="loaded"when Consist should hydrate data objects firstinput_materialization="requested"plusinput_paths={...}when a path-bound step needs exact local input destinations
For the lower-level staging helpers, see Materialization.
Execute a computational task as a tracked and cached Consist run.
This high-level entrypoint encapsulates the execution of a callable within a managed provenance context. It automates the lifecycle of the run, including signature computation for cache identity, artifact capture, and result persistence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Optional[Callable]
|
The computational function to execute. |
None
|
name
|
Optional[str]
|
A semantic identifier for the run. If omitted, the function's
|
None
|
tracker
|
Optional[Tracker]
|
The Tracker instance responsible for provenance and caching. If None, the active global tracker is resolved. |
None
|
adapter
|
Optional[ConfigAdapter]
|
Config adapter used to resolve adapter-driven identity for the run. |
None
|
identity_inputs
|
IdentityInputs
|
Additional hash-only identity inputs that contribute to cache keys. |
None
|
cache_options
|
Optional[CacheOptions]
|
Grouped cache controls for run execution. |
None
|
output_policy
|
Optional[OutputPolicyOptions]
|
Grouped output mismatch/missing policy controls. |
None
|
execution_options
|
Optional[ExecutionOptions]
|
Grouped runtime execution controls. For path-bound workflows, this is
also where you request local input staging via
|
None
|
**kwargs
|
Any
|
Arguments forwarded to Legacy direct policy kwargs are rejected (for example |
{}
|
Returns:
| Type | Description |
|---|---|
RunResult
|
A container holding the function's return value and the
immutable |
Raises:
| Type | Description |
|---|---|
TypeError
|
Raised when legacy run-policy kwargs are provided directly instead of via options objects. |
Run model¶
Use run.identity_summary to debug signature composition
(config_hash, input_hash, code_hash, adapter metadata, and
identity_inputs digests).
If you are diagnosing a cache miss, also inspect
run.meta["cache_miss_explanation"] on the completed run. It records the
likely reason the run missed cache, such as config drift, input drift, code
drift, validation failure, or the absence of a similar prior run.
The payload is intentionally compact:
reasongives the broad miss category.candidate_run_idpoints to the prior completed run that was compared, when one exists.detailscarries the concrete evidence, such as changed config keys, changed input keys, code-identity drift, orfallbacks_usedwhen the explainer had to lean on fallback data.
For adapter-backed runs, config miss details prefer
run.meta["config_identity_manifest"] when both the current run and comparison
candidate have one. That manifest-first path can report
config_references_changed / added / removed,
config_files_changed / added / removed, reference_status_changed, and
config_identity_options_changed. Older or non-adapter runs still fall back to
indexed config facets first and then the persisted JSON config snapshot.
Bases: SQLModel
Primary run table in the Consist database.
Each run captures execution metadata (status, timing, identity hashes, tags)
and links to artifacts through run_artifact_link. Full configuration details
live in the JSON run snapshot on disk, while the database stores hashes and
a queryable subset of metadata for caching and discovery.
Attributes: id (str): A unique identifier for the run, often combining model name, year, and a UUID. parent_run_id (Optional[str]): The ID of the parent run, if this is a nested execution. status (str): The current state of the run (e.g., "running", "completed", "failed"). model_name (str): The name of the model or workflow being executed. description (Optional[str]): Human-readable description of the run's purpose or outcome. year (Optional[int]): The simulation or data year, if applicable. iteration (Optional[int]): The iteration number, if applicable. stage (Optional[str]): The workflow stage, if applicable. phase (Optional[str]): The lifecycle phase, if applicable. tags (List[str]): A list of string labels for categorization and filtering (e.g., ["production", "urbansim"]). config_hash (Optional[str]): A hash of the run's configuration, used for caching. git_hash (Optional[str]): The Git commit hash of the code version used for the run. meta (dict[str, object]): A flexible dictionary for storing arbitrary metadata (e.g., hostname). started_at (datetime): The timestamp when the run execution began. ended_at (Optional[datetime]): The timestamp when the run execution completed or failed. created_at (datetime): The timestamp when the run record was created. updated_at (datetime): The timestamp when the run record was last updated.
duration_seconds
property
¶
identity_summary
property
¶
Return a structured cache-identity breakdown for this run.
The summary is intended for debugging cache behavior and explains the component hashes that form the run signature, plus identity-relevant metadata persisted on the run.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Cache-identity components and persisted identity metadata. Strict
resolved-binding runs additionally include |