Unverified Commit 3994c045 authored by xloem's avatar xloem Committed by GitHub
Browse files

Speed up git-lfs detection on error (#20641)

Prevent read and discard of entire checkpoint file.
parent 147fa37f
...@@ -415,7 +415,7 @@ def load_state_dict(checkpoint_file: Union[str, os.PathLike]): ...@@ -415,7 +415,7 @@ def load_state_dict(checkpoint_file: Union[str, os.PathLike]):
except Exception as e: except Exception as e:
try: try:
with open(checkpoint_file) as f: with open(checkpoint_file) as f:
if f.read().startswith("version"): if f.read(7) == "version":
raise OSError( raise OSError(
"You seem to have cloned a repository without having git-lfs installed. Please install " "You seem to have cloned a repository without having git-lfs installed. Please install "
"git-lfs and run `git lfs install` followed by `git lfs pull` in the folder " "git-lfs and run `git lfs install` followed by `git lfs pull` in the folder "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment