Skip to content

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.

root instance-attribute

root = project_root.resolve() / paths.RUN_OUTPUT_DIR

preview_path staticmethod

preview_path(profile_id: str) -> str

Encode profile IDs as filenames without permitting path traversal.

publish

publish(staging_root: Path) -> None

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_manifest() -> models.RunManifest

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_preview(profile_id: str, *, run_id: str | None = None) -> models.ProfilePreview

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

staging() -> typing.Generator[pathlib.Path]

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.

run_id instance-attribute

run_id: str

started_at instance-attribute

started_at: AwareDatetime

finished_at instance-attribute

finished_at: AwareDatetime

duration_seconds class-attribute instance-attribute

duration_seconds: float = pydantic.Field(ge=0)

status instance-attribute

status: Literal['succeeded', 'failed', 'interrupted']

error instance-attribute

error: str | None

uptimely_version instance-attribute

uptimely_version: str

build instance-attribute

build: BuildIdentity

engine instance-attribute

engine: EngineConfig

runtime_validation instance-attribute

runtime_validation: bool

preview_rows class-attribute instance-attribute

preview_rows: int = pydantic.Field(gt=0)

invocations instance-attribute

invocations: dict[str, InvocationResult]

profiles instance-attribute

profiles: dict[str, ProfileSummary]

log_path class-attribute instance-attribute

log_path: Literal['log.jsonl'] = LOG_FILE

ProfilePreview

Bases: ArtifactModel

A bounded head sample with explicit success or failure.

profile_id instance-attribute

profile_id: str

status instance-attribute

status: Literal['succeeded', 'failed']

requested_rows class-attribute instance-attribute

requested_rows: int = pydantic.Field(gt=0)

sampling class-attribute instance-attribute

sampling: Literal['head'] = 'head'

columns instance-attribute

columns: list[PreviewColumn]

rows instance-attribute

rows: list[list[JsonValue]]

error class-attribute instance-attribute

error: str | None = None

validate_sample

validate_sample() -> typing.Self

Require rectangular bounded samples and explicit failure diagnostics.