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

Method test_mp_cache

tests/data/test_lmdbdataset_dist.py:43–70  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

41
42 @DistCall(nnodes=1, nproc_per_node=1)
43 def test_mp_cache(self):
44 items = [[list(range(i))] for i in range(5)]
45
46 ds = LMDBDataset(items, transform=_InplaceXform(), cache_dir=self.tempdir, lmdb_kwargs={"map_size": 10 * 1024})
47 self.assertEqual(items, [[[]], [[0]], [[0, 1]], [[0, 1, 2]], [[0, 1, 2, 3]]])
48 ds1 = LMDBDataset(items, transform=_InplaceXform(), cache_dir=self.tempdir, lmdb_kwargs={"map_size": 10 * 1024})
49 self.assertEqual(list(ds1), list(ds))
50 self.assertEqual(items, [[[]], [[0]], [[0, 1]], [[0, 1, 2]], [[0, 1, 2, 3]]])
51
52 ds = LMDBDataset(
53 items,
54 transform=_InplaceXform(),
55 cache_dir=self.tempdir,
56 lmdb_kwargs={"map_size": 10 * 1024},
57 hash_func=json_hashing,
58 )
59 self.assertEqual(items, [[[]], [[0]], [[0, 1]], [[0, 1, 2]], [[0, 1, 2, 3]]])
60 ds1 = LMDBDataset(
61 items,
62 transform=_InplaceXform(),
63 cache_dir=self.tempdir,
64 lmdb_kwargs={"map_size": 10 * 1024},
65 hash_func=json_hashing,
66 )
67 self.assertEqual(list(ds1), list(ds))
68 self.assertEqual(items, [[[]], [[0]], [[0, 1]], [[0, 1, 2]], [[0, 1, 2, 3]]])
69
70 self.assertTrue(isinstance(ds1.info(), dict))
71
72
73if __name__ == "__main__":

Callers

nothing calls this directly

Calls 3

infoMethod · 0.95
LMDBDatasetClass · 0.90
_InplaceXformClass · 0.70

Tested by

no test coverage detected