-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow passing TBPlugin/TBLoader subclasses to TensorBoardWSGIApp #2582
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
tensorboard/backend/application.py
Outdated
| """Returns a plugin loader for the given plugin. | ||
| Args: | ||
| plugin: A TBPlugin subclass, or a TBLoader instance or subclass. |
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.
Maybe call this plugin_spec, as above, as it need not be a plugin?
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.
Done.
tensorboard/backend/application.py
Outdated
| """ | ||
| if isinstance(plugin, base_plugin.TBLoader): | ||
| return plugin | ||
| if isinstance(plugin, type): |
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.
Just to make sure, this guard is just for readability, right?
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.
Without it you get an error for passing something that isn't a class to issubclass, actually.
tensorboard/program.py
Outdated
| :type plugins: list[Union[base_plugin.TBLoader, Type[base_plugin.TBPlugin]]] | ||
| :type plugins: list[Union[base_plugin.TBLoader, | ||
| Type[base_plugin.TBLoader], |
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.
nit: Can we try to not introduce brittle aligned-indents in favor of
hanging indents? Every time I run across one or two or three I cry
a little, and the far-right ones look awkward even when correctly
formatted.
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 just got rid of these :type lines, which was my original instinct since they're a pain to format legibly and we don't use them consistently or in an enforceable way.
This is a follow up to #2576 that makes the new
TensorBoardWSGIApp()entry point accept types besides TBLoader instances for itspluginsargument, namely it also accepts aTBPluginsubclass (which it will wrap in aBasicLoader) or aTBLoadersubclass (which it will instantiate with no arguments to get an instance).I moved the existing helper in
program.TensorBoard()intoapplication.pyfor this, which means that API also has gained the ability to take aTBLoaderclass (and a better error if passing in invalid types).Lastly, I've streamlined the plugin list in
default.pyto just use bareTBLoadersubclasses, which liberates 10 parentheses to be used for nobler purposes.