@@ -63,6 +63,7 @@ def download(self):
6363 "Set `force_overwrite` to `True` if you wish to overwrite."
6464 )
6565 shutil .rmtree (self .target_dir )
66+ os .mkdir (self .target_dir )
6667 with utils .get_progress_bar (
6768 ArtifactDownloader .PROGRESS_STEPS_COUNT + self .PROGRESS_STEPS_COUNT
6869 ) as progress :
@@ -85,15 +86,16 @@ def _download(self):
8586 """Downloads model artifacts."""
8687 self .progress .update ("Importing model artifacts from catalog" )
8788 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 )
9799
98100class LargeArtifactDownloader (ArtifactDownloader ):
99101 PROGRESS_STEPS_COUNT = 4
@@ -157,17 +159,19 @@ def _download(self):
157159
158160 self .dsc_model .import_model_artifact (bucket_uri = bucket_uri , region = self .region )
159161 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 )
171175
172176 if self .remove_existing_artifact :
173177 self .progress .update (
0 commit comments