Restart Module¶
Each module with restart capabilities defines checkpoint and restart functions which leverage this class.
Restart Utility Class¶
- class orchestrator.utils.restart.Restart[source]¶
Bases:
RecorderUtility class for managing reading and writing checkpoint files.
The restarter instance can be imported for access to the read and write checkpoint methods.
- __init__()[source]¶
Initialize the Restart utility class.
Provides methods to read and write checkpoint files. Tracks whether a checkpoint file is missing to avoid duplicate log messages.
- write_checkpoint_file(checkpoint_file, checkpoint_dict)[source]¶
Add (or update) a checkpoint dictionary in the checkpoint file.
If the checkpoint file already exists, the new dictionary will be merged with the existing content. If the module’s section already exists, it will be overwritten with the latest data.
- Parameters:
checkpoint_file (str) – Path and filename (should be JSON) to read and write to.
checkpoint_dict (dict) – Checkpoint information to add or update in the file. The dictionary should be nested, with a single root key associated with the module, and the value being a dictionary of quantities to checkpoint.
- Raises:
ValueError – If the checkpoint dictionary does not have a single root key.
- read_checkpoint_file(checkpoint_file, module_key)[source]¶
Read a checkpoint file and extract a specific module dictionary.
If the checkpoint file or module key does not exist, an empty dictionary will be returned.
- Parameters:
checkpoint_file (str) – JSON filename (including full path) to read from.
module_key (str) – Module key for the specific checkpoint dictionary to return.
- Returns:
Module dictionary associated with the module_key.
- Return type:
dict
- orchestrator.utils.restart.restarter = <orchestrator.utils.restart.Restart object>¶
Restart instance which can be imported for use in other modules.