Make tests multi-process friendly. (#3683)
authorTim Hatch <tim@timhatch.com>
Thu, 1 Aug 2019 16:27:58 +0000 (09:27 -0700)
committerJared Roesch <roeschinc@gmail.com>
Thu, 1 Aug 2019 16:27:58 +0000 (09:27 -0700)
This side effect at module import time has a race condition between the "exists" check and the "mkdir" call.  The safer thing is to just call mkdir and catch the "already exists" error which is what makedirs does.

python/tvm/contrib/download.py

index bc6d324..b3ba7ef 100644 (file)
@@ -120,8 +120,8 @@ def download(url, path, overwrite=False, size_compare=False, verbose=1, retries=
 
 
 TEST_DATA_ROOT_PATH = os.path.join(os.path.expanduser('~'), '.tvm_test_data')
-if not os.path.exists(TEST_DATA_ROOT_PATH):
-    os.mkdir(TEST_DATA_ROOT_PATH)
+os.makedirs(TEST_DATA_ROOT_PATH, exist_ok=True)
+
 
 def download_testdata(url, relpath, module=None):
     """Downloads the test data from the internet.