From f59f0c29859ad701f268752fe4d8f0398235593a Mon Sep 17 00:00:00 2001 From: dbczumar Date: Mon, 24 Jan 2022 08:40:25 -0800 Subject: [PATCH 1/4] Use mkstemp Signed-off-by: dbczumar --- mlflow/utils/file_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlflow/utils/file_utils.py b/mlflow/utils/file_utils.py index 32653b343c445..f7c72340a76c1 100644 --- a/mlflow/utils/file_utils.py +++ b/mlflow/utils/file_utils.py @@ -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_filename = tempfile.mkstemp() try: with tarfile.open(unzipped_filename, "w") as tar: tar.add(source_dir, arcname=archive_name, filter=_filter_timestamps) From fa681860551ebe2f5b1b3fb1cd6cefe99eaefd57 Mon Sep 17 00:00:00 2001 From: dbczumar Date: Mon, 24 Jan 2022 08:43:55 -0800 Subject: [PATCH 2/4] Remove num examples Signed-off-by: dbczumar --- docs/source/models.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/models.rst b/docs/source/models.rst index 313d811c1a18a..b219d27a3f14e 100644 --- a/docs/source/models.rst +++ b/docs/source/models.rst @@ -805,7 +805,6 @@ and behavior: # load UCI Adult Data Set; segment it into training and test sets X, y = shap.datasets.adult() - num_examples = len(X) X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) # train XGBoost model From 0d4274c4bc1f9d1219d5e463eacd12f0ba8db878 Mon Sep 17 00:00:00 2001 From: dbczumar Date: Wed, 26 Jan 2022 13:24:00 -0800 Subject: [PATCH 3/4] Close instead of remove Signed-off-by: dbczumar --- mlflow/utils/file_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlflow/utils/file_utils.py b/mlflow/utils/file_utils.py index f7c72340a76c1..769b44793c1f5 100644 --- a/mlflow/utils/file_utils.py +++ b/mlflow/utils/file_utils.py @@ -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_filename) def _copy_project(src_path, dst_path=""): From 78e75b51e4741b0360d6e6c900438583683343cf Mon Sep 17 00:00:00 2001 From: dbczumar Date: Wed, 26 Jan 2022 13:55:07 -0800 Subject: [PATCH 4/4] Close the handle Signed-off-by: dbczumar --- mlflow/utils/file_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlflow/utils/file_utils.py b/mlflow/utils/file_utils.py index 769b44793c1f5..4b59a367372af 100644 --- a/mlflow/utils/file_utils.py +++ b/mlflow/utils/file_utils.py @@ -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.mkstemp() + 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) @@ -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.close(unzipped_filename) + os.close(unzipped_file_handle) def _copy_project(src_path, dst_path=""):