@bian-womp/spark-graph 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.cjs +30 -3
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/src/misc/base.d.ts.map +1 -1
- package/lib/cjs/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/cjs/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/lib/esm/index.js +30 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/src/misc/base.d.ts.map +1 -1
- package/lib/esm/src/runtime/GraphRuntime.d.ts.map +1 -1
- package/lib/esm/src/runtime/components/NodeExecutor.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/index.cjs
CHANGED
|
@@ -1560,9 +1560,20 @@ class NodeExecutor {
|
|
|
1560
1560
|
console.warn("NodeExecutor.execute: no runMode, skipping execution");
|
|
1561
1561
|
return;
|
|
1562
1562
|
}
|
|
1563
|
+
// In manual mode, require runContextIds unless autoRun policy is set
|
|
1563
1564
|
if (runMode === "manual" && (!runContextIds || runContextIds.size === 0)) {
|
|
1564
|
-
|
|
1565
|
-
|
|
1565
|
+
// If autoRun is true, auto-generate a run context (similar to createExecutionContext pattern)
|
|
1566
|
+
if (node.policy?.autoRun === true) {
|
|
1567
|
+
runContextIds = new Set([
|
|
1568
|
+
this.runContextManager.createRunContext(nodeId, () => { }, {
|
|
1569
|
+
propagate: false,
|
|
1570
|
+
}),
|
|
1571
|
+
]);
|
|
1572
|
+
}
|
|
1573
|
+
else {
|
|
1574
|
+
console.warn("NodeExecutor.execute: no runContextIds provided in manual mode, skipping execution");
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1566
1577
|
}
|
|
1567
1578
|
if (runMode === "auto" && runContextIds && runContextIds.size > 0) {
|
|
1568
1579
|
console.warn("NodeExecutor.execute: runContextIds provided in auto mode, ignoring");
|
|
@@ -2109,9 +2120,12 @@ class GraphRuntime {
|
|
|
2109
2120
|
}
|
|
2110
2121
|
}
|
|
2111
2122
|
// In auto mode, input updates can trigger execution; in manual mode they never should.
|
|
2123
|
+
// However, if autoRun policy is set, nodes run automatically even in manual mode.
|
|
2112
2124
|
if (anyChanged) {
|
|
2113
2125
|
this.handleResolver.scheduleRecomputeHandles(nodeId);
|
|
2114
|
-
|
|
2126
|
+
const node = this.graph.getNode(nodeId);
|
|
2127
|
+
const shouldAutoRun = this.runMode === "auto" || node?.policy?.autoRun === true;
|
|
2128
|
+
if (shouldAutoRun && this.graph.allInboundHaveValue(nodeId)) {
|
|
2115
2129
|
this.execute(nodeId);
|
|
2116
2130
|
}
|
|
2117
2131
|
}
|
|
@@ -2385,6 +2399,14 @@ class GraphRuntime {
|
|
|
2385
2399
|
}
|
|
2386
2400
|
else {
|
|
2387
2401
|
existing.params = n.params;
|
|
2402
|
+
// Re-merge policy when params change (params.policy can override descriptor/category policy)
|
|
2403
|
+
const desc = registry.nodes.get(existing.typeId);
|
|
2404
|
+
const cat = registry.categories.get(desc?.categoryId ?? "");
|
|
2405
|
+
existing.policy = {
|
|
2406
|
+
...cat?.policy,
|
|
2407
|
+
...desc?.policy,
|
|
2408
|
+
...n.params?.policy,
|
|
2409
|
+
};
|
|
2388
2410
|
if (!existing.stats) {
|
|
2389
2411
|
existing.stats = {
|
|
2390
2412
|
runs: 0,
|
|
@@ -3242,6 +3264,7 @@ function setupBasicGraphRegistry(id) {
|
|
|
3242
3264
|
categoryId: "compute",
|
|
3243
3265
|
inputs: { Value: "base.float" },
|
|
3244
3266
|
outputs: { Result: "base.float" },
|
|
3267
|
+
policy: { autoRun: true },
|
|
3245
3268
|
impl: (ins) => ({ Result: Number(ins.Value) }),
|
|
3246
3269
|
});
|
|
3247
3270
|
registry.registerNode({
|
|
@@ -3249,6 +3272,7 @@ function setupBasicGraphRegistry(id) {
|
|
|
3249
3272
|
categoryId: "compute",
|
|
3250
3273
|
inputs: { Value: "base.string" },
|
|
3251
3274
|
outputs: { Result: "base.string" },
|
|
3275
|
+
policy: { autoRun: true },
|
|
3252
3276
|
impl: (ins) => ({ Result: String(ins.Value) }),
|
|
3253
3277
|
});
|
|
3254
3278
|
registry.registerNode({
|
|
@@ -3256,6 +3280,7 @@ function setupBasicGraphRegistry(id) {
|
|
|
3256
3280
|
categoryId: "compute",
|
|
3257
3281
|
inputs: { Value: "base.bool" },
|
|
3258
3282
|
outputs: { Result: "base.bool" },
|
|
3283
|
+
policy: { autoRun: true },
|
|
3259
3284
|
impl: (ins) => ({ Result: Boolean(ins.Value) }),
|
|
3260
3285
|
});
|
|
3261
3286
|
registry.registerNode({
|
|
@@ -3263,6 +3288,7 @@ function setupBasicGraphRegistry(id) {
|
|
|
3263
3288
|
categoryId: "compute",
|
|
3264
3289
|
inputs: { Value: "base.object" },
|
|
3265
3290
|
outputs: { Result: "base.object" },
|
|
3291
|
+
policy: { autoRun: true },
|
|
3266
3292
|
impl: (ins) => ({ Result: ins.Value }),
|
|
3267
3293
|
});
|
|
3268
3294
|
registry.registerNode({
|
|
@@ -3270,6 +3296,7 @@ function setupBasicGraphRegistry(id) {
|
|
|
3270
3296
|
categoryId: "compute",
|
|
3271
3297
|
inputs: { Value: "base.vec3" },
|
|
3272
3298
|
outputs: { Result: "base.vec3" },
|
|
3299
|
+
policy: { autoRun: true },
|
|
3273
3300
|
impl: (ins) => ({ Result: ins.Value }),
|
|
3274
3301
|
});
|
|
3275
3302
|
// JSON parser node: base.stringToObject
|