Skip to content

Conversation

@nfelt
Copy link
Contributor

@nfelt nfelt commented Aug 20, 2019

This is a follow up to #2576 that makes the new TensorBoardWSGIApp() entry point accept types besides TBLoader instances for its plugins argument, namely it also accepts a TBPlugin subclass (which it will wrap in a BasicLoader) or a TBLoader subclass (which it will instantiate with no arguments to get an instance).

I moved the existing helper in program.TensorBoard() into application.py for this, which means that API also has gained the ability to take a TBLoader class (and a better error if passing in invalid types).

Lastly, I've streamlined the plugin list in default.py to just use bare TBLoader subclasses, which liberates 10 parentheses to be used for nobler purposes.

"""Returns a plugin loader for the given plugin.
Args:
plugin: A TBPlugin subclass, or a TBLoader instance or subclass.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

"""
if isinstance(plugin, base_plugin.TBLoader):
return plugin
if isinstance(plugin, type):
Copy link
Contributor

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?

Copy link
Contributor Author

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.

:type plugins: list[Union[base_plugin.TBLoader, Type[base_plugin.TBPlugin]]]
:type plugins: list[Union[base_plugin.TBLoader,
Type[base_plugin.TBLoader],
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@nfelt nfelt merged commit 0b2d793 into tensorflow:master Aug 21, 2019
@nfelt nfelt deleted the make-plugin-loader branch August 21, 2019 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants