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: actual error won't be raised while force_download=True #1983

Merged
merged 3 commits into from
Jan 17, 2024

Conversation

scruel
Copy link
Contributor

@scruel scruel commented Jan 16, 2024

No description provided.

@Wauplin
Copy link
Contributor

Wauplin commented Jan 16, 2024

Thanks for opening a PR about this @scruel! THinking about it, I think what we should do is to rework this line from

            raise ValueError(
                "We have no connection or you passed local_files_only, so force_download is not an accepted option."
            )

to

            if local_files_only:
                raise ValueError("Cannot pass 'force_download=True' and 'local_files_only=True' at the same time.")
            elif isinstance(head_call_error, OfflineModeIsEnabled):
                raise ValueError("Cannot pass 'force_download=True' when offline mode is enabled.") from head_call_error
            else:
                raise head_call_error

What I'm afraid with the current PR is that we might be missing some exceptions that we want to actually raise. So instead of raising on RepoNotFound and GatedRepoError specifically, we raise on everything except local_files_only=True and HF_HUB_OFFLINE=1 that are explicitly handled with a new (informative) error. What do you think @scruel?

@scruel
Copy link
Contributor Author

scruel commented Jan 16, 2024

I think what we should do is to rework this line from
So instead of raising on RepoNotFound and GatedRepoError specifically, we raise on everything except local_files_only=True and HF_HUB_OFFLINE=1 that are explicitly handled with a new (informative) error.

Agree, it will be more clear!

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.

Looks good! Thanks for iterating on it 🤗

@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

codecov bot commented Jan 16, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (5e3b603) 82.49% compared to head (324fec7) 82.45%.

Files Patch % Lines
src/huggingface_hub/file_download.py 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1983      +/-   ##
==========================================
- Coverage   82.49%   82.45%   -0.04%     
==========================================
  Files          66       66              
  Lines        8145     8150       +5     
==========================================
+ Hits         6719     6720       +1     
- Misses       1426     1430       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 making the changes @scruel! Looks good to me now 🎉

@Wauplin Wauplin merged commit 8496ea1 into huggingface:main Jan 17, 2024
14 checks passed
@scruel scruel deleted the patch-1 branch January 18, 2024 06:49
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.

None yet

3 participants