1313import boto3
1414from boto3 .s3 .transfer import TransferConfig
1515from botocore .config import Config
16+
1617# pylint: disable=unused-import
1718from botocore .exceptions import ClientError as CloudFileNotFoundError
1819from pydantic .v1 import BaseModel , Field
@@ -142,22 +143,24 @@ def get_client(self):
142143 :return:
143144 """
144145 customize_boto3_config = None
145- if (self .user_credential is not None
146- and self .user_credential .storage_provider is not None
147- and self .user_credential .storage_provider == "OSS" ):
146+ if (
147+ self .user_credential is not None
148+ and self .user_credential .storage_provider is not None
149+ and self .user_credential .storage_provider == "OSS"
150+ ):
148151 # OSS does not support aws integrity check
149- customize_boto3_config = Config (request_checksum_calculation = "when_required" ,
150- response_checksum_validation = "when_required" ,
151- s3 = {
152- "addressing_style" : "virtual"
153- } )
152+ customize_boto3_config = Config (
153+ request_checksum_calculation = "when_required" ,
154+ response_checksum_validation = "when_required" ,
155+ s3 = { "addressing_style" : "virtual" },
156+ )
154157 # pylint: disable=no-member
155158 kwargs = {
156159 "region_name" : Env .current .aws_region ,
157160 "aws_access_key_id" : self .user_credential .access_key_id ,
158161 "aws_secret_access_key" : self .user_credential .secret_access_key ,
159162 "aws_session_token" : self .user_credential .session_token ,
160- "config" : customize_boto3_config
163+ "config" : customize_boto3_config ,
161164 }
162165
163166 if self .endpoint is not None :
@@ -175,8 +178,8 @@ def is_expired(self):
175178 """
176179 # pylint: disable=no-member
177180 return (
178- self .user_credential .expiration
179- - datetime .now (tz = self .user_credential .expiration .tzinfo )
181+ self .user_credential .expiration
182+ - datetime .now (tz = self .user_credential .expiration .tzinfo )
180183 ).total_seconds () < 300
181184
182185
@@ -220,9 +223,9 @@ def get_cloud_path_prefix(self, resource_id, file_name):
220223 return base_path
221224
222225 def create_multipart_upload (
223- self ,
224- resource_id : str ,
225- remote_file_name : str ,
226+ self ,
227+ resource_id : str ,
228+ remote_file_name : str ,
226229 ):
227230 """
228231 Creates a multipart upload for the specified resource ID and remote file name.
@@ -243,12 +246,12 @@ def create_multipart_upload(
243246
244247 # pylint: disable=too-many-arguments
245248 def upload_part (
246- self ,
247- resource_id : str ,
248- remote_file_name : str ,
249- upload_id : str ,
250- part_number : int ,
251- compressed_chunk ,
249+ self ,
250+ resource_id : str ,
251+ remote_file_name : str ,
252+ upload_id : str ,
253+ part_number : int ,
254+ compressed_chunk ,
252255 ):
253256 """
254257 Uploads a part of the file as part of a multipart upload.
@@ -277,7 +280,7 @@ def upload_part(
277280 return {"ETag" : response ["ETag" ], "PartNumber" : part_number }
278281
279282 def complete_multipart_upload (
280- self , resource_id : str , remote_file_name : str , upload_id : str , uploaded_parts : dict
283+ self , resource_id : str , remote_file_name : str , upload_id : str , uploaded_parts : dict
281284 ):
282285 """
283286 Completes a multipart upload for the specified resource ID, remote file name, upload ID, e_tag, and part number.
@@ -302,7 +305,7 @@ def complete_multipart_upload(
302305 )
303306
304307 def upload_file (
305- self , resource_id : str , remote_file_name : str , file_name : str , progress_callback = None
308+ self , resource_id : str , remote_file_name : str , file_name : str , progress_callback = None
306309 ):
307310 """
308311 Upload a file to s3.
@@ -345,15 +348,15 @@ def _call_back(bytes_in_chunk):
345348
346349 # pylint: disable=too-many-arguments
347350 def download_file (
348- self ,
349- resource_id : str ,
350- remote_file_name : str ,
351- to_file : str = None ,
352- to_folder : str = "." ,
353- overwrite : bool = True ,
354- progress_callback = None ,
355- log_error = True ,
356- verbose = True ,
351+ self ,
352+ resource_id : str ,
353+ remote_file_name : str ,
354+ to_file : str = None ,
355+ to_folder : str = "." ,
356+ overwrite : bool = True ,
357+ progress_callback = None ,
358+ log_error = True ,
359+ verbose = True ,
357360 ):
358361 """
359362 Download a file from s3.
0 commit comments