Skip to content

Commit

Permalink
Use mkstemp to replace deprecated mktemp call (#5303)
Browse files Browse the repository at this point in the history
* Use mkstemp

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Remove num examples

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Close instead of remove

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Close the handle

Signed-off-by: dbczumar <corey.zumar@databricks.com>
  • Loading branch information
dbczumar committed Jan 26, 2022
1 parent 271750b commit 61984e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mlflow/utils/file_utils.py
Expand Up @@ -287,7 +287,7 @@ def _filter_timestamps(tar_info):
tar_info.mtime = 0
return tar_info if custom_filter is None else custom_filter(tar_info)

unzipped_filename = tempfile.mktemp()
unzipped_file_handle, unzipped_filename = tempfile.mkstemp()
try:
with tarfile.open(unzipped_filename, "w") as tar:
tar.add(source_dir, arcname=archive_name, filter=_filter_timestamps)
Expand All @@ -298,7 +298,7 @@ def _filter_timestamps(tar_info):
) as gzipped_tar, open(unzipped_filename, "rb") as tar:
gzipped_tar.write(tar.read())
finally:
os.remove(unzipped_filename)
os.close(unzipped_file_handle)


def _copy_project(src_path, dst_path=""):
Expand Down

1 comment on commit 61984e6

@sr-mpamera
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The security check fails even though the mlflow is upgraded to 1.23.1. It gives the error "Insecure Temporary File in mlflow".
Any suggested solution please ?

Please sign in to comment.