跳转至

检查点系统

BaseCheckpointSaver

zerograph.checkpoint.base.BaseCheckpointSaver

Bases: ABC

Abstract base class for checkpoint savers.

get_tuple abstractmethod

get_tuple(config: dict) -> CheckpointTuple | None

Get a checkpoint tuple by config.

get

get(config: dict) -> Checkpoint | None

Get a checkpoint by config.

put abstractmethod

put(
    config: dict,
    checkpoint: Checkpoint,
    metadata: CheckpointMetadata,
) -> dict

Store a checkpoint. Returns updated config.

put_writes abstractmethod

put_writes(
    config: dict, writes: list[PendingWrite], task_id: str
) -> None

Store pending writes for a task.

list abstractmethod

list(
    config: dict,
    *,
    limit: int = 10,
    before: dict | None = None
) -> list[CheckpointTuple]

List checkpoints.

delete_thread

delete_thread(thread_id: str) -> None

Delete all checkpoints for a thread.

Checkpoint 类型

zerograph.checkpoint.base.Checkpoint

Bases: TypedDict

zerograph.checkpoint.base.CheckpointMetadata

Bases: TypedDict

zerograph.checkpoint.base.CheckpointTuple

Bases: NamedTuple

InMemorySaver

zerograph.checkpoint.memory.InMemorySaver

Bases: BaseCheckpointSaver

In-memory checkpoint storage.

get_tuple

get_tuple(config: dict) -> CheckpointTuple | None

put

put(
    config: dict,
    checkpoint: Checkpoint,
    metadata: CheckpointMetadata,
) -> dict

put_writes

put_writes(
    config: dict, writes: list[PendingWrite], task_id: str
) -> None

list

list(
    config: dict,
    *,
    limit: int = 10,
    before: dict | None = None
) -> list[CheckpointTuple]

delete_thread

delete_thread(thread_id: str) -> None

get_pending_writes

get_pending_writes(config: dict) -> list[PendingWrite]

SqliteSaver

zerograph.checkpoint.sqlite.SqliteSaver

Bases: BaseCheckpointSaver

SQLite-backed checkpoint storage with WAL mode and thread-safe connections.

__init__

__init__(
    conn_string: str | Path = "checkpoints.db",
) -> None

get_tuple

get_tuple(config: dict) -> CheckpointTuple | None

put

put(
    config: dict,
    checkpoint: Checkpoint,
    metadata: CheckpointMetadata,
) -> dict

put_writes

put_writes(
    config: dict, writes: list[PendingWrite], task_id: str
) -> None

list

list(
    config: dict,
    *,
    limit: int = 10,
    before: dict | None = None
) -> list[CheckpointTuple]

delete_thread

delete_thread(thread_id: str) -> None

get_pending_writes

get_pending_writes(config: dict) -> list[PendingWrite]

close

close() -> None

AsyncSqliteSaver

zerograph.checkpoint.sqlite.AsyncSqliteSaver

Bases: SqliteSaver

Async wrapper around SqliteSaver using asyncio.to_thread.

All methods have async variants (aget_tuple, aput, etc.) that delegate to the synchronous SqliteSaver methods via asyncio.to_thread. The synchronous methods are also still available.

For :memory: databases, all async operations are routed through a single-threaded executor so they share the same in-memory database.

__init__

__init__(
    conn_string: str | Path = "checkpoints.db",
) -> None

aget_tuple async

aget_tuple(config: dict) -> CheckpointTuple | None

aput async

aput(
    config: dict,
    checkpoint: Checkpoint,
    metadata: CheckpointMetadata,
) -> dict

aput_writes async

aput_writes(
    config: dict, writes: list[PendingWrite], task_id: str
) -> None

alist async

alist(
    config: dict,
    *,
    limit: int = 10,
    before: dict | None = None
) -> list[CheckpointTuple]

adelete_thread async

adelete_thread(thread_id: str) -> None

aget_pending_writes async

aget_pending_writes(config: dict) -> list[PendingWrite]

close

close() -> None