@elaraai/e3-core 0.0.2-beta.3 → 0.0.2-beta.31
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/README.md +25 -22
- package/dist/src/dataflow/api-compat.d.ts +90 -0
- package/dist/src/dataflow/api-compat.d.ts.map +1 -0
- package/dist/src/dataflow/api-compat.js +134 -0
- package/dist/src/dataflow/api-compat.js.map +1 -0
- package/dist/src/dataflow/index.d.ts +18 -0
- package/dist/src/dataflow/index.d.ts.map +1 -0
- package/dist/src/dataflow/index.js +23 -0
- package/dist/src/dataflow/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts +53 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js +416 -0
- package/dist/src/dataflow/orchestrator/LocalOrchestrator.js.map +1 -0
- package/dist/src/dataflow/orchestrator/index.d.ts +12 -0
- package/dist/src/dataflow/orchestrator/index.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/index.js +12 -0
- package/dist/src/dataflow/orchestrator/index.js.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts +157 -0
- package/dist/src/dataflow/orchestrator/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/orchestrator/interfaces.js +51 -0
- package/dist/src/dataflow/orchestrator/interfaces.js.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts +67 -0
- package/dist/src/dataflow/state-store/FileStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/FileStateStore.js +286 -0
- package/dist/src/dataflow/state-store/FileStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts +42 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js +214 -0
- package/dist/src/dataflow/state-store/InMemoryStateStore.js.map +1 -0
- package/dist/src/dataflow/state-store/index.d.ts +13 -0
- package/dist/src/dataflow/state-store/index.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/index.js +13 -0
- package/dist/src/dataflow/state-store/index.js.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts +159 -0
- package/dist/src/dataflow/state-store/interfaces.d.ts.map +1 -0
- package/dist/src/dataflow/state-store/interfaces.js +6 -0
- package/dist/src/dataflow/state-store/interfaces.js.map +1 -0
- package/dist/src/dataflow/steps.d.ts +176 -0
- package/dist/src/dataflow/steps.d.ts.map +1 -0
- package/dist/src/dataflow/steps.js +528 -0
- package/dist/src/dataflow/steps.js.map +1 -0
- package/dist/src/dataflow/types.d.ts +116 -0
- package/dist/src/dataflow/types.d.ts.map +1 -0
- package/dist/src/dataflow/types.js +7 -0
- package/dist/src/dataflow/types.js.map +1 -0
- package/dist/src/dataflow.d.ts +142 -9
- package/dist/src/dataflow.d.ts.map +1 -1
- package/dist/src/dataflow.js +427 -64
- package/dist/src/dataflow.js.map +1 -1
- package/dist/src/errors.d.ts +39 -9
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +51 -8
- package/dist/src/errors.js.map +1 -1
- package/dist/src/execution/LocalTaskRunner.d.ts +73 -0
- package/dist/src/execution/LocalTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/LocalTaskRunner.js +399 -0
- package/dist/src/execution/LocalTaskRunner.js.map +1 -0
- package/dist/src/execution/MockTaskRunner.d.ts +49 -0
- package/dist/src/execution/MockTaskRunner.d.ts.map +1 -0
- package/dist/src/execution/MockTaskRunner.js +55 -0
- package/dist/src/execution/MockTaskRunner.js.map +1 -0
- package/dist/src/execution/index.d.ts +16 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +8 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/interfaces.d.ts +246 -0
- package/dist/src/execution/interfaces.d.ts.map +1 -0
- package/dist/src/execution/interfaces.js +6 -0
- package/dist/src/execution/interfaces.js.map +1 -0
- package/dist/src/execution/processHelpers.d.ts +20 -0
- package/dist/src/execution/processHelpers.d.ts.map +1 -0
- package/dist/src/execution/processHelpers.js +62 -0
- package/dist/src/execution/processHelpers.js.map +1 -0
- package/dist/src/executions.d.ts +71 -104
- package/dist/src/executions.d.ts.map +1 -1
- package/dist/src/executions.js +110 -476
- package/dist/src/executions.js.map +1 -1
- package/dist/src/index.d.ts +17 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +44 -18
- package/dist/src/index.js.map +1 -1
- package/dist/src/objects.d.ts +6 -53
- package/dist/src/objects.d.ts.map +1 -1
- package/dist/src/objects.js +11 -232
- package/dist/src/objects.js.map +1 -1
- package/dist/src/packages.d.ts +22 -14
- package/dist/src/packages.d.ts.map +1 -1
- package/dist/src/packages.js +116 -83
- package/dist/src/packages.js.map +1 -1
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts +35 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js +107 -0
- package/dist/src/storage/in-memory/InMemoryRepoStore.js.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts +114 -0
- package/dist/src/storage/in-memory/InMemoryStorage.d.ts.map +1 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js +349 -0
- package/dist/src/storage/in-memory/InMemoryStorage.js.map +1 -0
- package/dist/src/storage/in-memory/index.d.ts +12 -0
- package/dist/src/storage/in-memory/index.d.ts.map +1 -0
- package/dist/src/storage/in-memory/index.js +12 -0
- package/dist/src/storage/in-memory/index.js.map +1 -0
- package/dist/src/storage/index.d.ts +18 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +10 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +520 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +6 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/local/LocalBackend.d.ts +54 -0
- package/dist/src/storage/local/LocalBackend.d.ts.map +1 -0
- package/dist/src/storage/local/LocalBackend.js +141 -0
- package/dist/src/storage/local/LocalBackend.js.map +1 -0
- package/dist/src/storage/local/LocalLockService.d.ts +105 -0
- package/dist/src/storage/local/LocalLockService.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLockService.js +342 -0
- package/dist/src/storage/local/LocalLockService.js.map +1 -0
- package/dist/src/storage/local/LocalLogStore.d.ts +23 -0
- package/dist/src/storage/local/LocalLogStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalLogStore.js +66 -0
- package/dist/src/storage/local/LocalLogStore.js.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts +52 -0
- package/dist/src/storage/local/LocalObjectStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalObjectStore.js +287 -0
- package/dist/src/storage/local/LocalObjectStore.js.map +1 -0
- package/dist/src/storage/local/LocalRefStore.d.ts +50 -0
- package/dist/src/storage/local/LocalRefStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRefStore.js +337 -0
- package/dist/src/storage/local/LocalRefStore.js.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts +53 -0
- package/dist/src/storage/local/LocalRepoStore.d.ts.map +1 -0
- package/dist/src/storage/local/LocalRepoStore.js +353 -0
- package/dist/src/storage/local/LocalRepoStore.js.map +1 -0
- package/dist/src/storage/local/gc.d.ts +92 -0
- package/dist/src/storage/local/gc.d.ts.map +1 -0
- package/dist/src/storage/local/gc.js +322 -0
- package/dist/src/storage/local/gc.js.map +1 -0
- package/dist/src/storage/local/index.d.ts +17 -0
- package/dist/src/storage/local/index.d.ts.map +1 -0
- package/dist/src/storage/local/index.js +17 -0
- package/dist/src/storage/local/index.js.map +1 -0
- package/dist/src/storage/local/localHelpers.d.ts +25 -0
- package/dist/src/storage/local/localHelpers.d.ts.map +1 -0
- package/dist/src/storage/local/localHelpers.js +69 -0
- package/dist/src/storage/local/localHelpers.js.map +1 -0
- package/dist/src/{repository.d.ts → storage/local/repository.d.ts} +8 -4
- package/dist/src/storage/local/repository.d.ts.map +1 -0
- package/dist/src/{repository.js → storage/local/repository.js} +31 -29
- package/dist/src/storage/local/repository.js.map +1 -0
- package/dist/src/tasks.d.ts +16 -10
- package/dist/src/tasks.d.ts.map +1 -1
- package/dist/src/tasks.js +35 -41
- package/dist/src/tasks.js.map +1 -1
- package/dist/src/test-helpers.d.ts +4 -4
- package/dist/src/test-helpers.d.ts.map +1 -1
- package/dist/src/test-helpers.js +7 -21
- package/dist/src/test-helpers.js.map +1 -1
- package/dist/src/trees.d.ts +89 -27
- package/dist/src/trees.d.ts.map +1 -1
- package/dist/src/trees.js +218 -100
- package/dist/src/trees.js.map +1 -1
- package/dist/src/uuid.d.ts +26 -0
- package/dist/src/uuid.d.ts.map +1 -0
- package/dist/src/uuid.js +80 -0
- package/dist/src/uuid.js.map +1 -0
- package/dist/src/workspaceStatus.d.ts +6 -4
- package/dist/src/workspaceStatus.d.ts.map +1 -1
- package/dist/src/workspaceStatus.js +43 -49
- package/dist/src/workspaceStatus.js.map +1 -1
- package/dist/src/workspaces.d.ts +35 -26
- package/dist/src/workspaces.d.ts.map +1 -1
- package/dist/src/workspaces.js +169 -118
- package/dist/src/workspaces.js.map +1 -1
- package/package.json +4 -4
- package/dist/src/gc.d.ts +0 -54
- package/dist/src/gc.d.ts.map +0 -1
- package/dist/src/gc.js +0 -233
- package/dist/src/gc.js.map +0 -1
- package/dist/src/repository.d.ts.map +0 -1
- package/dist/src/repository.js.map +0 -1
- package/dist/src/workspaceLock.d.ts +0 -67
- package/dist/src/workspaceLock.d.ts.map +0 -1
- package/dist/src/workspaceLock.js +0 -217
- package/dist/src/workspaceLock.js.map +0 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Execution abstraction interfaces for e3 dataflow.
|
|
7
|
+
*
|
|
8
|
+
* These interfaces separate orchestration from business logic, enabling:
|
|
9
|
+
* - LocalDataflowExecutor: In-process execution with AsyncMutex (CLI, local dev)
|
|
10
|
+
* - StepFunctionsDataflowExecutor: AWS Step Functions orchestration (cloud)
|
|
11
|
+
*
|
|
12
|
+
* The core insight: Everything in dataflowExecute() except the processQueue()
|
|
13
|
+
* loop is pure business logic that both local and cloud execution share.
|
|
14
|
+
* By extracting these as functions and abstracting the orchestration,
|
|
15
|
+
* Step Functions can replace the local loop while reusing all e3-core logic.
|
|
16
|
+
*/
|
|
17
|
+
import type { StorageBackend, LockHandle } from '../storage/interfaces.js';
|
|
18
|
+
/**
|
|
19
|
+
* Options for task execution.
|
|
20
|
+
*/
|
|
21
|
+
export interface TaskExecuteOptions {
|
|
22
|
+
/** Force execution even if cached */
|
|
23
|
+
force?: boolean;
|
|
24
|
+
/** AbortSignal for cancellation */
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
/** Callback for stdout data */
|
|
27
|
+
onStdout?: (data: string) => void;
|
|
28
|
+
/** Callback for stderr data */
|
|
29
|
+
onStderr?: (data: string) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Result of a single task execution.
|
|
33
|
+
*/
|
|
34
|
+
export interface TaskResult {
|
|
35
|
+
/** Final state */
|
|
36
|
+
state: 'success' | 'failed' | 'error';
|
|
37
|
+
/** Whether the result was served from cache */
|
|
38
|
+
cached: boolean;
|
|
39
|
+
/** Execution ID (UUIDv7) */
|
|
40
|
+
executionId?: string;
|
|
41
|
+
/** Output hash (if state is 'success') */
|
|
42
|
+
outputHash?: string;
|
|
43
|
+
/** Exit code (if state is 'failed') */
|
|
44
|
+
exitCode?: number;
|
|
45
|
+
/** Error message (if state is 'error') */
|
|
46
|
+
error?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Task execution abstraction.
|
|
50
|
+
*
|
|
51
|
+
* Implementations:
|
|
52
|
+
* - LocalTaskRunner: Spawns east-node/east-py/julia processes locally
|
|
53
|
+
* - LambdaTaskRunner: Dispatches to AWS Lambda
|
|
54
|
+
* - FargateTaskRunner: Dispatches to AWS Fargate
|
|
55
|
+
*/
|
|
56
|
+
export interface TaskRunner {
|
|
57
|
+
/**
|
|
58
|
+
* Execute a task.
|
|
59
|
+
*
|
|
60
|
+
* @param storage - Storage backend
|
|
61
|
+
* @param taskHash - Hash of the TaskObject
|
|
62
|
+
* @param inputHashes - Hashes of input datasets
|
|
63
|
+
* @param options - Execution options
|
|
64
|
+
* @returns Task result
|
|
65
|
+
*/
|
|
66
|
+
execute(storage: StorageBackend, taskHash: string, inputHashes: string[], options?: TaskExecuteOptions): Promise<TaskResult>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle to a running dataflow execution.
|
|
70
|
+
*/
|
|
71
|
+
export interface ExecutionHandle {
|
|
72
|
+
/** Unique execution ID (Local: UUID, Cloud: Step Functions ARN) */
|
|
73
|
+
readonly id: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Status of a dataflow execution.
|
|
77
|
+
*/
|
|
78
|
+
export interface DataflowStatus {
|
|
79
|
+
/** Current state */
|
|
80
|
+
state: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
81
|
+
/** Tasks that have completed successfully */
|
|
82
|
+
completed: string[];
|
|
83
|
+
/** Tasks currently running */
|
|
84
|
+
running: string[];
|
|
85
|
+
/** Tasks waiting to run */
|
|
86
|
+
pending: string[];
|
|
87
|
+
/** Tasks that failed */
|
|
88
|
+
failed: string[];
|
|
89
|
+
/** Tasks skipped due to upstream failure */
|
|
90
|
+
skipped: string[];
|
|
91
|
+
/** Error message if state is 'failed' */
|
|
92
|
+
error?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Options for dataflow execution.
|
|
96
|
+
*/
|
|
97
|
+
export interface DataflowExecuteOptions {
|
|
98
|
+
/** Maximum concurrent task executions (default: 4) */
|
|
99
|
+
concurrency?: number;
|
|
100
|
+
/** Force re-execution even if cached (default: false) */
|
|
101
|
+
force?: boolean;
|
|
102
|
+
/** Filter to run only specific task(s) by exact name */
|
|
103
|
+
filter?: string;
|
|
104
|
+
/** AbortSignal for cancellation */
|
|
105
|
+
signal?: AbortSignal;
|
|
106
|
+
/** External lock handle (if caller manages locking) */
|
|
107
|
+
lock?: LockHandle;
|
|
108
|
+
/** Callback when a task starts */
|
|
109
|
+
onTaskStart?: (taskName: string) => void;
|
|
110
|
+
/** Callback when a task completes */
|
|
111
|
+
onTaskComplete?: (taskName: string, result: TaskResult) => void;
|
|
112
|
+
/** Callback for task stdout */
|
|
113
|
+
onStdout?: (taskName: string, data: string) => void;
|
|
114
|
+
/** Callback for task stderr */
|
|
115
|
+
onStderr?: (taskName: string, data: string) => void;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Result of a dataflow execution.
|
|
119
|
+
*/
|
|
120
|
+
export interface DataflowExecuteResult {
|
|
121
|
+
/** Overall success - true if all tasks completed successfully */
|
|
122
|
+
success: boolean;
|
|
123
|
+
/** Number of tasks executed (not from cache) */
|
|
124
|
+
executed: number;
|
|
125
|
+
/** Number of tasks served from cache */
|
|
126
|
+
cached: number;
|
|
127
|
+
/** Number of tasks that failed */
|
|
128
|
+
failed: number;
|
|
129
|
+
/** Number of tasks skipped due to upstream failure */
|
|
130
|
+
skipped: number;
|
|
131
|
+
/** Total duration in milliseconds */
|
|
132
|
+
duration: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Dataflow orchestration abstraction.
|
|
136
|
+
*
|
|
137
|
+
* Implementations:
|
|
138
|
+
* - LocalDataflowExecutor: In-process loop with AsyncMutex
|
|
139
|
+
* - StepFunctionsDataflowExecutor: AWS Step Functions state machine
|
|
140
|
+
*/
|
|
141
|
+
export interface DataflowExecutor {
|
|
142
|
+
/**
|
|
143
|
+
* Start a dataflow execution.
|
|
144
|
+
*
|
|
145
|
+
* Returns immediately with a handle. Use getStatus() to poll for completion.
|
|
146
|
+
*
|
|
147
|
+
* @param storage - Storage backend
|
|
148
|
+
* @param workspace - Workspace name
|
|
149
|
+
* @param options - Execution options
|
|
150
|
+
* @returns Execution handle
|
|
151
|
+
*/
|
|
152
|
+
start(storage: StorageBackend, workspace: string, options?: DataflowExecuteOptions): Promise<ExecutionHandle>;
|
|
153
|
+
/**
|
|
154
|
+
* Get the status of a dataflow execution.
|
|
155
|
+
*
|
|
156
|
+
* @param handle - Execution handle from start()
|
|
157
|
+
* @returns Current status
|
|
158
|
+
*/
|
|
159
|
+
getStatus(handle: ExecutionHandle): Promise<DataflowStatus>;
|
|
160
|
+
/**
|
|
161
|
+
* Cancel a running dataflow execution.
|
|
162
|
+
*
|
|
163
|
+
* Running tasks will be terminated. The execution will transition to
|
|
164
|
+
* 'cancelled' state.
|
|
165
|
+
*
|
|
166
|
+
* @param handle - Execution handle from start()
|
|
167
|
+
*/
|
|
168
|
+
cancel(handle: ExecutionHandle): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Wait for a dataflow execution to complete.
|
|
171
|
+
*
|
|
172
|
+
* @param handle - Execution handle from start()
|
|
173
|
+
* @returns Final result
|
|
174
|
+
*/
|
|
175
|
+
wait(handle: ExecutionHandle): Promise<DataflowExecuteResult>;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Task dependency graph.
|
|
179
|
+
*/
|
|
180
|
+
export interface TaskGraph {
|
|
181
|
+
/** Map of task name -> task info */
|
|
182
|
+
tasks: Map<string, {
|
|
183
|
+
hash: string;
|
|
184
|
+
inputPaths: string[];
|
|
185
|
+
outputPath: string;
|
|
186
|
+
dependencies: string[];
|
|
187
|
+
}>;
|
|
188
|
+
/** Map of output path -> producing task name */
|
|
189
|
+
outputToTask: Map<string, string>;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* These functions are the shared business logic that both local and cloud
|
|
193
|
+
* execution use. They are called by the orchestrator (LocalDataflowExecutor
|
|
194
|
+
* or Step Functions via Lambda handlers).
|
|
195
|
+
*
|
|
196
|
+
* Note: These are defined as function signatures here for documentation.
|
|
197
|
+
* The actual implementations are in dataflow.ts and will be exported
|
|
198
|
+
* as standalone functions.
|
|
199
|
+
*/
|
|
200
|
+
/**
|
|
201
|
+
* Get the task dependency graph for a workspace.
|
|
202
|
+
*
|
|
203
|
+
* Pure function - reads workspace state and package to build DAG.
|
|
204
|
+
*
|
|
205
|
+
* @param storage - Storage backend
|
|
206
|
+
* @param workspace - Workspace name
|
|
207
|
+
* @returns Task dependency graph
|
|
208
|
+
*/
|
|
209
|
+
export type DataflowGetGraphFn = (storage: StorageBackend, workspace: string) => Promise<TaskGraph>;
|
|
210
|
+
/**
|
|
211
|
+
* Check if a task's output is cached.
|
|
212
|
+
*
|
|
213
|
+
* Returns the cached output hash if available and valid.
|
|
214
|
+
*
|
|
215
|
+
* @param storage - Storage backend
|
|
216
|
+
* @param workspace - Workspace name
|
|
217
|
+
* @param taskHash - Task object hash
|
|
218
|
+
* @param inputHashes - Input dataset hashes
|
|
219
|
+
* @returns Cached output hash, or null if not cached or invalid
|
|
220
|
+
*/
|
|
221
|
+
export type DataflowCheckCacheFn = (storage: StorageBackend, workspace: string, taskHash: string, inputHashes: string[]) => Promise<string | null>;
|
|
222
|
+
/**
|
|
223
|
+
* Write task output to workspace tree.
|
|
224
|
+
*
|
|
225
|
+
* Called after successful task execution to update the workspace.
|
|
226
|
+
*
|
|
227
|
+
* @param storage - Storage backend
|
|
228
|
+
* @param workspace - Workspace name
|
|
229
|
+
* @param taskName - Task name
|
|
230
|
+
* @param outputPath - Output dataset path
|
|
231
|
+
* @param outputHash - Output object hash
|
|
232
|
+
*/
|
|
233
|
+
export type DataflowWriteOutputFn = (storage: StorageBackend, workspace: string, taskName: string, outputPath: string, outputHash: string) => Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Get tasks that are ready to execute.
|
|
236
|
+
*
|
|
237
|
+
* A task is ready when all its input dependencies have values assigned.
|
|
238
|
+
*
|
|
239
|
+
* @param storage - Storage backend
|
|
240
|
+
* @param workspace - Workspace name
|
|
241
|
+
* @param graph - Task dependency graph
|
|
242
|
+
* @param completed - Set of completed task names
|
|
243
|
+
* @returns Array of task names ready to execute
|
|
244
|
+
*/
|
|
245
|
+
export type DataflowGetReadyTasksFn = (storage: StorageBackend, workspace: string, graph: TaskGraph, completed: Set<string>) => Promise<string[]>;
|
|
246
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/execution/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAM3E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mCAAmC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kBAAkB;IAClB,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;IACtC,+CAA+C;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,KAAK,CAAC,EAA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E,MAAM,EAAE,CAAC;KACxB,CAAC,CAAC;IACH,gDAAgD;IAChD,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,SAAS,CAAC,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,KAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;;;;;;;;;GAUG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACpC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,KACnB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/execution/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get the current system boot ID.
|
|
7
|
+
* Used for detecting stale locks/processes after system reboot.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getBootId(): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Get process start time from /proc/<pid>/stat.
|
|
12
|
+
* Returns the starttime field (field 22) which is jiffies since boot.
|
|
13
|
+
* Used together with boot ID to uniquely identify a process (handles PID reuse).
|
|
14
|
+
*/
|
|
15
|
+
export declare function getPidStartTime(pid: number): Promise<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a process is still alive based on stored identification
|
|
18
|
+
*/
|
|
19
|
+
export declare function isProcessAlive(pid: number, pidStartTime: number, bootId: string): Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=processHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processHelpers.d.ts","sourceRoot":"","sources":["../../../src/execution/processHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;GAGG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAQjD;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAalE;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Process identification helpers for crash detection.
|
|
7
|
+
*
|
|
8
|
+
* These functions are used by LocalTaskRunner and LocalLockService
|
|
9
|
+
* to detect stale processes and locks after crashes or reboots.
|
|
10
|
+
*/
|
|
11
|
+
import * as fs from 'fs/promises';
|
|
12
|
+
/**
|
|
13
|
+
* Get the current system boot ID.
|
|
14
|
+
* Used for detecting stale locks/processes after system reboot.
|
|
15
|
+
*/
|
|
16
|
+
export async function getBootId() {
|
|
17
|
+
try {
|
|
18
|
+
const data = await fs.readFile('/proc/sys/kernel/random/boot_id', 'utf-8');
|
|
19
|
+
return data.trim();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// Not on Linux, use a placeholder
|
|
23
|
+
return 'unknown-boot-id';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get process start time from /proc/<pid>/stat.
|
|
28
|
+
* Returns the starttime field (field 22) which is jiffies since boot.
|
|
29
|
+
* Used together with boot ID to uniquely identify a process (handles PID reuse).
|
|
30
|
+
*/
|
|
31
|
+
export async function getPidStartTime(pid) {
|
|
32
|
+
try {
|
|
33
|
+
const data = await fs.readFile(`/proc/${pid}/stat`, 'utf-8');
|
|
34
|
+
// Fields are space-separated, but comm (field 2) can contain spaces and is in parens
|
|
35
|
+
// Find the closing paren, then split the rest
|
|
36
|
+
const closeParen = data.lastIndexOf(')');
|
|
37
|
+
const fields = data.slice(closeParen + 2).split(' ');
|
|
38
|
+
// After the closing paren, field index 0 is state (field 3), so starttime is at index 19
|
|
39
|
+
// (field 22 - 3 = 19)
|
|
40
|
+
return parseInt(fields[19], 10);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if a process is still alive based on stored identification
|
|
48
|
+
*/
|
|
49
|
+
export async function isProcessAlive(pid, pidStartTime, bootId) {
|
|
50
|
+
// Different boot? Process is dead
|
|
51
|
+
const currentBootId = await getBootId();
|
|
52
|
+
if (currentBootId !== bootId)
|
|
53
|
+
return false;
|
|
54
|
+
// Check if PID exists and has same start time
|
|
55
|
+
const currentStartTime = await getPidStartTime(pid);
|
|
56
|
+
if (currentStartTime === 0)
|
|
57
|
+
return false; // PID doesn't exist
|
|
58
|
+
if (currentStartTime !== pidStartTime)
|
|
59
|
+
return false; // PID reused
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=processHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processHelpers.js","sourceRoot":"","sources":["../../../src/execution/processHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS;IAC7B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,kCAAkC;QAClC,OAAO,iBAAiB,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,GAAG,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7D,qFAAqF;QACrF,8CAA8C;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrD,yFAAyF;QACzF,sBAAsB;QACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EACX,YAAoB,EACpB,MAAc;IAEd,kCAAkC;IAClC,MAAM,aAAa,GAAG,MAAM,SAAS,EAAE,CAAC;IACxC,IAAI,aAAa,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAE3C,8CAA8C;IAC9C,MAAM,gBAAgB,GAAG,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;IACpD,IAAI,gBAAgB,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,oBAAoB;IAC9D,IAAI,gBAAgB,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC,CAAC,aAAa;IAElE,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/src/executions.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
3
|
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { ExecutionStatus } from '@elaraai/e3-types';
|
|
6
|
+
import type { StorageBackend, LogChunk } from './storage/interfaces.js';
|
|
6
7
|
/**
|
|
7
8
|
* Compute the combined hash of input hashes.
|
|
8
9
|
*
|
|
@@ -14,51 +15,95 @@ import { type ExecutionStatus } from '@elaraai/e3-types';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare function inputsHash(inputHashes: string[]): string;
|
|
16
17
|
/**
|
|
17
|
-
* Get
|
|
18
|
+
* Get execution status for a specific execution.
|
|
18
19
|
*
|
|
19
|
-
* @param
|
|
20
|
+
* @param storage - Storage backend
|
|
21
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
20
22
|
* @param taskHash - Hash of the task object
|
|
21
23
|
* @param inHash - Combined hash of input hashes
|
|
22
|
-
* @
|
|
24
|
+
* @param executionId - Execution ID (UUIDv7)
|
|
25
|
+
* @returns ExecutionStatus or null if execution doesn't exist
|
|
26
|
+
* @throws {ExecutionCorruptError} If status file exists but cannot be decoded
|
|
23
27
|
*/
|
|
24
|
-
export declare function
|
|
28
|
+
export declare function executionGet(storage: StorageBackend, repo: string, taskHash: string, inHash: string, executionId: string): Promise<ExecutionStatus | null>;
|
|
25
29
|
/**
|
|
26
|
-
* Get execution status.
|
|
30
|
+
* Get the latest execution status (lexicographically greatest executionId).
|
|
27
31
|
*
|
|
28
|
-
* @param
|
|
32
|
+
* @param storage - Storage backend
|
|
33
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
29
34
|
* @param taskHash - Hash of the task object
|
|
30
35
|
* @param inHash - Combined hash of input hashes
|
|
31
|
-
* @returns ExecutionStatus or null if
|
|
32
|
-
|
|
36
|
+
* @returns ExecutionStatus or null if no executions exist
|
|
37
|
+
*/
|
|
38
|
+
export declare function executionGetLatest(storage: StorageBackend, repo: string, taskHash: string, inHash: string): Promise<ExecutionStatus | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the latest successful output hash for a completed execution.
|
|
41
|
+
* This is the primary cache lookup function.
|
|
42
|
+
*
|
|
43
|
+
* @param storage - Storage backend
|
|
44
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
45
|
+
* @param taskHash - Hash of the task object
|
|
46
|
+
* @param inHash - Combined hash of input hashes
|
|
47
|
+
* @returns Output hash or null if no successful execution exists
|
|
33
48
|
*/
|
|
34
|
-
export declare function
|
|
49
|
+
export declare function executionGetOutput(storage: StorageBackend, repo: string, taskHash: string, inHash: string): Promise<string | null>;
|
|
35
50
|
/**
|
|
36
|
-
*
|
|
51
|
+
* List all execution IDs for a (taskHash, inputsHash) pair.
|
|
37
52
|
*
|
|
38
|
-
* @param
|
|
53
|
+
* @param storage - Storage backend
|
|
54
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
39
55
|
* @param taskHash - Hash of the task object
|
|
40
56
|
* @param inHash - Combined hash of input hashes
|
|
41
|
-
* @returns
|
|
57
|
+
* @returns Array of execution IDs (sorted lexicographically ascending)
|
|
42
58
|
*/
|
|
43
|
-
export declare function
|
|
59
|
+
export declare function executionListIds(storage: StorageBackend, repo: string, taskHash: string, inHash: string): Promise<string[]>;
|
|
44
60
|
/**
|
|
45
61
|
* List all input hashes that have executions for a given task.
|
|
46
62
|
*
|
|
47
|
-
* @param
|
|
63
|
+
* @param storage - Storage backend
|
|
64
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
48
65
|
* @param taskHash - Hash of the task object
|
|
49
66
|
* @returns Array of input hashes
|
|
50
67
|
*/
|
|
51
|
-
export declare function executionListForTask(
|
|
68
|
+
export declare function executionListForTask(storage: StorageBackend, repo: string, taskHash: string): Promise<string[]>;
|
|
52
69
|
/**
|
|
53
70
|
* List all executions in the repository.
|
|
54
71
|
*
|
|
55
|
-
* @param
|
|
72
|
+
* @param storage - Storage backend
|
|
73
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
56
74
|
* @returns Array of { taskHash, inputsHash } objects
|
|
57
75
|
*/
|
|
58
|
-
export declare function executionList(
|
|
76
|
+
export declare function executionList(storage: StorageBackend, repo: string): Promise<Array<{
|
|
59
77
|
taskHash: string;
|
|
60
78
|
inputsHash: string;
|
|
61
79
|
}>>;
|
|
80
|
+
/**
|
|
81
|
+
* Result of finding the current execution for a task
|
|
82
|
+
*/
|
|
83
|
+
export interface CurrentExecutionRef {
|
|
84
|
+
/** Hash of the task object */
|
|
85
|
+
taskHash: string;
|
|
86
|
+
/** Combined hash of input hashes */
|
|
87
|
+
inputsHash: string;
|
|
88
|
+
/** Execution ID (UUIDv7) */
|
|
89
|
+
executionId: string;
|
|
90
|
+
/** True if this matches the current workspace input state */
|
|
91
|
+
isCurrent: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Find the execution reference for a task in a workspace.
|
|
95
|
+
*
|
|
96
|
+
* This looks up the task's current input hashes from the workspace state
|
|
97
|
+
* and finds the matching execution. If no execution exists for the current
|
|
98
|
+
* inputs, falls back to the most recent execution.
|
|
99
|
+
*
|
|
100
|
+
* @param storage - Storage backend
|
|
101
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
102
|
+
* @param ws - Workspace name
|
|
103
|
+
* @param taskName - Task name
|
|
104
|
+
* @returns Execution reference or null if no executions exist
|
|
105
|
+
*/
|
|
106
|
+
export declare function executionFindCurrent(storage: StorageBackend, repo: string, ws: string, taskName: string): Promise<CurrentExecutionRef | null>;
|
|
62
107
|
/**
|
|
63
108
|
* Options for reading execution logs
|
|
64
109
|
*/
|
|
@@ -68,109 +113,31 @@ export interface LogReadOptions {
|
|
|
68
113
|
/** Maximum bytes to read (default: 64KB) */
|
|
69
114
|
limit?: number;
|
|
70
115
|
}
|
|
71
|
-
|
|
72
|
-
* Result of reading a log chunk
|
|
73
|
-
*/
|
|
74
|
-
export interface LogChunk {
|
|
75
|
-
/** Log content (UTF-8) */
|
|
76
|
-
data: string;
|
|
77
|
-
/** Byte offset of this chunk */
|
|
78
|
-
offset: number;
|
|
79
|
-
/** Bytes in this chunk */
|
|
80
|
-
size: number;
|
|
81
|
-
/** Total log file size (for pagination) */
|
|
82
|
-
totalSize: number;
|
|
83
|
-
/** True if this is the end of the file */
|
|
84
|
-
complete: boolean;
|
|
85
|
-
}
|
|
116
|
+
export type { LogChunk };
|
|
86
117
|
/**
|
|
87
118
|
* Read execution logs with pagination support.
|
|
88
119
|
*
|
|
89
|
-
* @param
|
|
120
|
+
* @param storage - Storage backend
|
|
121
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
90
122
|
* @param taskHash - Hash of the task object
|
|
91
123
|
* @param inHash - Combined hash of input hashes
|
|
124
|
+
* @param executionId - Execution ID (UUIDv7)
|
|
92
125
|
* @param stream - Which log stream to read ('stdout' or 'stderr')
|
|
93
126
|
* @param options - Pagination options
|
|
94
127
|
* @returns Log chunk with data and metadata
|
|
95
128
|
*/
|
|
96
|
-
export declare function executionReadLog(
|
|
129
|
+
export declare function executionReadLog(storage: StorageBackend, repo: string, taskHash: string, inHash: string, executionId: string, stream: 'stdout' | 'stderr', options?: LogReadOptions): Promise<LogChunk>;
|
|
97
130
|
/**
|
|
98
131
|
* Evaluate command IR to get exec args.
|
|
99
132
|
*
|
|
100
133
|
* The IR is an East function: (inputs: Array<String>, output: String) -> Array<String>
|
|
101
134
|
*
|
|
102
|
-
* @param
|
|
135
|
+
* @param storage - Storage backend
|
|
136
|
+
* @param repo - Repository identifier (for local storage, the path to e3 repository directory)
|
|
103
137
|
* @param commandIrHash - Hash of the IR object
|
|
104
138
|
* @param inputPaths - Paths to staged input files
|
|
105
139
|
* @param outputPath - Path where output should be written
|
|
106
140
|
* @returns Array of strings to exec
|
|
107
141
|
*/
|
|
108
|
-
export declare function evaluateCommandIr(
|
|
109
|
-
/**
|
|
110
|
-
* Get the current system boot ID.
|
|
111
|
-
* Used for detecting stale locks/processes after system reboot.
|
|
112
|
-
*/
|
|
113
|
-
export declare function getBootId(): Promise<string>;
|
|
114
|
-
/**
|
|
115
|
-
* Get process start time from /proc/<pid>/stat.
|
|
116
|
-
* Returns the starttime field (field 22) which is jiffies since boot.
|
|
117
|
-
* Used together with boot ID to uniquely identify a process (handles PID reuse).
|
|
118
|
-
*/
|
|
119
|
-
export declare function getPidStartTime(pid: number): Promise<number>;
|
|
120
|
-
/**
|
|
121
|
-
* Check if a process is still alive based on stored identification
|
|
122
|
-
*/
|
|
123
|
-
export declare function isProcessAlive(pid: number, pidStartTime: number, bootId: string): Promise<boolean>;
|
|
124
|
-
/**
|
|
125
|
-
* Options for task execution
|
|
126
|
-
*/
|
|
127
|
-
export interface ExecuteOptions {
|
|
128
|
-
/** Re-run even if cached (default: false) */
|
|
129
|
-
force?: boolean;
|
|
130
|
-
/** Timeout in milliseconds (default: none) */
|
|
131
|
-
timeout?: number;
|
|
132
|
-
/** AbortSignal for cancellation */
|
|
133
|
-
signal?: AbortSignal;
|
|
134
|
-
/** Stream stdout callback */
|
|
135
|
-
onStdout?: (data: string) => void;
|
|
136
|
-
/** Stream stderr callback */
|
|
137
|
-
onStderr?: (data: string) => void;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Result of task execution
|
|
141
|
-
*/
|
|
142
|
-
export interface ExecutionResult {
|
|
143
|
-
/** Combined inputs hash (identifies this execution) */
|
|
144
|
-
inputsHash: string;
|
|
145
|
-
/** True if result was from cache */
|
|
146
|
-
cached: boolean;
|
|
147
|
-
/** Final state */
|
|
148
|
-
state: 'success' | 'failed' | 'error';
|
|
149
|
-
/** Output dataset hash (null on failure) */
|
|
150
|
-
outputHash: string | null;
|
|
151
|
-
/** Process exit code (null if not applicable) */
|
|
152
|
-
exitCode: number | null;
|
|
153
|
-
/** Execution time in ms (0 if cached) */
|
|
154
|
-
duration: number;
|
|
155
|
-
/** Error message on failure */
|
|
156
|
-
error: string | null;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Execute a single task.
|
|
160
|
-
*
|
|
161
|
-
* This is the core execution primitive. It:
|
|
162
|
-
* 1. Computes the execution identity from task + inputs
|
|
163
|
-
* 2. Checks cache (unless force=true)
|
|
164
|
-
* 3. Marshals inputs to a scratch directory
|
|
165
|
-
* 4. Evaluates command IR to get exec args
|
|
166
|
-
* 5. Runs the command
|
|
167
|
-
* 6. Stores the output and updates status
|
|
168
|
-
*
|
|
169
|
-
* @param repoPath - Path to .e3 repository
|
|
170
|
-
* @param taskHash - Hash of the task object
|
|
171
|
-
* @param inputHashes - Array of input dataset hashes
|
|
172
|
-
* @param options - Execution options
|
|
173
|
-
* @returns Execution result
|
|
174
|
-
*/
|
|
175
|
-
export declare function taskExecute(repoPath: string, taskHash: string, inputHashes: string[], options?: ExecuteOptions): Promise<ExecutionResult>;
|
|
142
|
+
export declare function evaluateCommandIr(storage: StorageBackend, repo: string, commandIrHash: string, inputPaths: string[], outputPath: string): Promise<string[]>;
|
|
176
143
|
//# sourceMappingURL=executions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executions.d.ts","sourceRoot":"","sources":["../../src/executions.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
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