BaseCheckpointStore¶
Bases: ABC
The interface shared by the durable and in-memory stores.
attr defaults to the primary attribute and is a payload-side name.
Attributes¶
| Name | Type | Value | Doc |
|---|---|---|---|
layout |
StoreLayout |
unset |
consolidate
abstractmethod
¶
consolidate(*, encode_cache: dict | None = None) -> tuple[int, ...]
Merge every payload into the canonical file.
get
abstractmethod
¶
get(key: int, attr: str | None = None, *, strict: bool = True) -> Any
The value of attr at key; KeyError if absent everywhere.
iter_items
abstractmethod
¶
iter_items(attr: str | None = None, *, keys: Iterable[int] | None = None, strict: bool = True) -> Iterator[tuple[int, Any]]
Yield (key, value) pairs, each key once, in ascending order.
The durable store keeps the current file open between yields, so finish or close the iterator before writing to the same store.
keys
abstractmethod
¶
keys(attr: str | None = None, *, strict: bool = True) -> list
The sorted keys stored for attr.
missing ¶
missing(expected: Iterable[int], attr: str | None = None) -> list[int]
The sorted expected keys that are absent. Reads strictly.
nested
abstractmethod
¶
nested(key: int, attr: str = '_program_results', layout: StoreLayout = SHOT_LAYOUT) -> BaseCheckpointStore
A read-only view of the object stored at key in attr.
put_batch
abstractmethod
¶
put_batch(entries: Mapping[int, Mapping[str, Any]], *, worker_id: str | None = None, encode_cache: dict | None = None) -> BatchReceipt
Store a batch of entries and return a receipt.
write_snapshot
abstractmethod
¶
write_snapshot(obj: Serializable, *, keep_entries: bool = False, encode_cache: dict | None = None) -> None
Atomically write the canonical file from obj.
With keep_entries, the committed entries of the existing file
replace obj's own streamed entries. encode_cache receives the
new file's seed (see CheckpointStore.write_snapshot).