@@ -63,6 +63,7 @@ def download(self):
63
63
"Set `force_overwrite` to `True` if you wish to overwrite."
64
64
)
65
65
shutil .rmtree (self .target_dir )
66
+ os .mkdir (self .target_dir )
66
67
with utils .get_progress_bar (
67
68
ArtifactDownloader .PROGRESS_STEPS_COUNT + self .PROGRESS_STEPS_COUNT
68
69
) as progress :
@@ -85,15 +86,16 @@ def _download(self):
85
86
"""Downloads model artifacts."""
86
87
self .progress .update ("Importing model artifacts from catalog" )
87
88
zip_content = self .dsc_model .get_model_artifact_content ()
88
- with tempfile .TemporaryDirectory () as temp_dir :
89
- self .progress .update ("Copying model artifacts to the artifact directory" )
90
- zip_file_path = os .path .join (temp_dir , f"{ str (uuid .uuid4 ())} .zip" )
91
- with open (zip_file_path , "wb" ) as zip_file :
92
- zip_file .write (zip_content )
93
- self .progress .update ("Extracting model artifacts" )
94
- with ZipFile (zip_file_path ) as zip_file :
95
- zip_file .extractall (self .target_dir )
96
-
89
+ self .progress .update ("Copying model artifacts to the artifact directory" )
90
+
91
+ zip_file_path = os .path .join (self .target_dir , f"{ str (uuid .uuid4 ())} .zip" )
92
+ with open (zip_file_path , "wb" ) as zip_file :
93
+ zip_file .write (zip_content )
94
+ self .progress .update ("Extracting model artifacts" )
95
+ with ZipFile (zip_file_path ) as zip_file :
96
+ zip_file .extractall (self .target_dir )
97
+
98
+ utils .remove_file (zip_file_path )
97
99
98
100
class LargeArtifactDownloader (ArtifactDownloader ):
99
101
PROGRESS_STEPS_COUNT = 4
@@ -157,17 +159,19 @@ def _download(self):
157
159
158
160
self .dsc_model .import_model_artifact (bucket_uri = bucket_uri , region = self .region )
159
161
self .progress .update ("Copying model artifacts to the artifact directory" )
160
- with tempfile .TemporaryDirectory () as temp_dir :
161
- zip_file_path = os .path .join (temp_dir , f"{ str (uuid .uuid4 ())} .zip" )
162
- zip_file_path = utils .copy_file (
163
- uri_src = bucket_uri ,
164
- uri_dst = zip_file_path ,
165
- auth = self .auth ,
166
- progressbar_description = "Copying model artifacts to the artifact directory" ,
167
- )
168
- self .progress .update ("Extracting model artifacts" )
169
- with ZipFile (zip_file_path ) as zip_file :
170
- zip_file .extractall (self .target_dir )
162
+
163
+ zip_file_path = os .path .join (self .target_dir , f"{ str (uuid .uuid4 ())} .zip" )
164
+ zip_file_path = utils .copy_file (
165
+ uri_src = bucket_uri ,
166
+ uri_dst = zip_file_path ,
167
+ auth = self .auth ,
168
+ progressbar_description = "Copying model artifacts to the artifact directory" ,
169
+ )
170
+ self .progress .update ("Extracting model artifacts" )
171
+ with ZipFile (zip_file_path ) as zip_file :
172
+ zip_file .extractall (self .target_dir )
173
+
174
+ utils .remove_file (zip_file_path )
171
175
172
176
if self .remove_existing_artifact :
173
177
self .progress .update (
0 commit comments