Skip to content

Commit ce6b17f

Browse files
authored
Try just removing prefix if no match (#623)
Previously, the graph explorer attempted to extract a label from a string to use as the display name for a node representing a function. Apparently, that regex does not always match a function. Certain graphs found within Google directly use the entire string as the name of the function. That caused the graph explorer to be blank due to an error. Now, the graph attempts to strip the prefix from the string and just use the second half as the display name if parsing the display name fails. This should be the less common case. Test Plan: Start TensorBoard pointed at the events file in the PR. The graph loads correctly as before. Also load the newly discovered internal pbtxt. It also loads successfully.
1 parent c2a8373 commit ce6b17f

File tree

1 file changed

+12
-1
lines changed
  • tensorboard/plugins/graph/tf_graph_common

1 file changed

+12
-1
lines changed

tensorboard/plugins/graph/tf_graph_common/render.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,18 @@ export class RenderNodeInfo {
15891589
// to see that in the graph, as the node would already be within
15901590
// the functions scene group.
15911591
const match = this.displayName.match(nodeDisplayNameRegex);
1592-
this.displayName = match[1];
1592+
if (match) {
1593+
// The display name had been successfully extracted. This is the most
1594+
// common scenario.
1595+
this.displayName = match[1];
1596+
} else if (_.startsWith(
1597+
this.displayName, tf.graph.FUNCTION_LIBRARY_NODE_PREFIX)) {
1598+
// The string does not match the usual pattern for how functions are
1599+
// named. Just use the entire second portion of the string as the name
1600+
// if we can successfully remove the prefix.
1601+
this.displayName = this.displayName.substring(
1602+
tf.graph.FUNCTION_LIBRARY_NODE_PREFIX.length);
1603+
}
15931604
}
15941605
}
15951606

0 commit comments

Comments
 (0)