Skip to content
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

graph: fix 'ungroup this series' button #4817

Merged
merged 2 commits into from
Mar 24, 2021

Conversation

psybuzz
Copy link
Contributor

@psybuzz psybuzz commented Mar 24, 2021

TensorBoard detects series of nodes (e.g. 'add_1', 'add_2', 'add_3', ...)
and visually collapses them into a single "series node". Currently, the
"ungroup this series" button in the right, floating info pane is broken.
Vestiges indicate that at one time, the button would modify the
HierarchyParams.seriesMap object, and rebuild a new Hierarchy
using the modified HierarchyParams.

This change properly wires up the handlers, but instead of modifying
the seriesMap in place, it creates a fresh new seriesMap and new
HierarchyParams for the new Hierarchy to use. This avoids a bug
where ungrouping a series then selecting a different graph to view
would cause the stale seriesMap from the previous graph to carry
over.

Fixes #4732

To test manually, feel free to check out this sample graph with a series:
https://github.com/tensorflow/tensorboard/files/6086986/series_graph.txt

Added a unit test and manually checked that the button now works.
image

@google-cla google-cla bot added the cla: yes label Mar 24, 2021
@psybuzz psybuzz marked this pull request as ready for review March 24, 2021 04:07
@psybuzz psybuzz requested a review from stephanwlee March 24, 2021 04:07
Comment on lines +135 to +138
const readonlySeriesMap = new Map([
['fooNode', tf_graph.SeriesGroupingType.UNGROUP],
['barNode', tf_graph.SeriesGroupingType.GROUP],
]);
Copy link
Contributor

Choose a reason for hiding this comment

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

idea: another way to have this test would be to Object.freeze it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting idea, although I don't know of any way to freeze a Map without writing a custom FrozenMap.

hierarchy: Hierarchy,
hierarchyParams: HierarchyParams
) {
export function getIncompatibleOps(hierarchy: Hierarchy) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would you mind specifying the return type? :D

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.

@@ -219,16 +217,12 @@ class TfGraphOpCompatCard extends LegacyElementMixin(PolymerElement) {
list.fire('iron-resize');
}
}
@computed('graphHierarchy', 'hierarchyParams')
@computed('graphHierarchy')
get _incompatibleOpNodes(): object {
Copy link
Contributor

Choose a reason for hiding this comment

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

if you type the getIncompatibleOps, you can better type the return types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done.

Comment on lines +905 to +906
hierarchy.getSeriesGroupType(seriesNode.name) ===
tf_graph.SeriesGroupingType.GROUP
Copy link
Contributor

Choose a reason for hiding this comment

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

Previous code reads !(seriesNode.name in map) and it makes me think that this code is basically checking to see if the hierarchy.getSeriesGroupType(seriesNode.name) has the default value in case it does not exist. I think it is more prudent to null to Map.prototype.has than matching against the default value defined in various places in this module.

Would it not read better if the hierarchy.getSeriesGroupType(seriesNode.name) were to return null?

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 would still prefer to hide the fact that the group types are stored implicitly, because it is a concern that is specific to Hierarchy internals. External consumers of the Hierarchy actually do not need to know what null values mean, so exposing only Group/Ungroup keeps consumers less complex and easier to reason about, imo.

While the previous code does check whether a node has been explicitly grouped/ungrouped, the new code matches the same intent (if a grouped series is too short, then ungroup it), and does not require readers to understand anything about the default group type.

I've updated the comment above on L900 accordingly.

@psybuzz psybuzz merged commit 28cae90 into tensorflow:master Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graph: "Ungroup this series of nodes" button is broken
2 participants