Skip to content

Commit 3a033e5

Browse files
committed
define behavior of graph based on caller
1 parent 32ef501 commit 3a033e5

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/components/molecules/flow/graph/Graph.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import setVarNode from './compute/setvarnode';
1111
import { LogLevel } from './GraphLogger';
1212

1313
class Graph {
14-
constructor(nodes, edges, startTime, initialEnvVars, logger) {
14+
constructor(nodes, edges, startTime, initialEnvVars, logger, caller) {
1515
this.nodes = nodes;
1616
this.edges = edges;
1717
this.logger = logger;
@@ -20,6 +20,7 @@ class Graph {
2020
this.graphRunNodeOutput = {};
2121
this.auth = undefined;
2222
this.envVariables = initialEnvVars;
23+
this.caller = caller;
2324
}
2425

2526
#checkTimeout() {
@@ -70,7 +71,9 @@ class Graph {
7071
if (node.type === 'outputNode') {
7172
//this.logs.push(`Output: ${JSON.stringify(prevNodeOutputData)}`);
7273
this.logger.add(LogLevel.INFO, '', { type: 'outputNode', data: prevNodeOutputData });
73-
useCanvasStore.getState().setOutputNode(node.id, prevNodeOutputData);
74+
if (this.caller === 'main') {
75+
useCanvasStore.getState().setOutputNode(node.id, prevNodeOutputData);
76+
}
7477
result = {
7578
status: 'Success',
7679
data: prevNodeOutputData,
@@ -141,6 +144,7 @@ class Graph {
141144
this.startTime,
142145
this.envVariables,
143146
this.logger,
147+
node.type,
144148
);
145149
result = await cNode.evaluate();
146150
this.envVariables = result.envVars;
@@ -208,11 +212,13 @@ class Graph {
208212

209213
async run() {
210214
// reset every output node for a fresh run
211-
this.nodes.forEach((node) => {
212-
if (node.type === 'outputNode') {
213-
useCanvasStore.getState().unSetOutputNode(node.id);
214-
}
215-
});
215+
if (this.caller === 'main') {
216+
this.nodes.forEach((node) => {
217+
if (node.type === 'outputNode') {
218+
useCanvasStore.getState().unSetOutputNode(node.id);
219+
}
220+
});
221+
}
216222
this.graphRunNodeOutput = {};
217223

218224
this.logger.add(LogLevel.INFO, 'Start Flowtest');

src/components/molecules/flow/graph/compute/complexnode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Graph1 from '../Graph';
22
import Node from './node';
33

44
class complexNode extends Node {
5-
constructor(nodes, edges, startTime, initialEnvVars, logger) {
5+
constructor(nodes, edges, startTime, initialEnvVars, logger, caller) {
66
super('complexNode');
7-
this.internalGraph = new Graph1(nodes, edges, startTime, initialEnvVars, logger);
7+
this.internalGraph = new Graph1(nodes, edges, startTime, initialEnvVars, logger, caller);
88
}
99

1010
async evaluate() {

src/components/molecules/flow/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ const Flow = ({ tab, collectionId }) => {
262262
startTime,
263263
envVariables,
264264
logger,
265+
'main',
265266
);
266267
const result = await g.run();
267268
logger.add(LogLevel.INFO, `Total time: ${Date.now() - startTime} ms`);

0 commit comments

Comments
 (0)