torchcell.paper.tables.SignalCache

class SignalCache(*, path: ~pathlib.Path, entries: dict[str, ~torchcell.paper.tables._CacheEntry] = <factory>)[source]

Bases: BaseModel

JSON-backed memo of (n, bytes) per id, keyed by LMDB fingerprint.

Reuse across runs so only rebuilt datasets recompute. entries maps a stable id (e.g. a dataset subpath) to its last computed signal + the LMDB fingerprint it was computed from.

classmethod load(path: str | Path) → SignalCache[source]

Load an existing cache JSON, or return an empty cache for a new path.

save() → None[source]

Persist the cache to its JSON path (sorted for a stable diff).

get_or_compute(cache_id: str, lmdb_dir: str | ~pathlib.Path, *, extract: ~collections.abc.Callable[[dict[str, ~typing.Any]], bytes] = <function default_phenotype_bytes>, label: str = '', log: ~collections.abc.Callable[[str], None] = <built-in function print>) → tuple[int, int, bool][source]

Return (n, bytes, from_cache), computing + persisting on a miss.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].