Skip to content

fix snapshot download behavior in offline mode when downloading to a local dir #3009

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

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

Conversation

hanouticelina
Copy link
Contributor

Should fix the incorrect behavior mentioned in this slack message (internal).

This PR addresses an issue where snapshot_download behaves incorrectly when:

  • a user specifies a local_dir parameter in offline mode (either viia HF_HUB_OFFLINE=1 or connection error).
  • the files are available in the cache but not in the local_dir.

Currently, in this scenario, we incorrectly returns the path to the cache directory instead of raising an appropriate error. This PR fixes that.

@hanouticelina hanouticelina requested a review from Wauplin April 16, 2025 12:12
@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.

From my understanding, I feel a correct fix would be to update L203 from

if commit_hash is not None:

to

if commit_hash is not None and local_dir is None:

i.e. we do the snapshot folder check only if local_dir is not provided by the user. When local_dir is set, the logic to handle things is a bit below (here) and returns with a warning if folder is not empty.

@hanouticelina hanouticelina requested a review from Wauplin April 17, 2025 12:36
@hanouticelina hanouticelina requested a review from Wauplin April 22, 2025 12:14
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!

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