CheckpointStore
Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- class CheckpointStore(root: str | Path, *, run_fingerprint: str | None = None, strict: bool = False, clustering_mode: str | None = None)[source]
Bases:
objectFile-based persistence for subject-level results, keyed by cache key.
Each entry is one pickle file named by a digest of its key, written atomically (write-then-rename) so an interrupted run never leaves a half-written checkpoint that a resumed run would mistake for a valid result.
- Parameters:
root – Directory holding the checkpoint files. Created on first write. A v0.1
manifest.json/subjects/tree here is migrated automatically on open.run_fingerprint – Optional analysis fingerprint bound to this store. When set, a mismatch with an existing fingerprint file is either raised (
strict=True) or warned. Also scopes keys written during v0.1 → v1 migration.strict – When
True, incompatible fingerprints raiseCompatibilityError(v0.1strict_checkpoint_hash). Legacy layouts are migrated rather than refused; only a corrupt v0.1 manifest raises.
- __init__(root: str | Path, *, run_fingerprint: str | None = None, strict: bool = False, clustering_mode: str | None = None) None[source]
- get(key: str) Any | None[source]
Return a previously stored result, or
Nonewhen absent.A corrupt entry is treated as absent (and removed) rather than failing the run: a checkpoint is a cache, never the source of truth.
- Parameters:
key – Cache key produced by the operator’s
cache_key.
- put(key: str, value: Any) None[source]
Store a result under
keyatomically.Storing a success clears any earlier failure record for the same key, so a retried subject that finally succeeds resumes cleanly.
- Parameters:
key – Cache key produced by the operator’s
cache_key.value – Picklable result value.
- contains(key: str) bool[source]
Return whether a success entry exists for
key.- Parameters:
key – Cache key produced by the operator’s
cache_key.
- put_failure(key: str, message: str) None[source]
Record that computing
keyfailed, with a human-readable cause.Only the terminal failure should be recorded (after a backend’s retry rounds are exhausted); intermediate failures of an in-flight retry never reach the store.
- Parameters:
key – Cache key produced by the operator’s
cache_key.message – Failure description (exception type and text).
- get_failure(key: str) str | None[source]
Return the recorded failure message for
key, orNone.A corrupt failure record is treated as absent (and removed), on the same “a checkpoint is a cache” principle as success entries.
- Parameters:
key – Cache key produced by the operator’s
cache_key.
- discard_failure(key: str) None[source]
Remove any failure record for
key(e.g. before a forced rerun).- Parameters:
key – Cache key produced by the operator’s
cache_key.