Saved runs¶
The optional run_id checks that the saved run has not changed since it was
read. Run storage keeps only the latest run, not run history.
For a reading example, see Read a saved run.
Publish and read the latest-run snapshot without locking.
RunStore
¶
Store the latest run without coordinating concurrent readers or writers.
preview_path
staticmethod
¶
Encode profile IDs as filenames without permitting path traversal.
publish
¶
Replace the entire snapshot, restoring it if promotion fails.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
staging_root
|
Path
|
Complete staged snapshot on the same filesystem. |
required |
Raises:
| Type | Description |
|---|---|
OSError
|
Publication, restoration, or cleanup fails. |
read_manifest
¶
Read and validate the latest manifest without caching it.
Raises:
| Type | Description |
|---|---|
RunNotFoundError
|
No saved run is available. |
ValueError
|
The manifest is invalid. |
OSError
|
The manifest cannot be read. |
read_preview
¶
Read and validate an indexed preview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_id
|
str
|
Profile key from the manifest's preview index. |
required |
run_id
|
str | None
|
Optional consistency token from a previously read manifest. |
None
|
Returns:
| Type | Description |
|---|---|
ProfilePreview
|
The profile's schema and bounded rows, or an explicit failed preview. |
Raises:
| Type | Description |
|---|---|
RunNotFoundError
|
No saved run is available. |
RunChangedError
|
A different run has replaced the requested snapshot. |
KeyError
|
The profile has no preview in this run. |
ValueError
|
The preview is invalid or disagrees with the manifest. |
OSError
|
An artifact cannot be read. |
read_logs
¶
read_logs(*, run_id: str | None = None, offset: int = 0, limit: int = 1000, level: str | None = None) -> list[models.LogEntry]
Read a bounded page of validated JSONL events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str | None
|
Optional consistency token from a previously read manifest. |
None
|
offset
|
int
|
Nonnegative number of log entries to skip. |
0
|
limit
|
int
|
Maximum number of entries to return, between 1 and 1,000. |
1000
|
level
|
str | None
|
Optional exact log level. Pagination counts matching events. |
None
|
Returns:
| Type | Description |
|---|---|
list[LogEntry]
|
Events in emission order; an empty list after the end of the log. |
Raises:
| Type | Description |
|---|---|
RunNotFoundError
|
No saved run is available. |
RunChangedError
|
A different run has replaced the requested snapshot. |
ValueError
|
Pagination arguments or log entries are invalid. |
OSError
|
An artifact cannot be read. |
staging
¶
Create and clean up a private staging directory beside the latest run.
RunChangedError
¶
Bases: ValueError
The requested run was replaced; consumers must reload the manifest.
RunNotFoundError
¶
Bases: FileNotFoundError
No latest-run manifest has been saved yet.
Validated contracts for the latest run and its related artifacts.
RunManifest
¶
Bases: ArtifactModel
One completed execution, including partial results after failure.