SealedRun

SealedRun#

class SealedRun#

Immutable view of a closed Run in an Experiment.

SealedRun exposes run-level attachments by name, Solve records created by Run.log_solve, and Sampling records created by Run.log_sample. Missing attachment names raise KeyError; choosing a typed getter incompatible with the stored media type raises ValueError. The status property records how the Run scope was closed: "finished", "failed", or "interrupted". It is not an aggregate status of child records, so a finished Run may contain failed Solve or Sampling attempts handled inside the Run.

__repr__() → str#
attachment_media_type(name: str) → str#

Original media type of a run-level attachment.

Storage compression suffixes are hidden from this logical media type.

get_attachment(name: str) → Any#

Read a run-level attachment by name.

The returned Python object is decoded from the attachment media type.

get_blob(name: str) → bytes#

Read decompressed bytes of a run-level attachment by name.

get_instance(name: str) → Instance#

Read an Instance run-level attachment by name.

get_json(name: str) → Any#

Read a JSON run-level attachment by name.

get_parametric_instance(name: str) → ParametricInstance#

Read a ParametricInstance run-level attachment by name.

get_sample_set(name: str) → SampleSet#

Read a SampleSet run-level attachment by name.

get_solution(name: str) → Solution#

Read a Solution run-level attachment by name.

get_with_codec(codec: type[AttachmentCodec[T]], name: str) → T#

Read a run-level attachment by name and decode it with a codec.

The codec class must provide media_type, encode(value) -> bytes, and decode(bytes) -> object. This method validates the stored media type against the codec before decoding.

write_attachment(name: str, path: str | PathLike | Path, *, overwrite: bool = False) → Path#

Write a run-level attachment to a filesystem path.

If path names an existing directory, the attachment filename stored by log_file is used inside that directory. Otherwise path is treated as the destination file path. Compressed attachments are decompressed while exporting.

property attachment_names: list[str]#

Read-only property.

Names of run-level attachments.

property lifecycle_reason: Optional[str]#

Read-only property.

Concise exception type and message for a failed or interrupted Run.

property run_id: int#

Read-only property.

Integer identifier of this run within its Experiment.

property samplings: list[Sampling]#

Read-only property.

Sampling records logged in this run, ordered by sampling_id.

property solves: list[Solve]#

Read-only property.

Solve records logged in this run, ordered by solve_id.

property status: str#

Read-only property.

Run lifecycle status: "finished", "failed", or "interrupted".

This records how the Run scope was closed, not whether every child Solve record finished successfully. A finished Run may contain failed Solve attempts if those adapter errors were handled inside the Run.

property trace: Optional[TraceResult]#

Read-only property.

Stored trace for this run, or None when this run was recorded without trace storage.

With store_trace=True, the Run span covers the body of the Run context manager. On exit the trace is stored in the Experiment Artifact. Read it after reopening the record without rerunning the computation:

>>> from ommx import Instance
>>> from ommx.experiment import Experiment
>>> instance = Instance.minimize()
>>> with Experiment.with_temp_local_registry(store_trace=True) as experiment:
...     with experiment.run() as run:
...         run.log_solution("candidate", instance.evaluate({}))
>>> reopened = Experiment.from_artifact(experiment.artifact)
>>> trace = reopened.runs[0].trace
>>> assert trace is not None and any(span.name == "Run" for span in trace.spans)

Run trace storage requires using the context manager and is independent of exporting spans to an external backend. Forking carries the recorded traces; select store_trace=True on the fork to trace new Runs there.