Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 6598: load_dataset broken for data_files on s3 #6862

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

matstrand
Copy link

@matstrand matstrand commented May 3, 2024

Fixes /issues/6598

I've added a new test case and a solution. Before applying the solution the test case was failing with the same error described in the linked issue.

MRE:

pip install "datasets[s3]"
python -c "from datasets import load_dataset; load_dataset('csv', data_files={'train': 's3://noaa-gsod-pds/2024/A5125600451.csv'})"

@matstrand matstrand force-pushed the issue-6598-load-dataset-broken-s3 branch 4 times, most recently from bf3c8c2 to 88cc5a3 Compare May 3, 2024 02:06
@matstrand matstrand force-pushed the issue-6598-load-dataset-broken-s3 branch from c3c0c06 to ded2cac Compare May 3, 2024 02:54
Comment on lines 571 to 574
if scheme in ("s3", "s3a") and storage_options is not None and "hf" in storage_options:
# Issue 6598: **storage_options is passed to botocore.session.Session()
# and must not contain keys that become invalid kwargs.
del storage_options["hf"]
Copy link
Member

Choose a reason for hiding this comment

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

it would be great to have a more general solution for any filesystem than hardcoding something for S3

maybe in _prepare_single_hop_path_and_storage_options() in file_utils.py ?

Copy link

Choose a reason for hiding this comment

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

Thanks ! Can you please explain a bit more what a better general solution could be? Is this an option ? Move this logic to set the hf token to this protocol check Link

Copy link
Author

Choose a reason for hiding this comment

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

Thanks both, seems the root issue is settingDownloadConfig.storage_options['hf'] in all situations. We may be able to remove that as test_load.py passes without it. It was added at #6028 but seems possibly obsoleted by #6784.

I've pushed a change. @lhoestq can you please trigger the CI so we can see if this introduces any regressions?

Copy link
Member

Choose a reason for hiding this comment

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

sure, I triggered the ci

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link

@stoicio stoicio left a comment

Choose a reason for hiding this comment

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

Looks good to me, Thanks for fixing !

tests/test_load.py Outdated Show resolved Hide resolved
@@ -93,7 +93,7 @@ def __post_init__(self, use_auth_token):
FutureWarning,
)
self.token = use_auth_token
if "hf" not in self.storage_options:
if self.token is not None and "hf" not in self.storage_options:
Copy link
Author

Choose a reason for hiding this comment

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

I was worried that removing this altogether might break functionality for someone. This still might break CI but let's see before spending more time on it.

Copy link
Member

Choose a reason for hiding this comment

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

you might have to revert this, since we need the endpoint to be in the storage options even if token is None

Copy link
Author

Choose a reason for hiding this comment

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

I'm trying to account for that here. This way _prepare_path_and_storage_options ensures that the endpoint is in the storage options without needing to populate it for all protocols in __post_init__.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected keyword argument 'hf' when downloading CSV dataset from S3
4 participants