@@ -110,13 +110,26 @@ def download(data_name, api_key, service, dest_path, show_progress=True) -> FedM
110110 logging .error (error_message )
111111 return FedMLResponse (code = ResponseCode .FAILURE , message = error_message )
112112 download_url = metadata .download_url
113- zip_file_name = data_name + ".zip"
114- path_local = os .path .abspath (zip_file_name )
113+ given_extension = os .path .splitext (data_name )[1 ]
114+ is_file = True
115+ if (given_extension is None or given_extension == "" ):
116+ is_file = False
117+
118+ if not is_file :
119+ download_file_name = data_name + ".zip"
120+ else :
121+ download_file_name = data_name
122+ path_local = os .path .abspath (download_file_name )
115123 dest_path = os .path .abspath (dest_path ) if dest_path else data_name
116- if _download_using_presigned_url (download_url , zip_file_name , show_progress = show_progress ):
124+ if _download_using_presigned_url (download_url , download_file_name , show_progress = show_progress ):
117125 try :
118- shutil .unpack_archive (path_local , dest_path )
119- os .remove (path_local )
126+ if not is_file :
127+ shutil .unpack_archive (path_local , dest_path )
128+ os .remove (path_local )
129+ else :
130+ if not os .path .exists (dest_path ):
131+ os .makedirs (dest_path )
132+ shutil .move (path_local ,dest_path )
120133 abs_dest_path = os .path .abspath (dest_path )
121134 return FedMLResponse (code = ResponseCode .SUCCESS , message = f"Successfully downloaded and unzipped data at "
122135 f"{ abs_dest_path } " , data = abs_dest_path )
0 commit comments