88
99import boto3
1010import lib .core as constances
11+ from lib .core .enums import ProjectType
1112import pandas as pd
1213import requests
1314from botocore .exceptions import ClientError
@@ -68,7 +69,8 @@ def validate_fuse(self):
6869 and self ._include_fuse
6970 ):
7071 raise AppValidationException (
71- f"Include fuse functionality is not supported for projects containing { self ._project .type } attached with URLs"
72+ "Include fuse functionality is not supported for projects containing "
73+ f"{ ProjectType .get_name (self ._project .type )} attached with URLs"
7274 )
7375
7476 def validate_folder_names (self ):
@@ -202,17 +204,16 @@ def upload_to_s3_from_folder(self, source: str, folder_path: str):
202204
203205 def _upload_file_to_s3 (_to_s3_bucket , _path , _s3_key ) -> None :
204206 _to_s3_bucket .upload_file (str (_path ), _s3_key )
205- self .reporter .update_progress ()
206207
207208 with concurrent .futures .ThreadPoolExecutor (max_workers = 10 ) as executor :
208209 results = []
209- self .reporter .start_progress ( len ( files_to_upload ), "Uploading" )
210+ self .reporter .start_spinner ( )
210211 for path in files_to_upload :
211212 s3_key = f"{ folder_path + '/' if folder_path else '' } { str (Path (path ).relative_to (Path (source )))} "
212213 results .append (
213214 executor .submit (_upload_file_to_s3 , to_s3_bucket , path , s3_key )
214215 )
215- self .reporter .finish_progress ()
216+ self .reporter .stop_spinner ()
216217
217218 def download_to_local_storage (self , destination : str , extract_zip = False ):
218219 exports = self ._service .get_exports (
@@ -227,22 +228,25 @@ def download_to_local_storage(self, destination: str, extract_zip=False):
227228 if not export :
228229 raise AppException ("Export not found." )
229230 export_status = export ["status" ]
230-
231- while export_status != ExportStatus .COMPLETE .value :
232- logger .info ("Waiting 5 seconds for export to finish on server." )
233- time .sleep (5 )
234-
235- export = self ._service .get_export (
236- team_id = self ._project .team_id ,
237- project_id = self ._project .id ,
238- export_id = export ["id" ],
239- )
240- if "error" in export :
241- raise AppException (export ["error" ])
242- export_status = export ["status" ]
243- if export_status in (ExportStatus .ERROR .value , ExportStatus .CANCELED .value ):
244- raise AppException ("Couldn't download export." )
245-
231+ if export_status != ExportStatus .COMPLETE .value :
232+ logger .info ("Waiting for export to finish on server." )
233+ self .reporter .start_spinner ()
234+ while export_status != ExportStatus .COMPLETE .value :
235+ export = self ._service .get_export (
236+ team_id = self ._project .team_id ,
237+ project_id = self ._project .id ,
238+ export_id = export ["id" ],
239+ )
240+ if "error" in export :
241+ raise AppException (export ["error" ])
242+ export_status = export ["status" ]
243+ if export_status in (
244+ ExportStatus .ERROR .value ,
245+ ExportStatus .CANCELED .value ,
246+ ):
247+ self .reporter .stop_spinner ()
248+ raise AppException ("Couldn't download export." )
249+ self .reporter .stop_spinner ()
246250 filename = Path (export ["path" ]).name
247251 filepath = Path (destination ) / filename
248252 with requests .get (export ["download" ], stream = True ) as response :
0 commit comments