-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Torchhub: automatically disambiguate ref if it's both a branch and a tag #74418
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
Conversation
[ghstack-poisoned]
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 891ff0d (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
NicolasHug
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #74368
This PR does 2 things:
- Update the URL where we download the archive, according to the latest github API docs https://docs.github.com/en/rest/reference/repos#download-a-repository-archive-zip
- When a user hits a 300 because the requested ref exists both as a branch and a tag, torchhub now re-tries to download the repo, assuming it's a branch (just like
git).
I'm not adding test right now because the tests require access to Ailing's private repo. We should find a better way to do this. But meanwhile, the following testplan will be enough:
from pytest import skip
import torch
try:
torch.hub.load("pytorch/vision:v0.5.0", "resnet18", force_reload=True)
except ImportError as e:
# We're loading a super old torchvision version so the import error is expected.
# It's completely unrelated to the changes made to torchhub.
assert "cannot import name 'PY3' from 'torch._six'" in str(e)
pass
# We can also load tags and branches explicitly without issue:
torch.hub.load("pytorch/vision:refs/tags/v0.5.0", "resnet18", force_reload=True, skip_validation=True)
torch.hub.load("pytorch/vision:refs/heads/v0.5.0", "resnet18", force_reload=True, skip_validation=True)| def _parse_repo_info(github): | ||
| if ':' in github: | ||
| repo_info, branch = github.split(':') | ||
| repo_info, ref = github.split(':') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed (private) uses of the term "branch" into "ref", as this is more accurate. This is somewhat orthogonal to the relevant changes made in this PR, so I can revert if it makes the review difficult.
vmoens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for fixing this!
|
@NicolasHug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Hey @NicolasHug. |
Stack from ghstack (oldest at bottom):
Differential Revision: D35008926