utils.checkpoint.CheckpointSession¶
Import path: earth2studio.utils.checkpoint.CheckpointSession
Documentation¶
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, default:None) –Existing catalog row to restore. If
None, the session starts as a new write target, by default None.
is_active
property
¶
is_active: bool
Whether this checkpoint session is active in the current context.
metadata
property
¶
Load metadata recorded for the selected checkpoint row.
bind ¶
Bind and restore a dataclass state object.
write ¶
write(**metadata: Any) -> CheckpointEntry | None
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:
-
CheckpointEntry | None–The committed catalog entry when this call triggers a flush; otherwise
None.
flush ¶
flush(**metadata: Any) -> CheckpointEntry | None
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:
-
CheckpointEntry | None–The committed catalog entry, or
Nonewhen there was nothing new to commit.