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

feat/unused-topology-path-display #2171

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path ../.gitignore"
},
"dependencies": {
"@kestra-io/ui-libs": "^0.0.22",
"@kestra-io/ui-libs": "^0.0.23",
"@popperjs/core": "npm:@sxzz/[email protected]",
"@vue-flow/background": "^1.2.0",
"@vue-flow/controls": "1.0.6",
Expand Down
46 changes: 46 additions & 0 deletions ui/src/components/executions/Topology.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,35 @@
},
loadData(){
this.loadGraph();
},
isUnused: function (nodeByUid, nodeUid) {
let nodeToCheck = nodeByUid[nodeUid];

if(!nodeToCheck) {
return false;
}

if(!nodeToCheck.task) {
// check if parent is unused (current node is probably a cluster root or end)
const splitUid = nodeToCheck.uid.split(".");
splitUid.pop();
return this.isUnused(nodeByUid, splitUid.join("."));
}

if (!nodeToCheck.executionId) {
return true;
}

const nodeExecution = nodeToCheck.executionId === this.execution?.id ? this.execution
: Object.values(this.subflowsExecutions).filter(execution => execution.id === this.data.executionId)?.[0];

if (!nodeExecution) {
return true;
}

return !nodeExecution.taskRunList.some(taskRun => taskRun.taskId === nodeToCheck.task?.id);


},
loadGraph(force) {
if (this.execution && (force || (this.flowGraph === undefined || this.previousExecutionId !== this.execution.id))) {
Expand All @@ -89,8 +118,14 @@
?.filter(cluster => cluster.type.endsWith("SubflowGraphCluster"))
?.map(cluster => cluster.uid.replace(CLUSTER_PREFIX, ""))
?? [];
const nodeByUid = {};

this.flowGraph.nodes
// lowest depth first to be available in nodeByUid map for child-to-parent unused check
.sort((a, b) => a.uid.length - b.uid.length)
.forEach(node => {
nodeByUid[node.uid] = node;

const parentSubflow = subflowPaths.filter(subflowPath => node.uid.startsWith(subflowPath + "."))
.sort((a, b) => b.length - a.length)?.[0]

Expand All @@ -103,8 +138,19 @@
}

node.executionId = this.execution.id;

// reduce opacity for cluster root & end
if(!node.task && this.isUnused(nodeByUid, node.uid)) {
node.unused = true;
}
});

this.flowGraph.edges
// keep only unused (or skipped) paths
.filter(edge => {
return this.isUnused(nodeByUid, edge.target) || this.isUnused(nodeByUid, edge.source);
}).forEach(edge => edge.unused = true);

// force refresh
this.$store.commit("flow/setFlowGraph", Object.assign({}, this.flowGraph));
})
Expand Down