Skip to content

Commit

Permalink
Ignore subgraph ids that point to non-existent subgraphs. Show error …
Browse files Browse the repository at this point in the history
…message when trying to jump to the non-existent subgraph.

PiperOrigin-RevId: 713364842
  • Loading branch information
Google AI Edge authored and copybara-github committed Jan 8, 2025
1 parent 1f6ef06 commit efd140f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/ui/src/components/visualizer/app_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ export class AppService {
}
graph.subGraphIds.push(...node.subgraphIds);
for (const subgraphId of node.subgraphIds) {
graphById[subgraphId].parentGraphId = graph.id;
const subgraph = graphById[subgraphId];
if (subgraph) {
subgraph.parentGraphId = graph.id;
}
}
}
}
Expand All @@ -190,7 +193,9 @@ export class AppService {
if (root == null) {
graphs = rootGraphs;
} else {
graphs = (root.subGraphIds || []).map((id) => graphById[id]);
graphs = (root.subGraphIds || [])
.map((id) => graphById[id])
.filter((graphs) => graphs != null);
}
// Sort by node count.
graphs.sort((g1, g2) => g2.nodes.length - g1.nodes.length);
Expand Down
21 changes: 13 additions & 8 deletions src/ui/src/components/visualizer/webgl_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,14 @@ export class WebglRenderer implements OnInit, OnDestroy {
}

private async openSubgraph(subgraphId: string) {
const graph = this.appService.getGraphById(subgraphId);
if (!graph) {
const msg = `No graph found for subgraph id: "${subgraphId}"`;
console.warn(msg);
this.snackBar.open(msg, 'Dismiss');
return;
}

// Add breadcrumb.
this.appService.addSubgraphBreadcrumbItem(
this.paneId,
Expand All @@ -2829,14 +2837,11 @@ export class WebglRenderer implements OnInit, OnDestroy {
);

// Open the subgraph in current pane.
const graph = this.appService.getGraphById(subgraphId);
if (graph) {
this.appService.selectNode(this.paneId, undefined);
this.appService.setFlattenLayersInCurrentPane(false);
this.appService.curInitialUiState.set(undefined);
this.appService.curToLocateNodeInfo.set(undefined);
this.appService.selectGraphInCurrentPane(graph);
}
this.appService.selectNode(this.paneId, undefined);
this.appService.setFlattenLayersInCurrentPane(false);
this.appService.curInitialUiState.set(undefined);
this.appService.curToLocateNodeInfo.set(undefined);
this.appService.selectGraphInCurrentPane(graph);
}

private getGroupNodeLabelSeparatorId(
Expand Down

0 comments on commit efd140f

Please sign in to comment.