question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use a finer exception when local_files_only=True and a file is missing in cache

See original GitHub issue

In Transformers we sometime try to access files that are not in a repo, catch the error (EntryNotFoundError for distant repos) and try a different file. For instance most models have a single weight file named pytorch_model.bin but some models have several checkpoint files and an index since they are extremely big. For those, there is no pytorch_model.bin but a pytorch_model.bin.index.json.

Therefore, the logic in from_pretrained is to look at pytorch_model.bin first, and if it’s not there, at pytorch_model.bin.index.json. Now when we have an internet connection, we can catch the EntryNotFoundError and all is fine. When there is no internet or the user decided to activate the offline mode however, hf_hub_download returns a ValueError, but it also returns a ValueError in many different situations, so we need to catch it and match the error message in Transformers which is not very clean, and very prone to breaking in the future.

It would be much nicer if the error raised was more specific, like a FileNotFoundError or any subclass of ValueError that would only be raised in this specific situation.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
julien-ccommented, Aug 9, 2022

yes that’s what i meant, thanks!

1reaction
sguggercommented, Aug 9, 2022

I haven’t seen it discussed anywhere personally, this stems from this PR (bug reported by Stas on slack) and I was pointing at it on this comment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete failed with "Missing cache file for object ..." in ... - IBM
Problem. Attempts to delete an object failed with "Missing cache file for object name-version:type:instance" in IBM Rational Synergy.
Read more >
Android Gradle build fails from cached files - Stack Overflow
I've tried Invalidate Cache and Restart from android studio and I've tried rm -rf ~/. gradle/caches but I continue getting the same error....
Read more >
Out of Memory for cache file C:\Program Files\avs\var\p_cache ...
I have a server that backups have failed two consecutive nights. Here is the error messages: AVTAR FATAL <5351>: Main: Unhandled internal exception...
Read more >
Caching in GitLab CI/CD
A cache is one or more files a job downloads and saves. Subsequent jobs that use the same cache don't have to download...
Read more >
How to delete precompile cache? - General Usage
I am fine with nuking the whole cache or whatever, but do not want to go ballistic ... cache file for ode_integratoren [top-level]...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found