@workglow/task-graph 0.0.52
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 +201 -0
- package/README.md +1280 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2842 -0
- package/dist/browser.js.map +33 -0
- package/dist/bun.d.ts +7 -0
- package/dist/bun.d.ts.map +1 -0
- package/dist/bun.js +2843 -0
- package/dist/bun.js.map +33 -0
- package/dist/common.d.ts +33 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/node.d.ts +7 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2842 -0
- package/dist/node.js.map +33 -0
- package/dist/storage/TaskGraphRepository.d.ts +92 -0
- package/dist/storage/TaskGraphRepository.d.ts.map +1 -0
- package/dist/storage/TaskGraphTabularRepository.d.ts +73 -0
- package/dist/storage/TaskGraphTabularRepository.d.ts.map +1 -0
- package/dist/storage/TaskOutputRepository.d.ts +93 -0
- package/dist/storage/TaskOutputRepository.d.ts.map +1 -0
- package/dist/storage/TaskOutputTabularRepository.d.ts +84 -0
- package/dist/storage/TaskOutputTabularRepository.d.ts.map +1 -0
- package/dist/task/ArrayTask.d.ts +72 -0
- package/dist/task/ArrayTask.d.ts.map +1 -0
- package/dist/task/ConditionalTask.d.ts +278 -0
- package/dist/task/ConditionalTask.d.ts.map +1 -0
- package/dist/task/GraphAsTask.d.ts +79 -0
- package/dist/task/GraphAsTask.d.ts.map +1 -0
- package/dist/task/GraphAsTaskRunner.d.ts +36 -0
- package/dist/task/GraphAsTaskRunner.d.ts.map +1 -0
- package/dist/task/ITask.d.ts +144 -0
- package/dist/task/ITask.d.ts.map +1 -0
- package/dist/task/ITaskRunner.d.ts +36 -0
- package/dist/task/ITaskRunner.d.ts.map +1 -0
- package/dist/task/JobQueueFactory.d.ts +23 -0
- package/dist/task/JobQueueFactory.d.ts.map +1 -0
- package/dist/task/JobQueueTask.d.ts +65 -0
- package/dist/task/JobQueueTask.d.ts.map +1 -0
- package/dist/task/Task.d.ts +334 -0
- package/dist/task/Task.d.ts.map +1 -0
- package/dist/task/TaskError.d.ts +66 -0
- package/dist/task/TaskError.d.ts.map +1 -0
- package/dist/task/TaskEvents.d.ts +40 -0
- package/dist/task/TaskEvents.d.ts.map +1 -0
- package/dist/task/TaskJSON.d.ts +82 -0
- package/dist/task/TaskJSON.d.ts.map +1 -0
- package/dist/task/TaskQueueRegistry.d.ts +69 -0
- package/dist/task/TaskQueueRegistry.d.ts.map +1 -0
- package/dist/task/TaskRegistry.d.ts +31 -0
- package/dist/task/TaskRegistry.d.ts.map +1 -0
- package/dist/task/TaskRunner.d.ts +99 -0
- package/dist/task/TaskRunner.d.ts.map +1 -0
- package/dist/task/TaskTypes.d.ts +68 -0
- package/dist/task/TaskTypes.d.ts.map +1 -0
- package/dist/task-graph/Conversions.d.ts +28 -0
- package/dist/task-graph/Conversions.d.ts.map +1 -0
- package/dist/task-graph/Dataflow.d.ts +73 -0
- package/dist/task-graph/Dataflow.d.ts.map +1 -0
- package/dist/task-graph/DataflowEvents.d.ts +34 -0
- package/dist/task-graph/DataflowEvents.d.ts.map +1 -0
- package/dist/task-graph/ITaskGraph.d.ts +38 -0
- package/dist/task-graph/ITaskGraph.d.ts.map +1 -0
- package/dist/task-graph/IWorkflow.d.ts +13 -0
- package/dist/task-graph/IWorkflow.d.ts.map +1 -0
- package/dist/task-graph/TaskGraph.d.ts +230 -0
- package/dist/task-graph/TaskGraph.d.ts.map +1 -0
- package/dist/task-graph/TaskGraphEvents.d.ts +54 -0
- package/dist/task-graph/TaskGraphEvents.d.ts.map +1 -0
- package/dist/task-graph/TaskGraphRunner.d.ts +202 -0
- package/dist/task-graph/TaskGraphRunner.d.ts.map +1 -0
- package/dist/task-graph/TaskGraphScheduler.d.ts +56 -0
- package/dist/task-graph/TaskGraphScheduler.d.ts.map +1 -0
- package/dist/task-graph/Workflow.d.ts +155 -0
- package/dist/task-graph/Workflow.d.ts.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +59 -0
- package/src/storage/README.md +61 -0
- package/src/task/ConditionalTask.README.md +268 -0
- package/src/task/README.md +251 -0
- package/src/task-graph/README.md +142 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { DirectedAcyclicGraph, EventEmitter } from "@workglow/util";
|
|
7
|
+
import { TaskOutputRepository } from "../storage/TaskOutputRepository";
|
|
8
|
+
import type { ITask } from "../task/ITask";
|
|
9
|
+
import { JsonTaskItem, TaskGraphJson } from "../task/TaskJSON";
|
|
10
|
+
import type { Provenance, TaskIdType, TaskInput, TaskOutput } from "../task/TaskTypes";
|
|
11
|
+
import { type PipeFunction } from "./Conversions";
|
|
12
|
+
import { Dataflow, type DataflowIdType } from "./Dataflow";
|
|
13
|
+
import type { ITaskGraph } from "./ITaskGraph";
|
|
14
|
+
import { GraphEventDagEvents, GraphEventDagParameters, TaskGraphEventListener, TaskGraphEvents, TaskGraphEventStatusParameters, TaskGraphStatusEvents, TaskGraphStatusListeners } from "./TaskGraphEvents";
|
|
15
|
+
import { CompoundMergeStrategy, GraphResult, type GraphResultArray, TaskGraphRunner } from "./TaskGraphRunner";
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for running a task graph
|
|
18
|
+
*/
|
|
19
|
+
export interface TaskGraphRunConfig {
|
|
20
|
+
/** Optional output cache to use for this task graph */
|
|
21
|
+
outputCache?: TaskOutputRepository | boolean;
|
|
22
|
+
/** Optional signal to abort the task graph */
|
|
23
|
+
parentSignal?: AbortSignal;
|
|
24
|
+
/** Optional provenance to use for this task graph */
|
|
25
|
+
parentProvenance?: Provenance;
|
|
26
|
+
}
|
|
27
|
+
declare class TaskGraphDAG extends DirectedAcyclicGraph<ITask<any, any, any>, Dataflow, TaskIdType, DataflowIdType> {
|
|
28
|
+
constructor();
|
|
29
|
+
}
|
|
30
|
+
interface TaskGraphConstructorConfig {
|
|
31
|
+
outputCache?: TaskOutputRepository;
|
|
32
|
+
dag?: TaskGraphDAG;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents a task graph, a directed acyclic graph of tasks and data flows
|
|
36
|
+
*/
|
|
37
|
+
export declare class TaskGraph implements ITaskGraph {
|
|
38
|
+
/** Optional output cache to use for this task graph */
|
|
39
|
+
outputCache?: TaskOutputRepository;
|
|
40
|
+
/**
|
|
41
|
+
* Constructor for TaskGraph
|
|
42
|
+
* @param config Configuration for the task graph
|
|
43
|
+
*/
|
|
44
|
+
constructor({ outputCache, dag }?: TaskGraphConstructorConfig);
|
|
45
|
+
private _dag;
|
|
46
|
+
private _runner;
|
|
47
|
+
get runner(): TaskGraphRunner;
|
|
48
|
+
/**
|
|
49
|
+
* Runs the task graph
|
|
50
|
+
* @param config Configuration for the graph run
|
|
51
|
+
* @returns A promise that resolves when all tasks are complete
|
|
52
|
+
* @throws TaskError if any tasks have failed
|
|
53
|
+
*/
|
|
54
|
+
run<ExecuteOutput extends TaskOutput>(input?: TaskInput, config?: TaskGraphRunConfig): Promise<GraphResultArray<ExecuteOutput>>;
|
|
55
|
+
/**
|
|
56
|
+
* Runs the task graph reactively
|
|
57
|
+
* @returns A promise that resolves when all tasks are complete
|
|
58
|
+
* @throws TaskError if any tasks have failed
|
|
59
|
+
*/
|
|
60
|
+
runReactive<Output extends TaskOutput>(): Promise<GraphResultArray<Output>>;
|
|
61
|
+
/**
|
|
62
|
+
* Merges the execute output to the run output
|
|
63
|
+
* @param results The execute output
|
|
64
|
+
* @param compoundMerge The compound merge strategy to use
|
|
65
|
+
* @returns The run output
|
|
66
|
+
*/
|
|
67
|
+
mergeExecuteOutputsToRunOutput<ExecuteOutput extends TaskOutput, Merge extends CompoundMergeStrategy = CompoundMergeStrategy>(results: GraphResultArray<ExecuteOutput>, compoundMerge: Merge): GraphResult<ExecuteOutput, Merge>;
|
|
68
|
+
/**
|
|
69
|
+
* Aborts the task graph
|
|
70
|
+
*/
|
|
71
|
+
abort(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Disables the task graph
|
|
74
|
+
*/
|
|
75
|
+
disable(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves a task from the task graph by its id
|
|
78
|
+
* @param id The id of the task to retrieve
|
|
79
|
+
* @returns The task with the given id, or undefined if not found
|
|
80
|
+
*/
|
|
81
|
+
getTask(id: TaskIdType): ITask<any, any, any> | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves all tasks in the task graph
|
|
84
|
+
* @returns An array of tasks in the task graph
|
|
85
|
+
*/
|
|
86
|
+
getTasks(): ITask<any, any, any>[];
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves all tasks in the task graph topologically sorted
|
|
89
|
+
* @returns An array of tasks in the task graph topologically sorted
|
|
90
|
+
*/
|
|
91
|
+
topologicallySortedNodes(): ITask<any, any, any>[];
|
|
92
|
+
/**
|
|
93
|
+
* Adds a task to the task graph
|
|
94
|
+
* @param task The task to add
|
|
95
|
+
* @returns The current task graph
|
|
96
|
+
*/
|
|
97
|
+
addTask(fn: PipeFunction<any, any>, config?: any): unknown;
|
|
98
|
+
addTask(task: ITask<any, any, any>): unknown;
|
|
99
|
+
/**
|
|
100
|
+
* Adds multiple tasks to the task graph
|
|
101
|
+
* @param tasks The tasks to add
|
|
102
|
+
* @returns The current task graph
|
|
103
|
+
*/
|
|
104
|
+
addTasks(tasks: PipeFunction<any, any>[]): unknown[];
|
|
105
|
+
addTasks(tasks: ITask<any, any, any>[]): unknown[];
|
|
106
|
+
/**
|
|
107
|
+
* Adds a data flow to the task graph
|
|
108
|
+
* @param dataflow The data flow to add
|
|
109
|
+
* @returns The current task graph
|
|
110
|
+
*/
|
|
111
|
+
addDataflow(dataflow: Dataflow): `${string}[${string}] ==> ${string}[${string}]`;
|
|
112
|
+
/**
|
|
113
|
+
* Adds multiple data flows to the task graph
|
|
114
|
+
* @param dataflows The data flows to add
|
|
115
|
+
* @returns The current task graph
|
|
116
|
+
*/
|
|
117
|
+
addDataflows(dataflows: Dataflow[]): `${string}[${string}] ==> ${string}[${string}]`[];
|
|
118
|
+
/**
|
|
119
|
+
* Retrieves a data flow from the task graph by its id
|
|
120
|
+
* @param id The id of the data flow to retrieve
|
|
121
|
+
* @returns The data flow with the given id, or undefined if not found
|
|
122
|
+
*/
|
|
123
|
+
getDataflow(id: DataflowIdType): Dataflow | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves all data flows in the task graph
|
|
126
|
+
* @returns An array of data flows in the task graph
|
|
127
|
+
*/
|
|
128
|
+
getDataflows(): Dataflow[];
|
|
129
|
+
/**
|
|
130
|
+
* Removes a data flow from the task graph
|
|
131
|
+
* @param dataflow The data flow to remove
|
|
132
|
+
* @returns The current task graph
|
|
133
|
+
*/
|
|
134
|
+
removeDataflow(dataflow: Dataflow): void;
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves the data flows that are sources of a given task
|
|
137
|
+
* @param taskId The id of the task to retrieve sources for
|
|
138
|
+
* @returns An array of data flows that are sources of the given task
|
|
139
|
+
*/
|
|
140
|
+
getSourceDataflows(taskId: unknown): Dataflow[];
|
|
141
|
+
/**
|
|
142
|
+
* Retrieves the data flows that are targets of a given task
|
|
143
|
+
* @param taskId The id of the task to retrieve targets for
|
|
144
|
+
* @returns An array of data flows that are targets of the given task
|
|
145
|
+
*/
|
|
146
|
+
getTargetDataflows(taskId: unknown): Dataflow[];
|
|
147
|
+
/**
|
|
148
|
+
* Retrieves the tasks that are sources of a given task
|
|
149
|
+
* @param taskId The id of the task to retrieve sources for
|
|
150
|
+
* @returns An array of tasks that are sources of the given task
|
|
151
|
+
*/
|
|
152
|
+
getSourceTasks(taskId: unknown): ITask<any, any, any>[];
|
|
153
|
+
/**
|
|
154
|
+
* Retrieves the tasks that are targets of a given task
|
|
155
|
+
* @param taskId The id of the task to retrieve targets for
|
|
156
|
+
* @returns An array of tasks that are targets of the given task
|
|
157
|
+
*/
|
|
158
|
+
getTargetTasks(taskId: unknown): ITask<any, any, any>[];
|
|
159
|
+
/**
|
|
160
|
+
* Removes a task from the task graph
|
|
161
|
+
* @param taskId The id of the task to remove
|
|
162
|
+
* @returns The current task graph
|
|
163
|
+
*/
|
|
164
|
+
removeTask(taskId: unknown): void;
|
|
165
|
+
resetGraph(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Converts the task graph to a JSON format suitable for dependency tracking
|
|
168
|
+
* @returns An array of JsonTaskItem objects, each representing a task and its dependencies
|
|
169
|
+
*/
|
|
170
|
+
toJSON(): TaskGraphJson;
|
|
171
|
+
/**
|
|
172
|
+
* Converts the task graph to a JSON format suitable for dependency tracking
|
|
173
|
+
* @returns An array of JsonTaskItem objects, each representing a task and its dependencies
|
|
174
|
+
*/
|
|
175
|
+
toDependencyJSON(): JsonTaskItem[];
|
|
176
|
+
/**
|
|
177
|
+
* Event emitter for task lifecycle events
|
|
178
|
+
*/
|
|
179
|
+
get events(): EventEmitter<TaskGraphStatusListeners>;
|
|
180
|
+
protected _events: EventEmitter<TaskGraphStatusListeners> | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Subscribes to an event
|
|
183
|
+
* @param name - The event name to listen for
|
|
184
|
+
* @param fn - The callback function to execute when the event occurs
|
|
185
|
+
* @returns a function to unsubscribe from the event
|
|
186
|
+
*/
|
|
187
|
+
subscribe<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>): () => void;
|
|
188
|
+
/**
|
|
189
|
+
* Registers an event listener for the specified event
|
|
190
|
+
* @param name - The event name to listen for
|
|
191
|
+
* @param fn - The callback function to execute when the event occurs
|
|
192
|
+
*/
|
|
193
|
+
on<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>): void | EventEmitter<TaskGraphStatusListeners>;
|
|
194
|
+
/**
|
|
195
|
+
* Removes an event listener for the specified event
|
|
196
|
+
* @param name - The event name to listen for
|
|
197
|
+
* @param fn - The callback function to execute when the event occurs
|
|
198
|
+
*/
|
|
199
|
+
off<Event extends TaskGraphEvents>(name: Event, fn: TaskGraphEventListener<Event>): void | EventEmitter<TaskGraphStatusListeners>;
|
|
200
|
+
/**
|
|
201
|
+
* Emits an event for the specified event
|
|
202
|
+
* @param name - The event name to emit
|
|
203
|
+
* @param args - The arguments to pass to the event listener
|
|
204
|
+
*/
|
|
205
|
+
emit<E extends GraphEventDagEvents>(name: E, ...args: GraphEventDagParameters<E>): void;
|
|
206
|
+
emit<E extends TaskGraphStatusEvents>(name: E, ...args: TaskGraphEventStatusParameters<E>): void;
|
|
207
|
+
/**
|
|
208
|
+
* Emits an event for the specified event
|
|
209
|
+
* @param name - The event name to emit
|
|
210
|
+
* @param args - The arguments to pass to the event listener
|
|
211
|
+
*/
|
|
212
|
+
protected emit_local<Event extends TaskGraphStatusEvents>(name: Event, ...args: TaskGraphEventStatusParameters<Event>): void;
|
|
213
|
+
/**
|
|
214
|
+
* Emits an event for the specified event
|
|
215
|
+
* @param name - The event name to emit
|
|
216
|
+
* @param args - The arguments to pass to the event listener
|
|
217
|
+
*/
|
|
218
|
+
protected emit_dag<Event extends GraphEventDagEvents>(name: Event, ...args: GraphEventDagParameters<Event>): void;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Super simple helper if you know the input and output handles, and there is only one each
|
|
222
|
+
*
|
|
223
|
+
* @param tasks
|
|
224
|
+
* @param inputHandle
|
|
225
|
+
* @param outputHandle
|
|
226
|
+
* @returns
|
|
227
|
+
*/
|
|
228
|
+
export declare function serialGraph(tasks: ITask<any, any, any>[], inputHandle: string, outputHandle: string): TaskGraph;
|
|
229
|
+
export {};
|
|
230
|
+
//# sourceMappingURL=TaskGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGraph.d.ts","sourceRoot":"","sources":["../../src/task-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
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { EventParameters } from "@workglow/util";
|
|
7
|
+
import { ITask } from "../task/ITask";
|
|
8
|
+
import { Dataflow } from "./Dataflow";
|
|
9
|
+
/**
|
|
10
|
+
* Events that can be emitted by the TaskGraph
|
|
11
|
+
*/
|
|
12
|
+
export type TaskGraphStatusListeners = {
|
|
13
|
+
graph_progress: (progress: number, message?: string, ...args: any[]) => void;
|
|
14
|
+
start: () => void;
|
|
15
|
+
complete: () => void;
|
|
16
|
+
error: (error: Error) => void;
|
|
17
|
+
abort: () => void;
|
|
18
|
+
disabled: () => void;
|
|
19
|
+
};
|
|
20
|
+
export type TaskGraphStatusEvents = keyof TaskGraphStatusListeners;
|
|
21
|
+
export type TaskGraphStatusListener<Event extends TaskGraphStatusEvents> = TaskGraphStatusListeners[Event];
|
|
22
|
+
export type TaskGraphEventStatusParameters<Event extends TaskGraphStatusEvents> = EventParameters<TaskGraphStatusListeners, Event>;
|
|
23
|
+
export type GraphEventDagListeners = {
|
|
24
|
+
task_added: (task: ITask) => void;
|
|
25
|
+
task_removed: (task: ITask) => void;
|
|
26
|
+
task_replaced: (task: ITask) => void;
|
|
27
|
+
dataflow_added: (dataflow: Dataflow) => void;
|
|
28
|
+
dataflow_removed: (dataflow: Dataflow) => void;
|
|
29
|
+
dataflow_replaced: (dataflow: Dataflow) => void;
|
|
30
|
+
};
|
|
31
|
+
export type GraphEventDagEvents = keyof GraphEventDagListeners;
|
|
32
|
+
export type GraphEventDagListener<Event extends GraphEventDagEvents> = GraphEventDagListeners[Event];
|
|
33
|
+
export type GraphEventDagParameters<Event extends GraphEventDagEvents> = EventParameters<GraphEventDagListeners, Event>;
|
|
34
|
+
export type TaskGraphListeners = TaskGraphStatusListeners & GraphEventDagListeners;
|
|
35
|
+
export type TaskGraphEvents = keyof TaskGraphListeners;
|
|
36
|
+
export type TaskGraphEventListener<Event extends TaskGraphEvents> = TaskGraphListeners[Event];
|
|
37
|
+
export type TaskGraphEventParameters<Event extends TaskGraphEvents> = EventParameters<TaskGraphListeners, Event>;
|
|
38
|
+
export declare const EventDagToTaskGraphMapping: {
|
|
39
|
+
readonly "node-added": "task_added";
|
|
40
|
+
readonly "node-removed": "task_removed";
|
|
41
|
+
readonly "node-replaced": "task_replaced";
|
|
42
|
+
readonly "edge-added": "dataflow_added";
|
|
43
|
+
readonly "edge-removed": "dataflow_removed";
|
|
44
|
+
readonly "edge-replaced": "dataflow_replaced";
|
|
45
|
+
};
|
|
46
|
+
export declare const EventTaskGraphToDagMapping: {
|
|
47
|
+
readonly task_added: "node-added";
|
|
48
|
+
readonly task_removed: "node-removed";
|
|
49
|
+
readonly task_replaced: "node-replaced";
|
|
50
|
+
readonly dataflow_added: "edge-added";
|
|
51
|
+
readonly dataflow_removed: "edge-removed";
|
|
52
|
+
readonly dataflow_replaced: "edge-replaced";
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=TaskGraphEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGraphEvents.d.ts","sourceRoot":"","sources":["../../src/task-graph/TaskGraphEvents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AAEH,MAAM,MAAM,wBAAwB,GAAG;IACrC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC7E,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,MA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AAI,eAAe,CACnF,kBAAkB,EAClB,KAAK,CACN,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;CAO7B,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;;;CAO7B,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ConvertAllToOptionalArray } from "@workglow/util";
|
|
7
|
+
import { TaskOutputRepository } from "../storage/TaskOutputRepository";
|
|
8
|
+
import { ITask } from "../task/ITask";
|
|
9
|
+
import { TaskError } from "../task/TaskError";
|
|
10
|
+
import { Provenance, TaskInput, TaskOutput, TaskStatus } from "../task/TaskTypes";
|
|
11
|
+
import { TaskGraph, TaskGraphRunConfig } from "./TaskGraph";
|
|
12
|
+
import { DependencyBasedScheduler, TopologicalScheduler } from "./TaskGraphScheduler";
|
|
13
|
+
export type GraphSingleTaskResult<T> = {
|
|
14
|
+
id: unknown;
|
|
15
|
+
type: String;
|
|
16
|
+
data: T;
|
|
17
|
+
};
|
|
18
|
+
export type GraphResultArray<T> = Array<GraphSingleTaskResult<T>>;
|
|
19
|
+
export type PropertyArrayGraphResult<T> = ConvertAllToOptionalArray<T>;
|
|
20
|
+
export type AnyGraphResult<T> = PropertyArrayGraphResult<T> | GraphResultArray<T>;
|
|
21
|
+
export declare const PROPERTY_ARRAY: "PROPERTY_ARRAY";
|
|
22
|
+
export declare const GRAPH_RESULT_ARRAY: "GRAPH_RESULT_ARRAY";
|
|
23
|
+
export type GraphResultMap<T> = {
|
|
24
|
+
[GRAPH_RESULT_ARRAY]: GraphResultArray<T>;
|
|
25
|
+
[PROPERTY_ARRAY]: PropertyArrayGraphResult<T>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Enum representing the possible compound merge strategies
|
|
29
|
+
*/
|
|
30
|
+
export type CompoundMergeStrategy = typeof PROPERTY_ARRAY | typeof GRAPH_RESULT_ARRAY;
|
|
31
|
+
export type GraphResult<Output, Merge extends CompoundMergeStrategy> = GraphResultMap<Output>[Merge];
|
|
32
|
+
/**
|
|
33
|
+
* Class for running a task graph
|
|
34
|
+
* Manages the execution of tasks in a task graph, including provenance tracking and caching
|
|
35
|
+
*/
|
|
36
|
+
export declare class TaskGraphRunner {
|
|
37
|
+
protected processScheduler: DependencyBasedScheduler;
|
|
38
|
+
protected reactiveScheduler: TopologicalScheduler;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the task graph is currently running
|
|
41
|
+
*/
|
|
42
|
+
protected running: boolean;
|
|
43
|
+
protected reactiveRunning: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Map of provenance input for each task
|
|
46
|
+
*/
|
|
47
|
+
protected provenanceInput: Map<unknown, TaskInput>;
|
|
48
|
+
/**
|
|
49
|
+
* The task graph to run
|
|
50
|
+
*/
|
|
51
|
+
readonly graph: TaskGraph;
|
|
52
|
+
/**
|
|
53
|
+
* Output cache repository
|
|
54
|
+
*/
|
|
55
|
+
protected outputCache?: TaskOutputRepository;
|
|
56
|
+
/**
|
|
57
|
+
* AbortController for cancelling graph execution
|
|
58
|
+
*/
|
|
59
|
+
protected abortController: AbortController | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Maps to track task execution state
|
|
62
|
+
*/
|
|
63
|
+
protected inProgressTasks: Map<unknown, Promise<TaskOutput>>;
|
|
64
|
+
protected inProgressFunctions: Map<unknown, Promise<any>>;
|
|
65
|
+
protected failedTaskErrors: Map<unknown, TaskError>;
|
|
66
|
+
/**
|
|
67
|
+
* Constructor for TaskGraphRunner
|
|
68
|
+
* @param graph The task graph to run
|
|
69
|
+
* @param outputCache The task output repository to use for caching task outputs
|
|
70
|
+
* @param processScheduler The scheduler to use for task execution
|
|
71
|
+
* @param reactiveScheduler The scheduler to use for reactive task execution
|
|
72
|
+
*/
|
|
73
|
+
constructor(graph: TaskGraph, outputCache?: TaskOutputRepository, processScheduler?: DependencyBasedScheduler, reactiveScheduler?: TopologicalScheduler);
|
|
74
|
+
runGraph<ExecuteOutput extends TaskOutput>(input?: TaskInput, config?: TaskGraphRunConfig): Promise<GraphResultArray<ExecuteOutput>>;
|
|
75
|
+
/**
|
|
76
|
+
* Runs the task graph in a reactive manner
|
|
77
|
+
* @returns A promise that resolves when all tasks are complete
|
|
78
|
+
* @throws TaskConfigurationError if the graph is already running reactively
|
|
79
|
+
*/
|
|
80
|
+
runGraphReactive<Output extends TaskOutput>(): Promise<GraphResultArray<Output>>;
|
|
81
|
+
/**
|
|
82
|
+
* Aborts the task graph execution
|
|
83
|
+
*/
|
|
84
|
+
abort(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Disables the task graph execution
|
|
87
|
+
*/
|
|
88
|
+
disable(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Filters graph-level input to only include properties that are not connected via dataflows for a given task
|
|
91
|
+
* @param task The task to filter input for
|
|
92
|
+
* @param input The graph-level input
|
|
93
|
+
* @returns Filtered input containing only unconnected properties
|
|
94
|
+
*/
|
|
95
|
+
protected filterInputForTask(task: ITask, input: TaskInput): TaskInput;
|
|
96
|
+
/**
|
|
97
|
+
* Adds input data to a task.
|
|
98
|
+
* Delegates to {@link Task.addInput} for the actual merging logic.
|
|
99
|
+
*
|
|
100
|
+
* @param task The task to add input data to
|
|
101
|
+
* @param overrides The input data to override (or add to if an array)
|
|
102
|
+
*/
|
|
103
|
+
addInputData(task: ITask, overrides: Partial<TaskInput> | undefined): void;
|
|
104
|
+
mergeExecuteOutputsToRunOutput<ExecuteOutput extends TaskOutput, Merge extends CompoundMergeStrategy = CompoundMergeStrategy>(results: GraphResultArray<ExecuteOutput>, compoundMerge: Merge): GraphResult<ExecuteOutput, Merge>;
|
|
105
|
+
/**
|
|
106
|
+
* Copies input data from edges to a task
|
|
107
|
+
* @param task The task to copy input data to
|
|
108
|
+
*/
|
|
109
|
+
protected copyInputFromEdgesToNode(task: ITask): void;
|
|
110
|
+
/**
|
|
111
|
+
* Retrieves the provenance input for a task
|
|
112
|
+
* @param node The task to retrieve provenance input for
|
|
113
|
+
* @returns The provenance input for the task
|
|
114
|
+
*/
|
|
115
|
+
protected getInputProvenance(node: ITask): TaskInput;
|
|
116
|
+
/**
|
|
117
|
+
* Pushes the output of a task to its target tasks
|
|
118
|
+
* @param node The task that produced the output
|
|
119
|
+
* @param results The output of the task
|
|
120
|
+
* @param nodeProvenance The provenance input for the task
|
|
121
|
+
*/
|
|
122
|
+
protected pushOutputFromNodeToEdges(node: ITask, results: TaskOutput, nodeProvenance?: Provenance): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Pushes the status of a task to its target edges
|
|
125
|
+
* @param node The task that produced the status
|
|
126
|
+
*
|
|
127
|
+
* For ConditionalTask, this method handles selective dataflow status:
|
|
128
|
+
* - Active branch dataflows get COMPLETED status
|
|
129
|
+
* - Inactive branch dataflows get DISABLED status
|
|
130
|
+
*/
|
|
131
|
+
protected pushStatusFromNodeToEdges(graph: TaskGraph, node: ITask, status?: TaskStatus): void;
|
|
132
|
+
/**
|
|
133
|
+
* Pushes the error of a task to its target edges
|
|
134
|
+
* @param node The task that produced the error
|
|
135
|
+
*/
|
|
136
|
+
protected pushErrorFromNodeToEdges(graph: TaskGraph, node: ITask): void;
|
|
137
|
+
/**
|
|
138
|
+
* Propagates DISABLED status through the graph.
|
|
139
|
+
*
|
|
140
|
+
* When a task's ALL incoming dataflows are DISABLED, that task becomes unreachable
|
|
141
|
+
* and should also be disabled. This cascades through the graph until no more
|
|
142
|
+
* tasks can be disabled.
|
|
143
|
+
*
|
|
144
|
+
* This is used by ConditionalTask to disable downstream tasks on inactive branches.
|
|
145
|
+
*
|
|
146
|
+
* @param graph The task graph to propagate disabled status through
|
|
147
|
+
*/
|
|
148
|
+
protected propagateDisabledStatus(graph: TaskGraph): void;
|
|
149
|
+
/**
|
|
150
|
+
* Runs a task with provenance input
|
|
151
|
+
* @param task The task to run
|
|
152
|
+
* @param parentProvenance The provenance input for the task
|
|
153
|
+
* @returns The output of the task
|
|
154
|
+
*/
|
|
155
|
+
protected runTaskWithProvenance<T>(task: ITask, input: TaskInput, parentProvenance: Provenance): Promise<GraphSingleTaskResult<T>>;
|
|
156
|
+
/**
|
|
157
|
+
* Resets a task
|
|
158
|
+
* @param graph The task graph to reset
|
|
159
|
+
* @param task The task to reset
|
|
160
|
+
* @param runId The run ID
|
|
161
|
+
*/
|
|
162
|
+
protected resetTask(graph: TaskGraph, task: ITask, runId: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* Resets the task graph, recursively
|
|
165
|
+
* @param graph The task graph to reset
|
|
166
|
+
*/
|
|
167
|
+
resetGraph(graph: TaskGraph, runnerId: string): void;
|
|
168
|
+
/**
|
|
169
|
+
* Handles the start of task graph execution
|
|
170
|
+
* @param parentSignal Optional abort signal from parent
|
|
171
|
+
*/
|
|
172
|
+
protected handleStart(config?: TaskGraphRunConfig): Promise<void>;
|
|
173
|
+
protected handleStartReactive(): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Handles the completion of task graph execution
|
|
176
|
+
*/
|
|
177
|
+
protected handleComplete(): Promise<void>;
|
|
178
|
+
protected handleCompleteReactive(): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Handles errors during task graph execution
|
|
181
|
+
*/
|
|
182
|
+
protected handleError(error: TaskError): Promise<void>;
|
|
183
|
+
protected handleErrorReactive(): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Handles task graph abortion
|
|
186
|
+
*/
|
|
187
|
+
protected handleAbort(): Promise<void>;
|
|
188
|
+
protected handleAbortReactive(): Promise<void>;
|
|
189
|
+
/**
|
|
190
|
+
* Handles task graph disabling
|
|
191
|
+
*/
|
|
192
|
+
protected handleDisable(): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Handles progress updates for the task graph
|
|
195
|
+
* Currently not implemented at the graph level
|
|
196
|
+
* @param progress Progress value (0-100)
|
|
197
|
+
* @param message Optional message
|
|
198
|
+
* @param args Additional arguments
|
|
199
|
+
*/
|
|
200
|
+
protected handleProgress(task: ITask, progress: number, message?: string, ...args: any[]): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=TaskGraphRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGraphRunner.d.ts","sourceRoot":"","sources":["../../src/task-graph/TaskGraphRunner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,yBAAyB,EAG1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA0B,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE/F,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAA4C,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI;IACrC,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AACF,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,yBAAyB,CAAC,CAAC,CAAC,CAAC;AACvE,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAElF,eAAO,MAAM,cAAc,EAAG,gBAAyB,CAAC;AACxD,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
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { ITask } from "../task/ITask";
|
|
7
|
+
import { TaskGraph } from "./TaskGraph";
|
|
8
|
+
/**
|
|
9
|
+
* Interface for task graph schedulers
|
|
10
|
+
*/
|
|
11
|
+
export interface ITaskGraphScheduler {
|
|
12
|
+
/**
|
|
13
|
+
* Gets an async iterator of tasks that can be executed
|
|
14
|
+
* @returns AsyncIterator of tasks that resolves to each task when it's ready
|
|
15
|
+
*/
|
|
16
|
+
tasks(): AsyncIterableIterator<ITask>;
|
|
17
|
+
/**
|
|
18
|
+
* Notifies the scheduler that a task has completed
|
|
19
|
+
* @param taskId The ID of the completed task
|
|
20
|
+
*/
|
|
21
|
+
onTaskCompleted(taskId: unknown): void;
|
|
22
|
+
/**
|
|
23
|
+
* Resets the scheduler state
|
|
24
|
+
*/
|
|
25
|
+
reset(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sequential scheduler that executes one task at a time in topological order
|
|
29
|
+
* Useful for debugging and understanding task execution flow
|
|
30
|
+
*/
|
|
31
|
+
export declare class TopologicalScheduler implements ITaskGraphScheduler {
|
|
32
|
+
private dag;
|
|
33
|
+
private sortedNodes;
|
|
34
|
+
private currentIndex;
|
|
35
|
+
constructor(dag: TaskGraph);
|
|
36
|
+
tasks(): AsyncIterableIterator<ITask>;
|
|
37
|
+
onTaskCompleted(taskId: unknown): void;
|
|
38
|
+
reset(): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Event-driven scheduler that executes tasks as soon as their dependencies are satisfied
|
|
42
|
+
* Most efficient for parallel execution but requires completion notifications
|
|
43
|
+
*/
|
|
44
|
+
export declare class DependencyBasedScheduler implements ITaskGraphScheduler {
|
|
45
|
+
private dag;
|
|
46
|
+
private completedTasks;
|
|
47
|
+
private pendingTasks;
|
|
48
|
+
private nextResolver;
|
|
49
|
+
constructor(dag: TaskGraph);
|
|
50
|
+
private isTaskReady;
|
|
51
|
+
private waitForNextTask;
|
|
52
|
+
tasks(): AsyncIterableIterator<ITask>;
|
|
53
|
+
onTaskCompleted(taskId: unknown): void;
|
|
54
|
+
reset(): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=TaskGraphScheduler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TaskGraphScheduler.d.ts","sourceRoot":"","sources":["../../src/task-graph/TaskGraphScheduler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAEtC;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,mBAAmB;IAIlD,OAAO,CAAC,GAAG;IAHvB,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,YAAY,CAAS;gBAET,GAAG,EAAE,SAAS;IAM3B,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC;IAM5C,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAItC,KAAK,IAAI,IAAI;CAId;AAED;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,mBAAmB;IAKtD,OAAO,CAAC,GAAG;IAJvB,OAAO,CAAC,cAAc,CAAe;IACrC,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,YAAY,CAA+C;gBAE/C,GAAG,EAAE,SAAS;IAMlC,OAAO,CAAC,WAAW;YA4BL,eAAe;IA4BtB,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC;IAW5C,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IA2BtC,KAAK,IAAI,IAAI;CAKd"}
|