From ee3ae4f56db1757ee7f9983b794c4361a26f4e89 Mon Sep 17 00:00:00 2001 From: Giannis Koumoutsos Date: Tue, 12 Sep 2023 18:12:32 +0200 Subject: [PATCH 1/4] initial examination --- src/edition/CustomNodes/GraphNode.tsx | 5 +++++ src/types.ts | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/edition/CustomNodes/GraphNode.tsx b/src/edition/CustomNodes/GraphNode.tsx index 58039adc5..5afc5671c 100644 --- a/src/edition/CustomNodes/GraphNode.tsx +++ b/src/edition/CustomNodes/GraphNode.tsx @@ -14,6 +14,7 @@ import NodeLabel from './NodeLabel'; import SuspenseBoundary from '../../suspense/SuspenseBoundary'; import NodeIcon from './NodeIcon'; import { DEFAULT_NODE_VALUES } from '../../utils/defaultValues'; +import useStore from '../../store/useStore'; function GraphNode(props: NodeProps) { const { getNodes, getEdges } = useReactFlow(); @@ -21,10 +22,14 @@ function GraphNode(props: NodeProps) { const { id } = props; const showWarningMsg = useSnackbarStore((state) => state.showWarningMsg); const nodeData = useNodeDataStore((state) => state.nodesData.get(id)); + const { loadedGraphs } = useStore.getState(); assertNodeDataDefined(nodeData, id); const { ui_props: uiProps } = nodeData; + const isOnServer = loadedGraphs.has(id); + // The id in the props seems to be the label.... + console.log(loadedGraphs, id, nodeData.ewoks_props.label, isOnServer); const isValidConnection = (connection: Connection) => { const { isValid, reason } = isValidLink( diff --git a/src/types.ts b/src/types.ts index a0f4fc5da..7903e87c4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -233,7 +233,6 @@ export interface EwoksNodeUiProps { task_icon?: string; task_category?: string; moreHandles?: boolean; - exists?: boolean; inputs?: outputsInputsSub[]; outputs?: outputsInputsSub[]; } -- GitLab From 5c2299a59e96e7b225f2ee05215ae2f913bbff4b Mon Sep 17 00:00:00 2001 From: "giannis.koumoutsos" Date: Wed, 13 Sep 2023 09:45:48 +0200 Subject: [PATCH 2/4] totally remove exists --- src/edition/CustomNodes/GraphNode.tsx | 2 +- src/edition/TaskDrawer/utils.ts | 3 +-- src/types.ts | 1 - src/utils/toRFEwoksNodesUtils.ts | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/edition/CustomNodes/GraphNode.tsx b/src/edition/CustomNodes/GraphNode.tsx index 5afc5671c..2ce807721 100644 --- a/src/edition/CustomNodes/GraphNode.tsx +++ b/src/edition/CustomNodes/GraphNode.tsx @@ -74,7 +74,7 @@ function GraphNode(props: NodeProps) { label={nodeData.ewoks_props.label || ''} showFull={withLabel} showCropped={!withLabel && !withImage} - color={uiProps.exists ? '#ced3ee' : 'red'} + color={isOnServer ? '#ced3ee' : 'red'} /> {withImage && ( diff --git a/src/edition/TaskDrawer/utils.ts b/src/edition/TaskDrawer/utils.ts index 99b8076d0..d0468262c 100644 --- a/src/edition/TaskDrawer/utils.ts +++ b/src/edition/TaskDrawer/utils.ts @@ -52,7 +52,7 @@ export async function loadSubworkflow( }; }); let id = 0; - let graphId = subGraph.graph.label || ''; + let graphId = subGraph.graph.id; while (nodes.some((nod) => nod.id === graphId)) { graphId += id++; } @@ -70,7 +70,6 @@ export async function loadSubworkflow( task_identifier: subGraph.graph.id, }, ui_props: { - exists: true, type: 'internal', ...(subGraph.graph.uiProps?.icon && { icon: subGraph.graph.uiProps.icon, diff --git a/src/types.ts b/src/types.ts index 7903e87c4..23abd5fe4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -266,7 +266,6 @@ export interface RFNodeUiProps { colorBorder?: string; nodeWidth?: number; moreHandles?: boolean; - exists?: boolean; // To position inputs-outputs of subgraphs in a graph inputs?: outputsInputsSub[]; outputs?: outputsInputsSub[]; diff --git a/src/utils/toRFEwoksNodesUtils.ts b/src/utils/toRFEwoksNodesUtils.ts index 1142d4f76..ad43822fe 100644 --- a/src/utils/toRFEwoksNodesUtils.ts +++ b/src/utils/toRFEwoksNodesUtils.ts @@ -139,7 +139,6 @@ export function addNodeProperties( ...tempNode.data, ui_props: { ...tempNode.data.ui_props, - exists: subgraphNode && !!subgraphNode.graph.id, inputs: inputsSub, outputs: outputsSub, }, -- GitLab From 8a4002541b53d318432624ab89fe2654fd16ac43 Mon Sep 17 00:00:00 2001 From: "giannis.koumoutsos" Date: Wed, 13 Sep 2023 14:06:06 +0200 Subject: [PATCH 3/4] tracing the loadGraphs creation --- src/edition/TaskDrawer/utils.ts | 4 +++- src/store/rootWorkflow.ts | 2 ++ src/utils.ts | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/edition/TaskDrawer/utils.ts b/src/edition/TaskDrawer/utils.ts index d0468262c..a72bbbfa5 100644 --- a/src/edition/TaskDrawer/utils.ts +++ b/src/edition/TaskDrawer/utils.ts @@ -52,7 +52,9 @@ export async function loadSubworkflow( }; }); let id = 0; - let graphId = subGraph.graph.id; + let graphId = subGraph.graph.label || ''; // + console.log(subGraph.graph.label, subGraph.graph.id); + while (nodes.some((nod) => nod.id === graphId)) { graphId += id++; } diff --git a/src/store/rootWorkflow.ts b/src/store/rootWorkflow.ts index 1735e599a..87e5d6a88 100644 --- a/src/store/rootWorkflow.ts +++ b/src/store/rootWorkflow.ts @@ -55,6 +55,8 @@ const rootWorkflow = ( // 3. Put the newNodeSubgraphs into loadedGraphs in their graphRF form (sync) newNodeSubgraphs.forEach((gr) => { + console.log(gr); + // calculate the rfNodes using the fetched subgraphs // nodes and edges stored with their data as EwoksRFNodes-Links get().addLoadedGraph({ diff --git a/src/utils.ts b/src/utils.ts index baa8100a7..316ce9ae2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,6 +37,7 @@ export async function getSubgraphs( (id) => id && !loadedGraphsIds.some((loadedGraphsId) => id === loadedGraphsId) ); + console.log(graphIdsToFetch); try { const subgraphResponses = await Promise.all( -- GitLab From 45ced180be5da4a61ab0b5311e1d28b7e23a5956 Mon Sep 17 00:00:00 2001 From: "giannis.koumoutsos" Date: Wed, 13 Sep 2023 14:58:44 +0200 Subject: [PATCH 4/4] use task_identifier to access the original graph --- src/edition/CustomNodes/GraphNode.tsx | 10 ++++++---- src/edition/TaskDrawer/utils.ts | 3 +-- src/store/rootWorkflow.ts | 2 -- src/utils.ts | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/edition/CustomNodes/GraphNode.tsx b/src/edition/CustomNodes/GraphNode.tsx index 2ce807721..e2ab925b6 100644 --- a/src/edition/CustomNodes/GraphNode.tsx +++ b/src/edition/CustomNodes/GraphNode.tsx @@ -27,9 +27,11 @@ function GraphNode(props: NodeProps) { assertNodeDataDefined(nodeData, id); const { ui_props: uiProps } = nodeData; - const isOnServer = loadedGraphs.has(id); - // The id in the props seems to be the label.... - console.log(loadedGraphs, id, nodeData.ewoks_props.label, isOnServer); + // DOC: the subgraph is connected to the original graph through the task_identifier like + // simple nodes and not through the id which is the unique in the current graph nodeId + const subgraphExistsOnServer = loadedGraphs.has( + nodeData.task_props.task_identifier + ); const isValidConnection = (connection: Connection) => { const { isValid, reason } = isValidLink( @@ -74,7 +76,7 @@ function GraphNode(props: NodeProps) { label={nodeData.ewoks_props.label || ''} showFull={withLabel} showCropped={!withLabel && !withImage} - color={isOnServer ? '#ced3ee' : 'red'} + color={subgraphExistsOnServer ? '#ced3ee' : 'red'} /> {withImage && ( diff --git a/src/edition/TaskDrawer/utils.ts b/src/edition/TaskDrawer/utils.ts index a72bbbfa5..541db470b 100644 --- a/src/edition/TaskDrawer/utils.ts +++ b/src/edition/TaskDrawer/utils.ts @@ -52,8 +52,7 @@ export async function loadSubworkflow( }; }); let id = 0; - let graphId = subGraph.graph.label || ''; // - console.log(subGraph.graph.label, subGraph.graph.id); + let graphId = subGraph.graph.label || ''; while (nodes.some((nod) => nod.id === graphId)) { graphId += id++; diff --git a/src/store/rootWorkflow.ts b/src/store/rootWorkflow.ts index 87e5d6a88..1735e599a 100644 --- a/src/store/rootWorkflow.ts +++ b/src/store/rootWorkflow.ts @@ -55,8 +55,6 @@ const rootWorkflow = ( // 3. Put the newNodeSubgraphs into loadedGraphs in their graphRF form (sync) newNodeSubgraphs.forEach((gr) => { - console.log(gr); - // calculate the rfNodes using the fetched subgraphs // nodes and edges stored with their data as EwoksRFNodes-Links get().addLoadedGraph({ diff --git a/src/utils.ts b/src/utils.ts index 316ce9ae2..baa8100a7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -37,7 +37,6 @@ export async function getSubgraphs( (id) => id && !loadedGraphsIds.some((loadedGraphsId) => id === loadedGraphsId) ); - console.log(graphIdsToFetch); try { const subgraphResponses = await Promise.all( -- GitLab