File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -201,14 +201,23 @@ def get_filepath_or_buffer(
201
201
if filepath_or_buffer .startswith ("s3n://" ):
202
202
filepath_or_buffer = filepath_or_buffer .replace ("s3n://" , "s3://" )
203
203
fsspec = import_optional_dependency ("fsspec" )
204
- from botocore .exceptions import NoCredentialsError
204
+
205
+ # If botocore is installed we fallback to reading with anon=True
206
+ # to allow reads from public buckets
207
+ try :
208
+ import_optional_dependency ("botocore" )
209
+ from botocore .exceptions import ClientError , NoCredentialsError
210
+
211
+ err_types_to_retry_with_anon = (ClientError , NoCredentialsError )
212
+ except ImportError :
213
+ err_types_to_retry_with_anon = ()
205
214
206
215
try :
207
216
file_obj = fsspec .open (
208
217
filepath_or_buffer , mode = mode or "rb" , ** (storage_options or {})
209
218
).open ()
210
219
# GH 34626 Reads from Public Buckets without Credentials needs anon=True
211
- except NoCredentialsError :
220
+ except err_types_to_retry_with_anon :
212
221
if storage_options is None :
213
222
storage_options = {"anon" : True }
214
223
else :
You can’t perform that action at this time.
0 commit comments