@@ -55,10 +55,10 @@ class BaseFileUploader(Generic[ContextT], ABC):
5555 """Abstract base class for uploaders"""
5656
5757 def __init__ (
58- self ,
59- context : ContextT ,
60- file_path : str | Path ,
61- display_progress = False ,
58+ self ,
59+ context : ContextT ,
60+ file_path : str | Path ,
61+ display_progress = False ,
6262 ):
6363 self ._context = context
6464 self ._file_path = Path (file_path )
@@ -96,7 +96,9 @@ def _prepare_upload(self):
9696
9797 def _get_upload_files (self , ** kwargs ):
9898 filename = os .path .basename (self ._file_path )
99- self ._file = UploadFileWithProgress (self ._file_path , display_progress = self ._display_progress )
99+ self ._file = UploadFileWithProgress (
100+ self ._file_path , display_progress = self ._display_progress
101+ )
100102 self ._cleanup_resources .append (self ._file )
101103 return {
102104 "file" : (filename , self ._file , "application/octet-stream" ),
@@ -118,7 +120,9 @@ def _perform_upload(self, **kwargs):
118120
119121 files = self ._get_upload_files (** kwargs )
120122 data = self ._get_upload_data (** kwargs )
121- self ._uploaded_file , error = self ._context .upload_api_endpoint .create (files = files , json = data )
123+ self ._uploaded_file , error = self ._context .upload_api_endpoint .create (
124+ files = files , json = data
125+ )
122126
123127 if not error :
124128 seconds = (datetime .now () - self ._started ).total_seconds ()
@@ -128,7 +132,7 @@ def _perform_upload(self, **kwargs):
128132 return
129133
130134 if "already exists in dataset" in str (
131- error
135+ error
132136 ): # VERY WEAK!!! But solution with HTTP 409 isn't nice either.
133137 self ._status = [Status .SKIPPED , Substatus .ALREADY_SYNCED , None ]
134138 else :
@@ -141,8 +145,9 @@ def _perform_upload(self, **kwargs):
141145 def _cleanup (self ):
142146 for resource in self ._cleanup_resources :
143147 try :
144- if hasattr (resource , "close" ) and \
145- not getattr (resource , "closed" , False ):
148+ if hasattr (resource , "close" ) and not getattr (
149+ resource , "closed" , False
150+ ):
146151 resource .close ()
147152 except Exception as e :
148153 self ._logger .error (f"{ self .log_prefix } { str (e )} ." )
@@ -159,7 +164,9 @@ def upload_file(self, **kwargs):
159164 try :
160165 self ._prepare_upload ()
161166 except Exception :
162- self ._logger .info (f"{ self .log_prefix } Upload preparation error. Trying again automatically in 1 second." )
167+ self ._logger .info (
168+ f"{ self .log_prefix } Upload preparation error. Trying again automatically in 1 second."
169+ )
163170 # Just try again
164171 time .sleep (1 )
165172 self ._prepare_upload ()
@@ -170,7 +177,9 @@ def upload_file(self, **kwargs):
170177 self ._perform_upload (** kwargs )
171178 except UploadRemoteFileError :
172179 # Just try again
173- self ._logger .info (f"{ self .log_prefix } Upload error. Trying again automatically in 1 second." )
180+ self ._logger .info (
181+ f"{ self .log_prefix } Upload error. Trying again automatically in 1 second."
182+ )
174183 time .sleep (1 )
175184 self ._perform_upload (** kwargs_copy )
176185 finally :
0 commit comments