MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _cachecheck

Method _cachecheck

monai/data/dataset.py:697–711  ·  view source on GitHub ↗

If the item is not found in the lmdb file, resolves to the persistent cache default behaviour.

(self, item_transformed)

Source from the content-addressed store, hash-verified

695 return lmdb.open(path=f"{self.db_file}", subdir=False, **self.lmdb_kwargs)
696
697 def _cachecheck(self, item_transformed):
698 """If the item is not found in the lmdb file, resolves to the persistent cache default behaviour."""
699 if self._read_env is None:
700 # this runs on multiple processes, each one should have its own env.
701 self._read_env = self._fill_cache_start_reader(show_progress=False)
702 with self._read_env.begin(write=False) as txn:
703 data = txn.get(self.hash_func(item_transformed))
704 if data is None:
705 warnings.warn("LMDBDataset: cache key not found, running fallback caching.")
706 return super()._cachecheck(item_transformed)
707 try:
708 # return pickle.loads(data)
709 return self._safe_deserialize(data)
710 except Exception as err:
711 raise RuntimeError("Invalid cache value, corrupted lmdb file?") from err
712
713 def info(self):
714 """

Callers

nothing calls this directly

Calls 4

_safe_deserializeMethod · 0.95
getMethod · 0.80
_cachecheckMethod · 0.45

Tested by

no test coverage detected