Unverified Commit 77ccd878 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

[FBCode->GH] Fix LSUN dataset tests flakyness (#3703)


Co-authored-by: default avatarVasilis Vryniotis <datumbox@users.noreply.github.com>
parent 2f3b7ca9
...@@ -1010,11 +1010,17 @@ class LSUNTestCase(datasets_utils.ImageDatasetTestCase): ...@@ -1010,11 +1010,17 @@ class LSUNTestCase(datasets_utils.ImageDatasetTestCase):
with super().create_dataset(*args, **kwargs) as output: with super().create_dataset(*args, **kwargs) as output:
yield output yield output
# Currently datasets.LSUN caches the keys in the current directory rather than in the root directory. Thus, # Currently datasets.LSUN caches the keys in the current directory rather than in the root directory. Thus,
# this creates a number of unique _cache_* files in the current directory that will not be removed together # this creates a number of _cache_* files in the current directory that will not be removed together
# with the temporary directory # with the temporary directory
for file in os.listdir(os.getcwd()): for file in os.listdir(os.getcwd()):
if file.startswith("_cache_"): if file.startswith("_cache_"):
try:
os.remove(file) os.remove(file)
except FileNotFoundError:
# When the same test is run in parallel (in fb internal tests), a thread may remove another
# thread's file. We should be able to remove the try/except when
# https://github.com/pytorch/vision/issues/825 is fixed.
pass
def _parse_classes(self, classes): def _parse_classes(self, classes):
if not isinstance(classes, str): if not isinstance(classes, str):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment