Skip to content

Commit 045ba1e

Browse files
authored
Add a declare to class fields which override a base class (#6908)
## Motivation for features / changes This is being done to support an internal migration cl/675299509
1 parent 9646de3 commit 045ba1e

File tree

1 file changed

+23
-30
lines changed
  • tensorboard/plugins/graph/tf_graph_common

1 file changed

+23
-30
lines changed

tensorboard/plugins/graph/tf_graph_common/render.ts

+23-30
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ limitations under the License.
1818
import * as d3 from 'd3';
1919
import {graphlib} from 'dagre';
2020
import * as _ from 'lodash';
21-
import * as tf_graph_common from './common';
22-
import * as tf_graph from './graph';
21+
import * as tfGraphCommon from './common';
22+
import * as tfGraph from './graph';
2323
import {
2424
BridgeNode,
2525
createGraph,
@@ -37,7 +37,7 @@ import {
3737
OpNodeImpl,
3838
} from './graph';
3939
import {Hierarchy} from './hierarchy';
40-
import * as tf_graph_util from './util';
40+
import * as tfGraphUtil from './util';
4141

4242
export type EdgeData = {
4343
v: string;
@@ -199,7 +199,7 @@ const PARAMS = {
199199
*/
200200
const nodeDisplayNameRegex = new RegExp(
201201
'^(?:' +
202-
tf_graph.FUNCTION_LIBRARY_NODE_PREFIX +
202+
tfGraph.FUNCTION_LIBRARY_NODE_PREFIX +
203203
')?(\\w+)_[a-z0-9]{8}(?:_\\d+)?$'
204204
);
205205
/**
@@ -301,14 +301,11 @@ export class RenderGraphInfo {
301301
.domain([0, maxComputeTime as unknown as number])
302302
.range(PARAMS.minMaxColors);
303303
this.edgeWidthSizedBasedScale = this.hierarchy.hasShapeInfo
304-
? tf_graph_common.EDGE_WIDTH_SIZE_BASED_SCALE
304+
? tfGraphCommon.EDGE_WIDTH_SIZE_BASED_SCALE
305305
: d3
306306
.scaleLinear()
307307
.domain([1, this.hierarchy.maxMetaEdgeSize])
308-
.range([
309-
tf_graph_common.MIN_EDGE_WIDTH,
310-
tf_graph_common.MAX_EDGE_WIDTH,
311-
]);
308+
.range([tfGraphCommon.MIN_EDGE_WIDTH, tfGraphCommon.MAX_EDGE_WIDTH]);
312309
}
313310
/**
314311
* Get a previously created RenderNodeInfo by its node name.
@@ -376,8 +373,7 @@ export class RenderGraphInfo {
376373
}
377374
// We only fade nodes when we're displaying stats.
378375
renderInfo.isFadedOut =
379-
this.displayingStats &&
380-
!tf_graph_util.hasDisplayableNodeStats(node.stats);
376+
this.displayingStats && !tfGraphUtil.hasDisplayableNodeStats(node.stats);
381377
var deviceHistogram: {} | null = null;
382378
var xlaClusterHistogram: {} | null = null;
383379
var opCompatibility: number | null = null;
@@ -628,7 +624,7 @@ export class RenderGraphInfo {
628624
newPrefix: string,
629625
functionOutputIndexToNode: {[key: string]: Node}
630626
): Metanode {
631-
const newMetanode = tf_graph.createMetanode(
627+
const newMetanode = tfGraph.createMetanode(
632628
libraryMetanode.name.replace(oldPrefix, newPrefix)
633629
);
634630
// Copy over various properties.
@@ -685,7 +681,7 @@ export class RenderGraphInfo {
685681
// This logic should never run because the meta graph should only
686682
// contain meta and op nodes.
687683
console.warn(
688-
node.name + ' is oddly neither a metanode nor an opnode.'
684+
`${node.name} is oddly neither a metanode nor an opnode.`
689685
);
690686
}
691687
});
@@ -873,7 +869,7 @@ export class RenderGraphInfo {
873869
// This node is not a function call.
874870
return;
875871
}
876-
if (childName.indexOf(tf_graph.FUNCTION_LIBRARY_NODE_PREFIX) === 0) {
872+
if (childName.indexOf(tfGraph.FUNCTION_LIBRARY_NODE_PREFIX) === 0) {
877873
// Do not replace library functions in the graph. The library
878874
// functions serve as templates for other nodes.
879875
return;
@@ -951,7 +947,7 @@ export class RenderGraphInfo {
951947
if (!_.isEmpty(this.hierarchy.libraryFunctions)) {
952948
this.buildSubhierarchiesForNeededFunctions(metagraph);
953949
}
954-
if (nodeName === tf_graph.ROOT_NAME) {
950+
if (nodeName === tfGraph.ROOT_NAME) {
955951
// Add all metanodes representing library function templates into the
956952
// library function scene group for the root node.
957953
_.forOwn(
@@ -1344,11 +1340,11 @@ export class RenderGraphInfo {
13441340
let metaedge = metagraph.edge(edgeObj);
13451341
let renderMetaedgeInfo = new RenderMetaedgeInfo(metaedge as any);
13461342
_.forEach(renderMetaedgeInfo.metaedge.baseEdgeList, (baseEdge) => {
1347-
const sourcePathList = baseEdge.v!.split(tf_graph.NAMESPACE_DELIM);
1343+
const sourcePathList = baseEdge.v!.split(tfGraph.NAMESPACE_DELIM);
13481344
for (let i = sourcePathList.length; i >= 0; i--) {
13491345
const fromBeginningPathList = sourcePathList.slice(0, i);
13501346
const node = this.hierarchy.node(
1351-
fromBeginningPathList.join(tf_graph.NAMESPACE_DELIM)
1347+
fromBeginningPathList.join(tfGraph.NAMESPACE_DELIM)
13521348
);
13531349
if (node) {
13541350
if (
@@ -1359,7 +1355,7 @@ export class RenderGraphInfo {
13591355
// Expand all hierarchies including the parent.
13601356
const currentNodeName = fromBeginningPathList
13611357
.slice(0, j)
1362-
.join(tf_graph.NAMESPACE_DELIM);
1358+
.join(tfGraph.NAMESPACE_DELIM);
13631359
if (!currentNodeName) {
13641360
continue;
13651361
}
@@ -1507,7 +1503,7 @@ export class AnnotationList {
15071503
ellipsisNode.setNumMoreNodes(++ellipsisNode.numMoreNodes);
15081504
return;
15091505
}
1510-
let ellipsisNode = new tf_graph.EllipsisNodeImpl(1);
1506+
let ellipsisNode = new tfGraph.EllipsisNodeImpl(1);
15111507
this.list.push(
15121508
new Annotation(
15131509
ellipsisNode,
@@ -1682,7 +1678,7 @@ export class RenderNodeInfo {
16821678
// Only use the portion beyond the last delimiter as the display
16831679
// name.
16841680
this.displayName = node.name.substring(
1685-
node.name.lastIndexOf(tf_graph.NAMESPACE_DELIM) + 1
1681+
node.name.lastIndexOf(tfGraph.NAMESPACE_DELIM) + 1
16861682
);
16871683
if (node.type === NodeType.META && (node as Metanode).associatedFunction) {
16881684
// Function names are suffixed with a length-8 hexadecimal string
@@ -1700,13 +1696,13 @@ export class RenderNodeInfo {
17001696
// common scenario.
17011697
this.displayName = match[1];
17021698
} else if (
1703-
_.startsWith(this.displayName, tf_graph.FUNCTION_LIBRARY_NODE_PREFIX)
1699+
_.startsWith(this.displayName, tfGraph.FUNCTION_LIBRARY_NODE_PREFIX)
17041700
) {
17051701
// The string does not match the usual pattern for how functions are
17061702
// named. Just use the entire second portion of the string as the name
17071703
// if we can successfully remove the prefix.
17081704
this.displayName = this.displayName.substring(
1709-
tf_graph.FUNCTION_LIBRARY_NODE_PREFIX.length
1705+
tfGraph.FUNCTION_LIBRARY_NODE_PREFIX.length
17101706
);
17111707
}
17121708
}
@@ -1750,7 +1746,7 @@ export class RenderMetaedgeInfo {
17501746
weight: number;
17511747
/**
17521748
* X and Y coordinate pairs of the points in the path of the edge.
1753-
* @see tf_graph.node.subsceneAdjustPaths
1749+
* @see tfGraph.node.subsceneAdjustPaths
17541750
*/
17551751
points: Point[];
17561752
/**
@@ -1822,7 +1818,7 @@ function setGraphDepth(graph: graphlib.Graph, depth: number) {
18221818
});
18231819
}
18241820
export class RenderGroupNodeInfo extends RenderNodeInfo {
1825-
override node: GroupNode;
1821+
declare node: GroupNode;
18261822
/**
18271823
* The core graph is derived from the underlying node's metagraph, minus
18281824
* the extracted source-like and sink-like nodes.
@@ -1851,10 +1847,7 @@ export class RenderGroupNodeInfo extends RenderNodeInfo {
18511847
isolatedOutExtract: RenderNodeInfo[];
18521848
/** Array of nodes to show in the function library scene group. */
18531849
libraryFunctionsExtract: RenderNodeInfo[];
1854-
constructor(
1855-
groupNode: GroupNode,
1856-
graphOptions: tf_graph.LabeledGraphOptions
1857-
) {
1850+
constructor(groupNode: GroupNode, graphOptions: tfGraph.LabeledGraphOptions) {
18581851
super(groupNode);
18591852
let metagraph = groupNode.metagraph;
18601853
let gl = metagraph.graph() as any;
@@ -1999,7 +1992,7 @@ function extractSpecifiedNodes(renderNode: RenderGroupNodeInfo) {
19991992
let renderInfo = graph.node(n);
20001993
if (
20011994
renderInfo.node.include === InclusionType.EXCLUDE &&
2002-
!n.startsWith(tf_graph.FUNCTION_LIBRARY_NODE_PREFIX)
1995+
!n.startsWith(tfGraph.FUNCTION_LIBRARY_NODE_PREFIX)
20031996
) {
20041997
// Move the node if the node is excluded and not part of the library
20051998
// function scene group, which contains nodes that do not represent ops in
@@ -2287,7 +2280,7 @@ export function expandUntilNodeIsShown(
22872280
let renderNode = renderHierarchy.getRenderNodeByName(nodeName);
22882281
for (let i = 1; i < splitTensorName.length; i++) {
22892282
// Op nodes are not expandable.
2290-
if (renderNode.node.type === tf_graph.NodeType.OP) {
2283+
if (renderNode.node.type === tfGraph.NodeType.OP) {
22912284
break;
22922285
}
22932286
renderHierarchy.buildSubhierarchy(nodeName);

0 commit comments

Comments
 (0)