Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/io/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def _strip_schema(url):
return result.netloc + result.path


def get_fs():
return s3fs.S3FileSystem(anon=False)
def get_fs(anon: bool = False):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will be removed by: #34266 and reverts error originally introduced in: https://github.com/pandas-dev/pandas/pull/33632/files#diff-a37b395bed03f0404dec864a4529c97dL37

return s3fs.S3FileSystem(anon=anon)


def get_file_and_filesystem(
Expand All @@ -38,7 +38,7 @@ def get_file_and_filesystem(
# aren't valid for that bucket.
# A NoCredentialsError is raised if you don't have creds
# for that bucket.
fs = get_fs()
fs = get_fs(anon=True)
file = fs.open(_strip_schema(filepath_or_buffer), mode)
return file, fs

Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/io/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import pytest

import pandas.util._test_decorators as td

from pandas import read_csv
import pandas._testing as tm

from pandas.io.common import is_s3_url

Expand All @@ -23,3 +26,12 @@ def test_streaming_s3_objects():
for el in data:
body = StreamingBody(BytesIO(el), content_length=len(el))
read_csv(body)


@tm.network
@td.skip_if_no("s3fs")
def test_read_without_creds_from_pub_bucket():
# GH 34626
# Use Amazon Open Data Registry - https://registry.opendata.aws/gdelt
result = read_csv("s3://gdelt-open-data/events/1981.csv", nrows=3)
assert len(result) == 3