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

Fix snapshot download when local_dir is provided. #2592

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

hanouticelina
Copy link
Contributor

@hanouticelina hanouticelina commented Oct 8, 2024

This PR fixes a bug reported internally in this private slack message.

Issue

The issue comes from huggingface_hub.snapshot_download() which does not return the folder that already contains the downloaded files if:

  • local_dir is provided.
  • we are in offline mode, i.e. no internet connection, hub down, or internet connection is deactivated (local_files_only=True or HF_HUB_OFFLINE=True).

Fix

When local_dir is provided, we should check if it exists and contains files, as it's expected to have the latest version of the repo replicated there rather than in a snapshot folder.

@hanouticelina hanouticelina requested a review from Wauplin October 8, 2024 08:14
@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
Contributor

@Wauplin Wauplin 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 spotting and fixing this!

src/huggingface_hub/_snapshot_download.py Outdated Show resolved Hide resolved
tests/test_snapshot_download.py Outdated Show resolved Hide resolved
tests/test_snapshot_download.py Outdated Show resolved Hide resolved
@hanouticelina hanouticelina requested a review from Wauplin October 8, 2024 15:40
@hanouticelina
Copy link
Contributor Author

thanks for the review! I added your suggestions here : f3a8bbb

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Thanks!

@hanouticelina
Copy link
Contributor Author

let's merge this :)

@hanouticelina hanouticelina merged commit c8da356 into main Oct 8, 2024
19 checks passed
@hanouticelina hanouticelina deleted the fix-local-dir-snapshot-download branch October 8, 2024 19:05
hanouticelina added a commit that referenced this pull request Oct 9, 2024
* Fix snapshot download when local_dir is provided

* Fix tests docstring

* Add comment

* Fixes post-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