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

Method _fill_cache

monai/data/grid_dataset.py:283–301  ·  view source on GitHub ↗

Compute and fill the cache content from data source. Args: indices: target indices in the `self.data` source to compute cache. if None, use the first `cache_num` items.

(self, indices=None)

Source from the content-addressed store, hash-verified

281 self._cache, self._cache_other = zip(*self._fill_cache(indices)) # type: ignore
282
283 def _fill_cache(self, indices=None) -> list:
284 """
285 Compute and fill the cache content from data source.
286
287 Args:
288 indices: target indices in the `self.data` source to compute cache.
289 if None, use the first `cache_num` items.
290
291 """
292 if self.cache_num <= 0:
293 return []
294 if indices is None:
295 indices = list(range(self.cache_num))
296 if self.progress and not has_tqdm:
297 warnings.warn("tqdm is not installed, will not show the caching progress bar.")
298
299 pfunc = tqdm if self.progress and has_tqdm else (lambda v, **_: v)
300 with ThreadPool(self.num_workers) as p:
301 return list(pfunc(p.imap(self._load_cache_item, indices), total=len(indices), desc="Loading dataset"))
302
303 def _load_cache_item(self, idx: int):
304 """

Callers 1

set_dataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected