Use a finer exception when local_files_only=True and a file is missing in cache
See original GitHub issueIn 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:
- Created a year ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
yes that’s what i meant, thanks!
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.