CheckpointSession#

class earth2studio.utils.checkpoint.CheckpointSession(catalog, entry=None)[source]#

Active checkpoint row or new checkpoint session.

A session is the context-bound handle used by workflows and components to restore bound state, record completed restart boundaries, and commit new checkpoint rows. Sessions created from Checkpoint.select() restore an existing catalog row; sessions opened by with checkpoint on an empty catalog create the first row for the checkpoint.

Parameters:
  • catalog (Checkpoint) – Checkpoint catalog that owns this session.

  • entry (CheckpointEntry | None, optional) – Existing catalog row to restore. If None, the session starts as a new write target, by default None.

artifact(name)[source]#

Compatibility alias for metadata_value().

Parameters:

name (str)

Return type:

Any

property artifacts: dict[str, Any]#

Compatibility alias for checkpoint metadata.

bind(state)[source]#

Bind and restore a dataclass state object.

Parameters:

state (T | CheckpointState[T])

Return type:

CheckpointState[T]

property commit_id: str | None#

Selected commit identifier, if one exists.

property device: device#

Device used for live checkpoint state tensors.

property exists: bool#

Whether this session resolves to an existing checkpoint row.

flush(**metadata)[source]#

Commit the current session state to the checkpoint catalog.

flush writes an atomic commit directory containing the manifest, bound component state, and checkpoint metadata, then updates the catalog row for this session. If no write is pending and no metadata overrides are supplied, no commit is created.

Returns:

The committed catalog entry, or None when there was nothing new to commit.

Return type:

CheckpointEntry | None

Parameters:

metadata (Any)

property is_active: bool#

Whether this checkpoint session is active in the current context.

property lead_time: Any | None#

Forecast lead time metadata, when present.

property metadata: dict[str, Any]#

Load metadata recorded for the selected checkpoint row.

metadata_value(name)[source]#

Load one metadata value by name.

Parameters:

name (str)

Return type:

Any

write(**metadata)[source]#

Record a safe restart boundary for the active session.

write increments the session write count and stores the latest checkpoint metadata. If the parent checkpoint’s flush_interval is reached, the pending update is committed to disk; otherwise it remains in memory until a later write or flush.

Returns:

The committed catalog entry when this call triggers a flush; otherwise None.

Return type:

CheckpointEntry | None

Parameters:

metadata (Any)