feat: implement debug node
All checks were successful
🚀 Lint & Test & Deploy / release (pull_request) Successful in 3m53s

Closes #39
This commit is contained in:
release-bot
2026-02-12 21:33:47 +01:00
parent 48cee58ad3
commit 15e08a8163
11 changed files with 234 additions and 111 deletions

View File

@@ -59,7 +59,7 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
private definitionMap: Map<string, NodeDefinition> = new Map();
private seed = Math.floor(Math.random() * 100000000);
private debugData: Record<string, Int32Array> = {};
private debugData: Record<number, { type: string; data: Int32Array }> = {};
perf?: PerformanceStore;
@@ -143,8 +143,8 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
for (const node of graphNodes) {
if (node.type.endsWith('/debug')) {
node.state = node.state || {};
node.state.depth = Math.min(...node.state.parents.map(s => s.state.depth), 1) - 1;
nodes.push(node);
const parent = node.state.parents[0];
parent.state.debugNode = true;
}
}
@@ -247,6 +247,12 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
log.log(`Using cached value for ${node_type.id || node.id}`);
this.perf?.addPoint('cache-hit', 1);
results[node.id] = cachedValue as Int32Array;
if (node.state.debugNode && node_type.outputs) {
this.debugData[node.id] = {
type: node_type.outputs[0],
data: cachedValue
};
}
continue;
}
this.perf?.addPoint('cache-hit', 0);
@@ -255,8 +261,11 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
log.log(`Inputs:`, inputs);
a = performance.now();
results[node.id] = node_type.execute(encoded_inputs);
if (node_type.id.endsWith('/debug')) {
this.debugData[node.id] = results[node.id];
if (node.state.debugNode && node_type.outputs) {
this.debugData[node.id] = {
type: node_type.outputs[0],
data: results[node.id]
};
}
log.log('Executed', node.type, node.id);
b = performance.now();

View File

@@ -5,6 +5,7 @@ type RuntimeState = {
parents: RuntimeNode[];
children: RuntimeNode[];
inputNodes: Record<string, RuntimeNode>;
debugNode?: boolean;
};
export type RuntimeNode = SerializedNode & { state: RuntimeState };

View File

@@ -6,12 +6,15 @@ export class WorkerRuntimeExecutor implements RuntimeExecutor {
new URL(`./worker-runtime-executor-backend.ts`, import.meta.url)
);
async execute(graph: Graph, settings: Record<string, unknown>) {
execute(graph: Graph, settings: Record<string, unknown>) {
return this.worker.executeGraph(graph, settings);
}
async getPerformanceData() {
getPerformanceData() {
return this.worker.getPerformanceData();
}
getDebugData() {
return this.worker.getDebugData();
}
set useRuntimeCache(useCache: boolean) {
this.worker.setUseRuntimeCache(useCache);
}