Torchhub: rewrite commit hash check to avoid using unnecessary GitHub API credits...
authorNicolas Hug <nicolashug@fb.com>
Fri, 17 Sep 2021 16:49:46 +0000 (09:49 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 17 Sep 2021 17:30:39 +0000 (10:30 -0700)
commitf9bf144a0c5e3627f5fafb256cebf1f02152ab0c
treedb86e20ed131a99c6e68a1e22cb79647aeb8c275
parent0559cb37cd2dbee6dce25c6afcd155e2fdd1f335
Torchhub: rewrite commit hash check to avoid using unnecessary GitHub API credits (#64362)

Summary:
This PR adds more detailed error messages to torchhub if the commit hash validation goes wrong, providing suggestions to the users on how to resolve the issue.

It also documents why such validation is important.

EDIT: it also avoids validatating some stuff when we know "stuff" isn't a commit since there's no risk in this case

CC malfet mthrok

cc nairbv NicolasHug

Pull Request resolved: https://github.com/pytorch/pytorch/pull/64362

Reviewed By: gchanan, malfet

Differential Revision: D30731191

Pulled By: NicolasHug

fbshipit-source-id: d1ee7c2ef2591dd7a5291977af1635ada2552d1b
test/test_utils.py
torch/hub.py