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

Switch from cached_download to hf_hub_download in remaining occurrences #31284

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jun 6, 2024

(somehow related to huggingface/huggingface_hub#2317)

This PR get rids of the remaining cached_download in favor of the more robust hf_hub_download. Cached_download is quite legacy (replaced since Aug 2022) and I'd like to completely drop it at some point. The core part of transformers's logic made the switch quite some time ago already.

Main change is basically to go from

json.load(open(cached_download(hf_hub_url(repo_id, filename, repo_type="dataset")), "r"))

to

json.loads(Path(hf_hub_download(repo_id, filename, repo_type="dataset")).read_text())

I used Path(...).read_text() to avoid opening the file without closing it.

Note: there is still one occurrence of cached_download in ./src/transformers/models/deprecated/van/convert_van_to_pytorch.py but since it is in a deprecated/ folder, I did not bother maintaining it.

@Wauplin Wauplin requested a review from a team June 6, 2024 10:50
@Wauplin Wauplin changed the title Switch from cahed_download to hf_hub_download in remaining occurrences Switch from cached_download to hf_hub_download in remaining occurrences Jun 6, 2024
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for updating all of these!

@amyeroberts amyeroberts merged commit 9ef93fc into main Jun 6, 2024
21 checks passed
@amyeroberts amyeroberts deleted the remove-deprecated-cached-download branch June 6, 2024 11:06
@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.

@Wauplin
Copy link
Contributor Author

Wauplin commented Jun 6, 2024

That was quick! Thanks for the review 🤗

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.

3 participants