diff --git a/horovod/runner/js_run.py b/horovod/runner/js_run.py index d25f5dd3f6..5be6801198 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 f7a82cd06d..5f506f9f0a 100644 --- a/test/single/test_run.py +++ b/test/single/test_run.py @@ -640,7 +640,7 @@ def test(output, expected, exit_code=0): 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 038ed1eab9..77871c456a 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