From 012782381f1df013e9d55dc8056418b281986cf5 Mon Sep 17 00:00:00 2001 From: Nic Ma Date: Fri, 26 Mar 2021 11:12:15 +0800 Subject: [PATCH] [DLMED] fix SmartCache warning Signed-off-by: Nic Ma --- monai/data/dataset.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/monai/data/dataset.py b/monai/data/dataset.py index 9a4e932160..06a29574af 100644 --- a/monai/data/dataset.py +++ b/monai/data/dataset.py @@ -582,6 +582,9 @@ class SmartCacheDataset(Randomizable, CacheDataset): This replacement will not work if setting the `multiprocessing_context` of DataLoader to `spawn` or on windows(the default multiprocessing method is `spawn`) and setting `num_workers` greater than 0. + If using MONAI workflows, please add `SmartCacheHandler` to the handler list of trainer, + otherwise, please make sure to call `start()`, `update_cache()`, `shutdown()` during training. + Args: data: input data to load and transform to generate dataset for model. transform: transforms to execute operations on input data. @@ -800,18 +803,6 @@ def __len__(self): """ return self.cache_num - def __getitem__(self, index): - """ - Raise exception if didn't call the expected APIs in SmartCacheDataset. - - """ - if not self.is_started(): - raise RuntimeError( - "if using MONAI workflows, please add `SmartCacheHandler` to the handler list of trainer," - "otherwise, please make sure to call `start()`, `update_cache()`, `shutdown()` during training." - ) - return super().__getitem__(index) - class ZipDataset(Dataset): """