Benchanything's picture
Add 300 CheckerBench tasks, dataset card, and restoration tools (part 3)
8247f19 verified
Raw History Blame Contribute Delete
1.8 kB
diff --git a/horovod/runner/js_run.py b/horovod/runner/js_run.py
index d25f5dd3..5be68011 100644
--- a/horovod/runner/js_run.py
+++ b/horovod/runner/js_run.py
@@ -126,7 +126,12 @@ def generate_jsrun_rankfile(settings, path=None):
slots=settings.num_proc))
# Generate rankfile
- path = tempfile.mktemp() if path is None else path
+ # using mkstemp here instead of insecure mktemp.
+ # note that the caller is responsible for cleaning up this file
+ if path is None:
+ fd, path = tempfile.mkstemp()
+ fd.close()
+
with open(path, 'w') as tmp:
tmp.write('overlapping_rs: allow\n')
tmp.write('cpu_index_using: logical\n')
diff --git a/test/single/test_run.py b/test/single/test_run.py
index f7a82cd0..5f506f9f 100644
--- a/test/single/test_run.py
+++ b/test/single/test_run.py
@@ -640,7 +640,7 @@ class RunTests(unittest.TestCase):
test(("HYDRA build details:\n"
" Version: 3.3a2\n"
" Configure options: 'MPICHLIB_CFLAGS=-g -O2'\n"), _MPICH_IMPL)
-
+
test("Intel(R) MPI", _IMPI_IMPL)
test("Unknown MPI v1.00", _UNKNOWN_IMPL)
diff --git a/test/utils/common.py b/test/utils/common.py
index 038ed1ea..77871c45 100644
--- a/test/utils/common.py
+++ b/test/utils/common.py
@@ -112,15 +112,12 @@ def tempdir():
@contextlib.contextmanager
def temppath():
- path = tempfile.mktemp()
+ dir_path = tempfile.TemporaryDirectory()
+ path = os.path.join(dir_path.name,'temp_test_file')
try:
yield path
finally:
- if os.path.exists(path):
- if os.path.isfile(path):
- os.remove(path)
- else:
- shutil.rmtree(path)
+ dir_path.cleanup()
@contextlib.contextmanager