Skip to content

MemoryCheckpointStore

Bases: BaseCheckpointStore

An in-memory twin of CheckpointStore, holding values by reference.

It keeps the first value stored for a key and attribute. consolidate and write_snapshot do nothing.

MemoryCheckpointStore

MemoryCheckpointStore(layout: StoreLayout) -> None

Attributes

Name Type Value Doc
layout
(inherited)
StoreLayout unset

consolidate

consolidate(*, encode_cache: dict | None = None) -> tuple[int, ...]

Merge every payload into the canonical file.


get

get(key: int, attr: str | None = None, *, strict: bool = True) -> Any

The value of attr at key; KeyError if absent everywhere.


iter_items

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

keys(attr: str | None = None, *, strict: bool = True) -> list

The sorted keys stored for attr.


missing

Inherited method from BaseCheckpointStore.missing().


nested

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

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

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).