From d67659504b6e6409299df78c572a104cd3d9fb80 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Tue, 11 Jan 2022 00:06:49 +0000 Subject: [PATCH] capture windows permission error Signed-off-by: Wenqi Li --- monai/data/dataset.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/monai/data/dataset.py b/monai/data/dataset.py index ecb92eda97..8a42ed5181 100644 --- a/monai/data/dataset.py +++ b/monai/data/dataset.py @@ -335,7 +335,9 @@ def _cachecheck(self, item_transformed): raise e _item_transformed = self._pre_transform(deepcopy(item_transformed)) # keep the original hashed - if hashfile is not None: + if hashfile is None: + return _item_transformed + try: # NOTE: Writing to a temporary directory and then using a nearly atomic rename operation # to make the cache more robust to manual killing of parent process # which may leave partially written cache files in an incomplete state @@ -354,6 +356,8 @@ def _cachecheck(self, item_transformed): shutil.move(temp_hash_file, hashfile) except FileExistsError: pass + except PermissionError: # project-monai/monai issue #3613 + pass return _item_transformed def _transform(self, index: int):