loqs.internal.checkpointstore¶
Durable checkpoint storage for streamed, int-keyed dict attributes.
A store holds entries keyed by an integer (a shot or item index). Each entry
carries one value per streamed attribute. Entries live in a canonical HDF5
file and, until consolidated, in atomically written per-worker payload
files. CheckpointStore is the durable implementation and
MemoryCheckpointStore is an in-memory twin with the same interface.
Classes¶
BaseCheckpointStoreBatchReceiptCheckpointReadErrorCheckpointStoreMemoryCheckpointStoreStoreLayoutStreamedAttr
Attributes¶
Functions¶
atomic_h5_file ¶
atomic_h5_file(path: str | PathLike) -> Iterator[h5py.File]
Write an HDF5 file atomically.
Opens <path>.tmp in mode "w" and yields it. On a normal exit the
file is closed and renamed onto path. On any BaseException the file
is closed, the temp file is removed and the exception propagates.
Windows can't replace a file that a handle holds open, so a caller
holding a handle on path closes it inside the block.
open_h5 ¶
open_h5(path: str | PathLike, mode: str) -> h5py.File
Open an HDF5 file, retrying only on BlockingIOError.
Lock contention is retried up to 5 attempts in all, waiting
delay + random.uniform(0, delay) with delay = 0.01 * 2**attempt.
The last BlockingIOError is re-raised. Any other error propagates at
once.
raise_if_uncommitted ¶
raise_if_uncommitted(f: File) -> None
Raise CheckpointReadError if a canonical file holds entries past
its commit marker. A file with no marker passes.