-
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
Use registration pattern for dashboard tabs #611
Conversation
After thinking about this refactoring, I'm not sure of the benefits. I'm not adamantly opposed (more indifferent) - I just don't see the win here of moving where information is stored. Previously, plugin info (name, element, title) were stored in 1 place (a JSON list). To register a plugin, a developer would just add an entry (JSON object) to a list and import its dashboard. Now, that same info is stored across individual dashboards. Because polymer lacks interfaces, it's hard to document + enforce properties each dashboard must provide. And each dashboard has to call The previous system seems more systematic and understandable (and concise enough). |
To be clear, I think we want to at least prevent constructing all the dashboards if we're to go forward. At the same time, a stronger justification for what we get out of this refactoring would be nice. |
The advantage is that lines 38 through 55 in https://github.com/tensorflow/tensorboard-plugin-example/blob/b095516b8070fe3001d428f957990719560d869c/greeter_tensorboard/index.html can be deleted. This is preferable to needing to copy the big central |
Ah k. Despite being big, the Could we
|
I preserved the benefits of your previous change. We still have type checking and all that goodness. The only difference now is that the definitions themselves are localized (rather than centralized.)
|
Could we avoid placing the property on the dashboard component (which lacks type-checking)? Just add an argument to |
A few questions:
|
|
@chihuahua You're going to love love love what I just did. Not only did I take |
The plugin list no longer needs to be specified at all. The HTML imports themselves are now the plugin list. Special properties, e.g. custom tab names, are now defined as properties on the Polymer components themselves. The tradeoff is that each plugin's dashboard must call a registration function, providing the plugin name and the name of the custom element. See also: tensorflow#459
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 seems like something that works nicely. We have a Dashboard
type that specifies properties. Lets try it out both internally and with greeter plugin.
@nfelt, we indeed should update greeter plugin. I don't think we have a need to differentiate between plugins with the same name at the moment.
@@ -324,6 +326,10 @@ | |||
import {fetchRuns} from "../tf-backend/runsStore.js"; | |||
import * as paginatedViewStore from "../tf-paginated-view/paginatedViewStore.js"; | |||
|
|||
if (Object.keys(dashboardRegistry).length === 0) { |
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: Since we imported lodash, we could optionally use _.isEmpty(dashboardRegistry)
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
throw new Error(`Plugin already registered: ${dashboard.plugin}`); | ||
} | ||
if (!dashboard.tabName) { | ||
dashboard.tabName = capitalize(dashboard.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.
There's no need to capitalize in JS because we do so using CSS:
text-transform: uppercase; |
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.
That's true but I wasn't quite sure how comfortable I felt making assumptions about the CSS design here. Done.
The main subsequent challenge is to smoothly update other logic that had depended on our previous API for registering plugins. |
The plugin list no longer needs to be specified at all. The HTML imports
themselves are now the plugin list. Special properties, e.g. custom tab names,
are now defined as properties on the Polymer components themselves.
The tradeoff is that each plugin's dashboard must call a registration function,
providing the plugin name and the name of the custom element.
See also: #459