checkpoint_storage¶
checkpoint_storage ¶
Checkpoint storage for fault tolerance.
Provides persistent storage of execution state to enable resume after failures.
CheckpointStorage ¶
Bases: ABC
Abstract base for checkpoint storage implementations.
Follows Strategy pattern for pluggable storage backends.
save
abstractmethod
¶
Save checkpoint data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
UUID
|
Unique session identifier |
required |
data
|
dict[str, Any]
|
Checkpoint data to save |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful |
Source code in ondine/adapters/checkpoint_storage.py
load
abstractmethod
¶
Load latest checkpoint data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
UUID
|
Session identifier |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Checkpoint data or None if not found |
list_checkpoints
abstractmethod
¶
List all available checkpoints.
Returns:
| Type | Description |
|---|---|
list[CheckpointInfo]
|
List of checkpoint information |
delete
abstractmethod
¶
Delete checkpoint for session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
UUID
|
Session identifier |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if deleted |
exists
abstractmethod
¶
Check if checkpoint exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
UUID
|
Session identifier |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if exists |
LocalFileCheckpointStorage ¶
Bases: CheckpointStorage
Local filesystem checkpoint storage implementation.
Stores checkpoints as JSON files for human readability and debugging.
Initialize local file checkpoint storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_dir
|
Path
|
Directory for checkpoints |
Path('.checkpoints')
|
use_json
|
bool
|
Use JSON format (True) or pickle (False) |
True
|
Source code in ondine/adapters/checkpoint_storage.py
save ¶
Save checkpoint to local file.
Source code in ondine/adapters/checkpoint_storage.py
load ¶
Load checkpoint from local file.
Source code in ondine/adapters/checkpoint_storage.py
list_checkpoints ¶
List all checkpoints in directory.
Source code in ondine/adapters/checkpoint_storage.py
delete ¶
Delete checkpoint file.
Source code in ondine/adapters/checkpoint_storage.py
exists ¶
cleanup_old_checkpoints ¶
Delete checkpoints older than specified days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int
|
Age threshold in days |
7
|
Returns:
| Type | Description |
|---|---|
int
|
Number of checkpoints deleted |