-
Notifications
You must be signed in to change notification settings - Fork 245
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
NOMRG Added _restore_import_cache decorator to see what breaks #247
Conversation
❌ Deploy Preview for pytorch-hub-preview failed. 🔨 Explore the source changes: 6132d9d 🔍 Inspect the deploy log: https://app.netlify.com/sites/pytorch-hub-preview/deploys/61b87b99cd01630009af5756 |
def _restore_import_cache(func): | ||
# call func, and resore the sys.modules dict to what it was prior to the call | ||
# This avoids bugs like https://github.com/pytorch/hub/issues/243 | ||
def inner(*args, **kwargs): | ||
before = set(sys.modules.keys()) | ||
out = func(*args, **kwargs) | ||
after = set(sys.modules.keys()) | ||
for module in after - before: | ||
sys.modules.pop(module) | ||
|
||
return out | ||
|
||
return inner |
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.
This decorator and its use in help()
, list()
, and load()
is the only relevant chance of this PR. I need to copy-paste the entire file but the rest is unchanged.
Soooooo...... This works, but it doesn't. This is an attempt at fixing #243. I added a decorator to all torchhub functions to avoid import clashes. It almost works, but it makes all torchvision scripts fail (except the first one), all with this same error:
which is due to torchscript and in particular to these lines in the I'm not sure whether we could remove them in torchvision, but even if we could, there's a chance that other packages would use something similar, and we would break them. |
see below