libmuscle.snapshot_manager module

class libmuscle.snapshot_manager.SnapshotManager(instance_id: Reference, manager: MMPClient, port_manager: PortManager)[source]

Bases: object

Manages information on snapshots for the Instance

Implements the saving and loading of snapshots in the checkpointing API.

load_snapshot() Message[source]

Get the Message to resume from.

static load_snapshot_from_file(snapshot_location: Path) Snapshot[source]

Load a previously stored snapshot from the filesystem.

Parameters:

snapshot_location – path where the snapshot is stored.

prepare_resume(resume_snapshot: Path | None, snapshot_directory: Path | None) float | None[source]

Apply checkpoint info received from the manager.

If there is a snapshot to resume from, this loads it and does any resume work that libmuscle should do, including restoring message counts and storing the resumed-from snapshot again as our first snapshot.

Parameters:
  • resume_snapshot – Snapshot to resume from (or None if not resuming)

  • snapshot_directory – directory to save snapshots in

Returns:

Time at which the initial snapshot was saved, if resuming.

resuming_from_final() bool[source]

Check whether we have a final snapshot.

Doesn’t say whether we should resume now, just that we were given an intermediate snapshot to resume from by the manager.

resuming_from_intermediate() bool[source]

Check whether we have an intermediate snapshot.

Doesn’t say whether we should resume now, just that we were given an intermediate snapshot to resume from by the manager.

save_snapshot(msg: Message | None, final: bool, triggers: List[str], wallclock_time: float, f_init_max_timestamp: float | None, settings_overlay: Settings) float[source]

Save a (final) snapshot.

Parameters:
  • msg – Message object representing the snapshot.

  • final – True iff called from save_final_snapshot.

  • triggers – Description of checkpoints that triggered this.

  • wallclock_time – Wallclock time when saving.

  • f_init_max_timestamp – Timestamp for final snapshots.

  • settings_overlay – Current settings overlay.

Returns:

Simulation time at which the snapshot was made.