@@ -146,14 +146,16 @@ def upload_data(
146146 bucket_name = re .findall (r"https://(.*?).s3.amazonaws.com" , presigned_url )[0 ]
147147 s3_link = f"s3://{ bucket_name } /{ path } "
148148 return s3_link
149- except Exception as e :
149+ except Exception :
150150 if nattempts > 0 :
151151 return upload_data (file_name , content_type , content_encoding , nattempts - 1 )
152152 else :
153153 raise Exception ("File Uploading Error: Failure on Uploading to S3." )
154154
155155
156- def s3_to_csv (s3_url : Text , aws_credentials : Optional [Dict [Text , Text ]] = {"AWS_ACCESS_KEY_ID" : None , "AWS_SECRET_ACCESS_KEY" : None }) -> Text :
156+ def s3_to_csv (
157+ s3_url : Text , aws_credentials : Optional [Dict [Text , Text ]] = {"AWS_ACCESS_KEY_ID" : None , "AWS_SECRET_ACCESS_KEY" : None }
158+ ) -> Text :
157159 """Convert s3 url to a csv file and download the file in `download_path`
158160
159161 Args:
@@ -179,11 +181,11 @@ def s3_to_csv(s3_url: Text, aws_credentials: Optional[Dict[Text, Text]] = {"AWS_
179181 aws_secret_access_key = aws_credentials .get ("AWS_SECRET_ACCESS_KEY" ) or os .getenv ("AWS_SECRET_ACCESS_KEY" )
180182 s3 = boto3 .client ("s3" , aws_access_key_id = aws_access_key_id , aws_secret_access_key = aws_secret_access_key )
181183 response = s3 .list_objects_v2 (Bucket = bucket_name , Prefix = prefix )
182- except NoCredentialsError as e :
184+ except NoCredentialsError :
183185 raise Exception (
184186 "to use the s3 bucket option you need to set the right AWS credentials [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY]"
185187 )
186- except Exception as e :
188+ except Exception :
187189 raise Exception ("the bucket you are trying to use does not exist" )
188190
189191 try :
@@ -222,10 +224,10 @@ def s3_to_csv(s3_url: Text, aws_credentials: Optional[Dict[Text, Text]] = {"AWS_
222224 main_file_name = Path (data [first_key ][i ]).stem
223225 for val in data .values ():
224226 if Path (val [i ]).stem != main_file_name :
225- raise Exception (f "all the files in different directories should have the same prefix" )
227+ raise Exception ("all the files in different directories should have the same prefix" )
226228
227229 elif prefix == "" :
228- raise Exception (f "ERROR the files can't be at the root of the bucket " )
230+ raise Exception ("ERROR the files can't be at the root of the bucket " )
229231 else :
230232 data = {prefix : [f"s3://{ bucket_name } /{ file } " for file in files ]}
231233
0 commit comments