-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
init: fix top-level module reloading #2005
Conversation
Summary: Fixes #1989 (also described in a new comment in `__init__.py`). This will require a Google-internal sync change, which I’ll link in shortly. Test Plan: Regression test added. It fails before this change in Python 2 and 3, and passes after this change in both as well. wchargin-branch: reload-tensorboard
wchargin-branch: reload-tensorboard
(Just for consistency with the rest of the module—we’re not so far down the rabbit hole that this is a functional change.) wchargin-branch: reload-tensorboard
wchargin-branch: reload-tensorboard
wchargin-branch: reload-tensorboard
wchargin-branch: reload-tensorboard
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.
FWIW, one other potential way to address this would be for the lazy loading logic itself to check if the named module already exists in sys.modules, and if it does exist, just return that module immediately. This would mean that after reloading, the modules would be pre-resolved rather than lazy, so it's different from the approach here, but also seems correct. Thoughts?
Presuming that you mean the argument to |
Fair enough. I think it is fair to require that the names passed to the decorator match the actual importable name of the decorated symbol, which is all that's really required for this to work (if there is no module in sys.modules, you fall back to the lazy function, regardless of whether there ever is such a module). But what you've done is fine too. |
Yep, understood. It only really breaks if you have a
This already doesn’t hold within Google, though. :-) |
Summary:
Fixes #1989 (also described in a new comment in
__init__.py
).This will require a Google-internal sync change: http://cl/238144308.
Test Plan:
Regression test added. It fails before this change in Python 2 and 3,
and passes after this change in both as well. The http://cl/238144308
test plan also passes.
wchargin-branch: reload-tensorboard