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 PermissionError while creating '.no_exist/' directory in cache #2594

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Oct 9, 2024

Should fix huggingface/transformers#33897 (cc @sanketsudake).

When trying to download a file that doesn't exist on a remote repo, huggingface_hub caches the information locally. Next time the user tries to download this file again, we will raise an error directly instead of attempting to make an HTTP call. This saves a few HTTP calls in transformers since the lib is not always aware of which tokenizers files exists on a given repo. This feature exists only when revision is passed with a specific commit_hash.

Since this feature is an optimization, it should be purely optional. That's why we have a try/catch around the file.touch() call to store non-existence of a given file. In huggingface/transformers#33897, @sanketsudake reported that the mkdir call is failing for them with a PermissionError. This PR fixes this by moving it inside the try/catch (PermissionError is a subclass of OSError).

@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

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

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

LGTM!

@Wauplin
Copy link
Contributor Author

Wauplin commented Oct 9, 2024

(failing test is unrelated)

@Wauplin Wauplin merged commit 4058e1f into main Oct 9, 2024
18 of 19 checks passed
@Wauplin Wauplin deleted the fix-permission-error-while-creating-no-exist-dir branch October 9, 2024 10:13
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.

Error in loading AutoTokenizer when correct token passed
3 participants