comfyui-node 1.4.3 → 1.4.4
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/LICENSE +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/call-wrapper.d.ts +124 -124
- package/dist/call-wrapper.js +1 -1
- package/dist/call-wrapper.js.map +1 -1
- package/dist/client.d.ts +290 -290
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pool/WorkflowPool.d.ts +80 -0
- package/dist/pool/WorkflowPool.d.ts.map +1 -1
- package/dist/pool/WorkflowPool.js +147 -2
- package/dist/pool/WorkflowPool.js.map +1 -1
- package/dist/pool/failover/SmartFailoverStrategy.js +1 -1
- package/dist/pool/failover/SmartFailoverStrategy.js.map +1 -1
- package/dist/pool/index.d.ts +1 -0
- package/dist/pool/index.d.ts.map +1 -1
- package/dist/pool/profiling/JobProfiler.d.ts +130 -0
- package/dist/pool/profiling/JobProfiler.d.ts.map +1 -0
- package/dist/pool/profiling/JobProfiler.js +225 -0
- package/dist/pool/profiling/JobProfiler.js.map +1 -0
- package/dist/pool/queue/QueueAdapter.d.ts +30 -30
- package/dist/pool/queue/adapters/memory.d.ts +20 -20
- package/dist/pool/types/job.d.ts +3 -0
- package/dist/pool/types/job.d.ts.map +1 -1
- package/dist/pool.d.ts +180 -180
- package/dist/workflow.js +1 -1
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/README.OLD.md +0 -1395
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Job Profiler - Automatic per-node execution profiling for WorkflowPool
|
|
3
|
+
* =======================================================================
|
|
4
|
+
*
|
|
5
|
+
* Captures detailed execution metrics for workflow jobs automatically:
|
|
6
|
+
* - Per-node execution timing
|
|
7
|
+
* - Progress tracking for nodes that emit progress events
|
|
8
|
+
* - Execution order and dependencies
|
|
9
|
+
* - Node types and metadata
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```ts
|
|
13
|
+
* const pool = new WorkflowPool(clients, { enableProfiling: true });
|
|
14
|
+
* const jobId = await pool.enqueue(workflow);
|
|
15
|
+
*
|
|
16
|
+
* pool.on('job:completed', (event) => {
|
|
17
|
+
* console.log(event.detail.job.profileStats);
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* JobProfiler tracks execution metrics for a single workflow job.
|
|
23
|
+
*/
|
|
24
|
+
export class JobProfiler {
|
|
25
|
+
queuedAt;
|
|
26
|
+
startedAt;
|
|
27
|
+
completedAt;
|
|
28
|
+
promptId;
|
|
29
|
+
nodeProfiles = new Map();
|
|
30
|
+
lastExecutingNode = null;
|
|
31
|
+
constructor(queuedAt, workflowJson) {
|
|
32
|
+
this.queuedAt = queuedAt;
|
|
33
|
+
// Initialize node profiles from workflow structure
|
|
34
|
+
if (workflowJson) {
|
|
35
|
+
for (const [nodeId, nodeData] of Object.entries(workflowJson)) {
|
|
36
|
+
const node = nodeData;
|
|
37
|
+
if (node && typeof node === 'object' && node.class_type) {
|
|
38
|
+
this.nodeProfiles.set(nodeId, {
|
|
39
|
+
nodeId,
|
|
40
|
+
type: node.class_type,
|
|
41
|
+
title: node._meta?.title,
|
|
42
|
+
cached: false,
|
|
43
|
+
status: 'pending'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Record execution start event
|
|
51
|
+
*/
|
|
52
|
+
onExecutionStart(promptId) {
|
|
53
|
+
this.promptId = promptId;
|
|
54
|
+
if (!this.startedAt) {
|
|
55
|
+
this.startedAt = Date.now();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Record cached nodes
|
|
60
|
+
*/
|
|
61
|
+
onCachedNodes(nodeIds) {
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
for (const nodeId of nodeIds) {
|
|
64
|
+
let profile = this.nodeProfiles.get(nodeId);
|
|
65
|
+
if (!profile) {
|
|
66
|
+
profile = {
|
|
67
|
+
nodeId,
|
|
68
|
+
cached: true,
|
|
69
|
+
status: 'cached'
|
|
70
|
+
};
|
|
71
|
+
this.nodeProfiles.set(nodeId, profile);
|
|
72
|
+
}
|
|
73
|
+
profile.cached = true;
|
|
74
|
+
profile.status = 'cached';
|
|
75
|
+
profile.startedAt = now;
|
|
76
|
+
profile.completedAt = now;
|
|
77
|
+
profile.duration = 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Record node execution start
|
|
82
|
+
*/
|
|
83
|
+
onNodeExecuting(nodeId) {
|
|
84
|
+
// Complete previous node if any
|
|
85
|
+
if (this.lastExecutingNode && this.lastExecutingNode !== nodeId) {
|
|
86
|
+
this.completeNode(this.lastExecutingNode);
|
|
87
|
+
}
|
|
88
|
+
// Start tracking new node
|
|
89
|
+
let profile = this.nodeProfiles.get(nodeId);
|
|
90
|
+
if (!profile) {
|
|
91
|
+
profile = {
|
|
92
|
+
nodeId,
|
|
93
|
+
cached: false,
|
|
94
|
+
status: 'executing'
|
|
95
|
+
};
|
|
96
|
+
this.nodeProfiles.set(nodeId, profile);
|
|
97
|
+
}
|
|
98
|
+
if (!profile.startedAt) {
|
|
99
|
+
profile.startedAt = Date.now();
|
|
100
|
+
profile.status = 'executing';
|
|
101
|
+
}
|
|
102
|
+
this.lastExecutingNode = nodeId;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Record node completion (when next node starts or execution ends)
|
|
106
|
+
*/
|
|
107
|
+
completeNode(nodeId) {
|
|
108
|
+
const profile = this.nodeProfiles.get(nodeId);
|
|
109
|
+
if (profile && !profile.completedAt && profile.startedAt) {
|
|
110
|
+
profile.completedAt = Date.now();
|
|
111
|
+
profile.duration = profile.completedAt - profile.startedAt;
|
|
112
|
+
profile.status = 'completed';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Record execution end (node: null event)
|
|
117
|
+
*/
|
|
118
|
+
onExecutionComplete() {
|
|
119
|
+
// Complete last executing node
|
|
120
|
+
if (this.lastExecutingNode) {
|
|
121
|
+
this.completeNode(this.lastExecutingNode);
|
|
122
|
+
this.lastExecutingNode = null;
|
|
123
|
+
}
|
|
124
|
+
// Mark any nodes still in "executing" state as completed
|
|
125
|
+
for (const profile of Array.from(this.nodeProfiles.values())) {
|
|
126
|
+
if (profile.status === 'executing' && !profile.completedAt && profile.startedAt) {
|
|
127
|
+
profile.completedAt = Date.now();
|
|
128
|
+
profile.duration = profile.completedAt - profile.startedAt;
|
|
129
|
+
profile.status = 'completed';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.completedAt = Date.now();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Record progress event for a node
|
|
136
|
+
*/
|
|
137
|
+
onProgress(progress) {
|
|
138
|
+
if (!progress.node)
|
|
139
|
+
return;
|
|
140
|
+
const nodeId = String(progress.node);
|
|
141
|
+
let profile = this.nodeProfiles.get(nodeId);
|
|
142
|
+
if (!profile) {
|
|
143
|
+
profile = {
|
|
144
|
+
nodeId,
|
|
145
|
+
cached: false,
|
|
146
|
+
status: 'executing',
|
|
147
|
+
progressEvents: []
|
|
148
|
+
};
|
|
149
|
+
this.nodeProfiles.set(nodeId, profile);
|
|
150
|
+
}
|
|
151
|
+
if (!profile.progressEvents) {
|
|
152
|
+
profile.progressEvents = [];
|
|
153
|
+
}
|
|
154
|
+
profile.progressEvents.push({
|
|
155
|
+
timestamp: Date.now(),
|
|
156
|
+
value: progress.value,
|
|
157
|
+
max: progress.max
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Record node execution error
|
|
162
|
+
*/
|
|
163
|
+
onNodeError(nodeId, error) {
|
|
164
|
+
let profile = this.nodeProfiles.get(nodeId);
|
|
165
|
+
if (!profile) {
|
|
166
|
+
profile = {
|
|
167
|
+
nodeId,
|
|
168
|
+
cached: false,
|
|
169
|
+
status: 'failed'
|
|
170
|
+
};
|
|
171
|
+
this.nodeProfiles.set(nodeId, profile);
|
|
172
|
+
}
|
|
173
|
+
profile.status = 'failed';
|
|
174
|
+
profile.error = error;
|
|
175
|
+
profile.completedAt = Date.now();
|
|
176
|
+
if (profile.startedAt) {
|
|
177
|
+
profile.duration = profile.completedAt - profile.startedAt;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Generate final profile statistics
|
|
182
|
+
*/
|
|
183
|
+
getStats() {
|
|
184
|
+
const now = Date.now();
|
|
185
|
+
const completedAt = this.completedAt || now;
|
|
186
|
+
const startedAt = this.startedAt || this.queuedAt;
|
|
187
|
+
const nodes = Array.from(this.nodeProfiles.values());
|
|
188
|
+
// Calculate summary statistics
|
|
189
|
+
const executedNodes = nodes.filter(n => n.status === 'completed').length;
|
|
190
|
+
const cachedNodes = nodes.filter(n => n.cached).length;
|
|
191
|
+
const failedNodes = nodes.filter(n => n.status === 'failed').length;
|
|
192
|
+
const slowestNodes = nodes
|
|
193
|
+
.filter(n => n.duration && n.duration > 0)
|
|
194
|
+
.sort((a, b) => (b.duration || 0) - (a.duration || 0))
|
|
195
|
+
.slice(0, 5)
|
|
196
|
+
.map(n => ({
|
|
197
|
+
nodeId: n.nodeId,
|
|
198
|
+
type: n.type,
|
|
199
|
+
title: n.title,
|
|
200
|
+
duration: n.duration
|
|
201
|
+
}));
|
|
202
|
+
const progressNodes = nodes
|
|
203
|
+
.filter(n => n.progressEvents && n.progressEvents.length > 0)
|
|
204
|
+
.map(n => n.nodeId);
|
|
205
|
+
return {
|
|
206
|
+
promptId: this.promptId,
|
|
207
|
+
totalDuration: completedAt - this.queuedAt,
|
|
208
|
+
queueTime: startedAt - this.queuedAt,
|
|
209
|
+
executionTime: completedAt - startedAt,
|
|
210
|
+
queuedAt: this.queuedAt,
|
|
211
|
+
startedAt: this.startedAt,
|
|
212
|
+
completedAt,
|
|
213
|
+
nodes,
|
|
214
|
+
summary: {
|
|
215
|
+
totalNodes: nodes.length,
|
|
216
|
+
executedNodes,
|
|
217
|
+
cachedNodes,
|
|
218
|
+
failedNodes,
|
|
219
|
+
slowestNodes,
|
|
220
|
+
progressNodes
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=JobProfiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobProfiler.js","sourceRoot":"","sources":["../../../src/pool/profiling/JobProfiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAsEH;;GAEG;AACH,MAAM,OAAO,WAAW;IACd,QAAQ,CAAS;IACjB,SAAS,CAAU;IACnB,WAAW,CAAU;IACrB,QAAQ,CAAU;IAClB,YAAY,GAAsC,IAAI,GAAG,EAAE,CAAC;IAC5D,iBAAiB,GAAkB,IAAI,CAAC;IAEhD,YAAY,QAAgB,EAAE,YAAkC;QAC9D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,mDAAmD;QACnD,IAAI,YAAY,EAAE,CAAC;YACjB,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC9D,MAAM,IAAI,GAAG,QAAe,CAAC;gBAC7B,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACxD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE;wBAC5B,MAAM;wBACN,IAAI,EAAE,IAAI,CAAC,UAAU;wBACrB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK;wBACxB,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE,SAAS;qBAClB,CAAC,CAAC;gBACL,CAAC;YACH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ting: number;
|
|
4
|
-
inFlight: number;
|
|
5
|
-
delayed: number;
|
|
6
|
-
failed: number;
|
|
7
|
-
}
|
|
8
|
-
export interface QueueReservation {
|
|
9
|
-
/** Unique reservation identifier (often equals the jobId for in-memory implementation). */
|
|
10
|
-
reservationId: string;
|
|
11
|
-
payload: WorkflowJobPayload;
|
|
12
|
-
attempt: number;
|
|
13
|
-
/** Optional timestamp when the item becomes visible again (for delayed retries). */
|
|
14
|
-
availableAt?: number;
|
|
15
|
-
}
|
|
16
|
-
export interface QueueAdapter {
|
|
17
|
-
enqueue(payload: WorkflowJobPayload, opts?: {
|
|
18
|
-
priority?: number;
|
|
19
|
-
delayMs?: number;
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
reserve(): Promise<QueueReservation | null>;
|
|
22
|
-
commit(reservationId: string): Promise<void>;
|
|
23
|
-
retry(reservationId: string, opts?: {
|
|
24
|
-
delayMs?: number;
|
|
25
|
-
}): Promise<void>;
|
|
26
|
-
discard(reservationId: string, reason?: unknown): Promise<void>;
|
|
27
|
-
remove(jobId: string): Promise<boolean>;
|
|
28
|
-
stats(): Promise<QueueStats>;
|
|
29
|
-
shutdown(): Promise<void>;
|
|
30
|
-
}
|
|
1
|
+
import type { WorkflowJobPayload } from "../types/job.js";
|
|
2
|
+
export interface QueueStats {
|
|
3
|
+
waiting: number;
|
|
4
|
+
inFlight: number;
|
|
5
|
+
delayed: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
}
|
|
8
|
+
export interface QueueReservation {
|
|
9
|
+
/** Unique reservation identifier (often equals the jobId for in-memory implementation). */
|
|
10
|
+
reservationId: string;
|
|
11
|
+
payload: WorkflowJobPayload;
|
|
12
|
+
attempt: number;
|
|
13
|
+
/** Optional timestamp when the item becomes visible again (for delayed retries). */
|
|
14
|
+
availableAt?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface QueueAdapter {
|
|
17
|
+
enqueue(payload: WorkflowJobPayload, opts?: {
|
|
18
|
+
priority?: number;
|
|
19
|
+
delayMs?: number;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
reserve(): Promise<QueueReservation | null>;
|
|
22
|
+
commit(reservationId: string): Promise<void>;
|
|
23
|
+
retry(reservationId: string, opts?: {
|
|
24
|
+
delayMs?: number;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
discard(reservationId: string, reason?: unknown): Promise<void>;
|
|
27
|
+
remove(jobId: string): Promise<boolean>;
|
|
28
|
+
stats(): Promise<QueueStats>;
|
|
29
|
+
shutdown(): Promise<void>;
|
|
30
|
+
}
|
|
31
31
|
//# sourceMappingURL=QueueAdapter.d.ts.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { QueueAdapter, QueueReservation, QueueStats } from "../QueueAdapter.js";
|
|
2
|
-
import type { WorkflowJobPayload } from "../../types/job.js";
|
|
3
|
-
export declare class MemoryQueueAdapter implements QueueAdapter {
|
|
4
|
-
private waiting;
|
|
5
|
-
private inFlight;
|
|
6
|
-
private failed;
|
|
7
|
-
enqueue(payload: WorkflowJobPayload, opts?: {
|
|
8
|
-
priority?: number;
|
|
9
|
-
delayMs?: number;
|
|
10
|
-
}): Promise<void>;
|
|
11
|
-
reserve(): Promise<QueueReservation | null>;
|
|
12
|
-
commit(reservationId: string): Promise<void>;
|
|
13
|
-
retry(reservationId: string, opts?: {
|
|
14
|
-
delayMs?: number;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
discard(reservationId: string, reason?: unknown): Promise<void>;
|
|
17
|
-
remove(jobId: string): Promise<boolean>;
|
|
18
|
-
stats(): Promise<QueueStats>;
|
|
19
|
-
shutdown(): Promise<void>;
|
|
20
|
-
}
|
|
1
|
+
import { QueueAdapter, QueueReservation, QueueStats } from "../QueueAdapter.js";
|
|
2
|
+
import type { WorkflowJobPayload } from "../../types/job.js";
|
|
3
|
+
export declare class MemoryQueueAdapter implements QueueAdapter {
|
|
4
|
+
private waiting;
|
|
5
|
+
private inFlight;
|
|
6
|
+
private failed;
|
|
7
|
+
enqueue(payload: WorkflowJobPayload, opts?: {
|
|
8
|
+
priority?: number;
|
|
9
|
+
delayMs?: number;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
reserve(): Promise<QueueReservation | null>;
|
|
12
|
+
commit(reservationId: string): Promise<void>;
|
|
13
|
+
retry(reservationId: string, opts?: {
|
|
14
|
+
delayMs?: number;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
discard(reservationId: string, reason?: unknown): Promise<void>;
|
|
17
|
+
remove(jobId: string): Promise<boolean>;
|
|
18
|
+
stats(): Promise<QueueStats>;
|
|
19
|
+
shutdown(): Promise<void>;
|
|
20
|
+
}
|
|
21
21
|
//# sourceMappingURL=memory.d.ts.map
|
package/dist/pool/types/job.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Workflow, WorkflowResult } from "../../workflow.js";
|
|
2
|
+
import type { JobProfileStats } from "../profiling/JobProfiler.js";
|
|
2
3
|
export type JobId = string;
|
|
3
4
|
export type WorkflowInput = Workflow | object | string | {
|
|
4
5
|
toJSON(): object;
|
|
@@ -52,5 +53,7 @@ export interface JobRecord extends WorkflowJobPayload {
|
|
|
52
53
|
result?: WorkflowResult | Record<string, unknown>;
|
|
53
54
|
startedAt?: number;
|
|
54
55
|
completedAt?: number;
|
|
56
|
+
/** Execution profiling stats (only present when profiling enabled) */
|
|
57
|
+
profileStats?: JobProfileStats;
|
|
55
58
|
}
|
|
56
59
|
//# sourceMappingURL=job.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../../src/pool/types/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../../src/pool/types/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,m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