@elaraai/e3-api-server 1.0.103 → 1.0.105
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 +114 -9
- package/dist/src/call-limits.d.ts +72 -0
- package/dist/src/call-limits.d.ts.map +1 -0
- package/dist/src/call-limits.js +104 -0
- package/dist/src/call-limits.js.map +1 -0
- package/dist/src/call-limits.spec.d.ts +6 -0
- package/dist/src/call-limits.spec.d.ts.map +1 -0
- package/dist/src/call-limits.spec.js +264 -0
- package/dist/src/call-limits.spec.js.map +1 -0
- package/dist/src/cli.js +10 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/handlers/calls.d.ts +238 -0
- package/dist/src/handlers/calls.d.ts.map +1 -0
- package/dist/src/handlers/calls.js +383 -0
- package/dist/src/handlers/calls.js.map +1 -0
- package/dist/src/handlers/functions.d.ts +47 -14
- package/dist/src/handlers/functions.d.ts.map +1 -1
- package/dist/src/handlers/functions.js +159 -94
- package/dist/src/handlers/functions.js.map +1 -1
- package/dist/src/handlers/functions.spec.js +71 -14
- package/dist/src/handlers/functions.spec.js.map +1 -1
- package/dist/src/handlers/index.d.ts +2 -1
- package/dist/src/handlers/index.d.ts.map +1 -1
- package/dist/src/handlers/index.js +2 -1
- package/dist/src/handlers/index.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/portable.d.ts +2 -1
- package/dist/src/portable.d.ts.map +1 -1
- package/dist/src/portable.js +4 -1
- package/dist/src/portable.js.map +1 -1
- package/dist/src/portable.spec.js +1 -0
- package/dist/src/portable.spec.js.map +1 -1
- package/dist/src/routes/calls.d.ts +81 -0
- package/dist/src/routes/calls.d.ts.map +1 -0
- package/dist/src/routes/calls.js +141 -0
- package/dist/src/routes/calls.js.map +1 -0
- package/dist/src/routes/functions.d.ts +97 -25
- package/dist/src/routes/functions.d.ts.map +1 -1
- package/dist/src/routes/functions.js +147 -30
- package/dist/src/routes/functions.js.map +1 -1
- package/dist/src/routes/index.d.ts +2 -1
- package/dist/src/routes/index.d.ts.map +1 -1
- package/dist/src/routes/index.js +2 -1
- package/dist/src/routes/index.js.map +1 -1
- package/dist/src/server.d.ts +15 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +43 -10
- package/dist/src/server.js.map +1 -1
- package/dist/src/types.d.ts +295 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +13 -2
- package/dist/src/types.js.map +1 -1
- package/package.json +7 -6
|
@@ -5,20 +5,22 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Handlers for named package functions.
|
|
7
7
|
*
|
|
8
|
-
* A call
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* A call through a package — the package route's, with no workspace — reduces
|
|
9
|
+
* to the graph-free `runDetached` primitive: the caller's values → run a body
|
|
10
|
+
* IR on a runner → return the result inline. Nothing durable is written — no
|
|
11
|
+
* output object, no execution record, no logs, no dataset ref. A call through
|
|
12
|
+
* a workspace is kept instead, as the calls handlers file and run it
|
|
13
|
+
* (`handlers/calls.ts`).
|
|
13
14
|
* Named functions are author-published IR (same trust as a deployed task),
|
|
14
15
|
* which any caller the route admits runs on the function's own runner; a
|
|
15
|
-
* runner the caller names instead is held to its grant (
|
|
16
|
+
* runner the caller names instead is held to its grant (e3-core's
|
|
17
|
+
* `functionRunnerRefusal`).
|
|
16
18
|
* One-shot, whose IR is the caller's, runs through e3-core's `oneShotExecute`
|
|
17
19
|
* under the grant the host gives the caller (routes/functions.ts), and so does
|
|
18
20
|
* a split call's launch, which runs as a job the client polls.
|
|
19
21
|
*/
|
|
20
22
|
import { ArrayType, none, some, variant } from '@elaraai/east';
|
|
21
|
-
import { packageRead, PermissionDeniedError, TaskNotFoundError, detachedToExecuteResult, invalidExecuteResult, pinCallArguments, resolveExecuteLimits, resolveJobLimits, splitCallInvalid, splitCallPlatformFree, splitCallPrepare, splitCallResult, } from '@elaraai/e3-core/portable';
|
|
23
|
+
import { packageRead, PermissionDeniedError, TaskNotFoundError, detachedToExecuteResult, functionRunnerRefusal, invalidExecuteResult, pinCallArguments, resolveExecuteLimits, resolveJobLimits, splitCallInvalid, splitCallPlatformFree, splitCallPrepare, splitCallResult, } from '@elaraai/e3-core/portable';
|
|
22
24
|
import { decodeFunctionObject, pathToString } from '@elaraai/e3-types';
|
|
23
25
|
import { sendSuccess, sendError } from '../beast2.js';
|
|
24
26
|
import { errorToVariant } from '../errors.js';
|
|
@@ -40,45 +42,19 @@ async function resolveFunction(storage, repoPath, pkgName, version, fnName) {
|
|
|
40
42
|
return decodeFunctionObject(await storage.objects.read(repoPath, fnHash));
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
|
-
* The
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* A function's body is its author's, and runs on its author's runner as a
|
|
49
|
-
* task's does, so a call that names no runner runs for any caller the route
|
|
50
|
-
* admits. A runner the call names is the caller's:
|
|
51
|
-
* - the `custom` runtime is refused whatever the grant, since it would run a
|
|
52
|
-
* command of the caller's own;
|
|
53
|
-
* - a stock runtime given a platform package the function's own runner does
|
|
54
|
-
* not load makes more reachable than the author gave the body, and runs only
|
|
55
|
-
* under the elevated grant (`any`);
|
|
56
|
-
* - any other — the function's packages, or fewer, on a stock runtime — runs
|
|
57
|
-
* for any caller.
|
|
58
|
-
*
|
|
59
|
-
* @throws {PermissionDeniedError} When the runner gives a package the
|
|
60
|
-
* function's does not load, and the grant is not `any` (`path` `runner`).
|
|
45
|
+
* The arguments a named call hands its runner: the function's inputs, each
|
|
46
|
+
* pinned by its hash in the workspace, then each value as its bytes and each
|
|
47
|
+
* dataset argument pinned the same way, with what the call read. A call with
|
|
48
|
+
* no workspace — through the package route — has none to read an input or a
|
|
49
|
+
* dataset from, and is `invalid`.
|
|
61
50
|
*/
|
|
62
|
-
function
|
|
63
|
-
if (override.type === 'custom') {
|
|
64
|
-
return invalidExecuteResult('the call names the custom runtime to run the function on, which runs a command of its own: '
|
|
65
|
-
+ 'a function runs on its own runner, or on a stock runtime the call names — east_c, east_node or east_py');
|
|
66
|
-
}
|
|
67
|
-
const loaded = stored.type === 'custom' ? [] : stored.value.platforms;
|
|
68
|
-
if (grant !== 'any' && override.value.platforms.some((platform) => !loaded.includes(platform))) {
|
|
69
|
-
throw new PermissionDeniedError('runner');
|
|
70
|
-
}
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The arguments a named call hands its runner: each value as its bytes, and
|
|
75
|
-
* each dataset of the workspace pinned by its hash, as a one-shot's is, with
|
|
76
|
-
* what the call read. A call with no workspace — through the package route —
|
|
77
|
-
* has none to read a dataset from, and is `invalid`.
|
|
78
|
-
*/
|
|
79
|
-
async function callArguments(storage, repoPath, workspace, fnName, args) {
|
|
51
|
+
async function callArguments(storage, repoPath, workspace, fnName, fnObj, args) {
|
|
80
52
|
if (workspace !== null)
|
|
81
|
-
return pinCallArguments(storage, repoPath, workspace, args);
|
|
53
|
+
return pinCallArguments(storage, repoPath, workspace, args, { inputs: fnObj.inputs });
|
|
54
|
+
if (fnObj.inputs.length > 0) {
|
|
55
|
+
return invalidExecuteResult(`'${fnName}' reads ${fnObj.inputs.map((path) => pathToString(path)).join(', ')} from the workspace it is called through, `
|
|
56
|
+
+ `and a call through the package has none: call it through a workspace it is deployed to, at …/workspaces/<ws>/functions/${fnName}`);
|
|
57
|
+
}
|
|
82
58
|
const values = [];
|
|
83
59
|
for (const [i, arg] of args.entries()) {
|
|
84
60
|
if (arg.type === 'dataset') {
|
|
@@ -95,24 +71,27 @@ async function callArguments(storage, repoPath, workspace, fnName, args) {
|
|
|
95
71
|
* bodyIr → runDetached. Never throws for execution outcomes — only for
|
|
96
72
|
* storage/infra errors, and a runner the caller's grant does not allow.
|
|
97
73
|
*/
|
|
98
|
-
async function executeFunction(storage, repoPath, runner, fnName, fnObj, req, workspace, syncDeadlineMs, grant, signal, verbose) {
|
|
99
|
-
// Signature validation: arity
|
|
100
|
-
//
|
|
101
|
-
// from the runner.
|
|
102
|
-
if (req.args.length !== fnObj.
|
|
103
|
-
return invalidExecuteResult(`Expected ${fnObj.
|
|
74
|
+
async function executeFunction(storage, repoPath, runner, fnName, fnObj, req, workspace, syncDeadlineMs, ceilings, grant, signal, verbose) {
|
|
75
|
+
// Signature validation: arity — the arguments alone, never the inputs the
|
|
76
|
+
// server reads — is checked here, before anything runs. Per-element type
|
|
77
|
+
// errors surface as a runtime decode failure (`failed`) from the runner.
|
|
78
|
+
if (req.args.length !== fnObj.argTypes.length) {
|
|
79
|
+
return invalidExecuteResult(`Expected ${fnObj.argTypes.length} argument(s), got ${req.args.length}`);
|
|
104
80
|
}
|
|
105
81
|
if (req.runner.type === 'some') {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
82
|
+
const refusal = functionRunnerRefusal(fnObj.runner, req.runner.value, grant);
|
|
83
|
+
if (refusal !== null)
|
|
84
|
+
return invalidExecuteResult(refusal);
|
|
109
85
|
}
|
|
110
|
-
const pinned = await callArguments(storage, repoPath, workspace, fnName, req.args);
|
|
86
|
+
const pinned = await callArguments(storage, repoPath, workspace, fnName, fnObj, req.args);
|
|
111
87
|
if (!('args' in pinned))
|
|
112
88
|
return pinned;
|
|
113
89
|
const bodyIr = await storage.objects.read(repoPath, fnObj.bodyIr);
|
|
114
90
|
const runnerValue = req.runner.type === 'some' ? req.runner.value : fnObj.runner;
|
|
115
|
-
const limits = resolveExecuteLimits(req.limits,
|
|
91
|
+
const limits = resolveExecuteLimits(req.limits, {
|
|
92
|
+
...(syncDeadlineMs !== undefined && { syncDeadlineMs }),
|
|
93
|
+
...(ceilings !== undefined && { ceilings }),
|
|
94
|
+
});
|
|
116
95
|
const result = await runner.runDetached({
|
|
117
96
|
bodyIr,
|
|
118
97
|
args: pinned.args,
|
|
@@ -120,7 +99,8 @@ async function executeFunction(storage, repoPath, runner, fnName, fnObj, req, wo
|
|
|
120
99
|
limits,
|
|
121
100
|
environment: fnObj.environment.type === 'some' ? fnObj.environment.value : undefined,
|
|
122
101
|
}, { signal, storage, verbose });
|
|
123
|
-
// The result names each dataset argument the call read, at its
|
|
102
|
+
// The result names each input and dataset argument the call read, at its
|
|
103
|
+
// pinned hash
|
|
124
104
|
return detachedToExecuteResult(result, pinned.inputs);
|
|
125
105
|
}
|
|
126
106
|
// =============================================================================
|
|
@@ -137,7 +117,8 @@ export async function listPackageFunctions(storage, repoPath, pkgName, version)
|
|
|
137
117
|
const fnObj = decodeFunctionObject(await storage.objects.read(repoPath, fnHash));
|
|
138
118
|
signatures.push({
|
|
139
119
|
name,
|
|
140
|
-
|
|
120
|
+
inputs: fnObj.inputs,
|
|
121
|
+
argTypes: fnObj.argTypes,
|
|
141
122
|
outputType: fnObj.outputType,
|
|
142
123
|
runner: fnObj.runner,
|
|
143
124
|
});
|
|
@@ -156,7 +137,8 @@ export async function describePackageFunction(storage, repoPath, pkgName, versio
|
|
|
156
137
|
const fnObj = await resolveFunction(storage, repoPath, pkgName, version, fnName);
|
|
157
138
|
return sendSuccess(FunctionSignatureType, {
|
|
158
139
|
name: fnName,
|
|
159
|
-
|
|
140
|
+
inputs: fnObj.inputs,
|
|
141
|
+
argTypes: fnObj.argTypes,
|
|
160
142
|
outputType: fnObj.outputType,
|
|
161
143
|
runner: fnObj.runner,
|
|
162
144
|
});
|
|
@@ -167,9 +149,12 @@ export async function describePackageFunction(storage, repoPath, pkgName, versio
|
|
|
167
149
|
}
|
|
168
150
|
/**
|
|
169
151
|
* Call a named function synchronously: resolve → validate arity → run →
|
|
170
|
-
* 200 ExecuteResult. The call's
|
|
171
|
-
* deadline, so the caller gets a structured
|
|
172
|
-
* transport cut.
|
|
152
|
+
* 200 ExecuteResult. The call's limits are held to the host's ceilings, and its
|
|
153
|
+
* timeout under the host's sync deadline too, so the caller gets a structured
|
|
154
|
+
* `timed_out` instead of a transport cut. It runs within the request, on
|
|
155
|
+
* `runner`, and keeps nothing: the package route's. A call through a
|
|
156
|
+
* workspace's routes is kept, and runs where the host runs calls
|
|
157
|
+
* (`callFunctionInWorkspace`).
|
|
173
158
|
*
|
|
174
159
|
* @remarks
|
|
175
160
|
* A call that names no runner runs the function on its own, whatever the
|
|
@@ -177,11 +162,13 @@ export async function describePackageFunction(storage, repoPath, pkgName, versio
|
|
|
177
162
|
* (`invalid`), and a platform package the function's own runner does not
|
|
178
163
|
* load unless the grant is `any` (`permission_denied`, `path` `runner`).
|
|
179
164
|
*
|
|
180
|
-
*
|
|
181
|
-
* pinned by its hash
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
165
|
+
* The function's inputs come first among its parameters: through a workspace
|
|
166
|
+
* each is read as stored at launch, pinned by its hash and named in the
|
|
167
|
+
* result's `inputs`; an unassigned one is `invalid`, naming its path. The
|
|
168
|
+
* caller passes the arguments alone, each a value or a dataset of the
|
|
169
|
+
* workspace, pinned the same way. A call with no workspace, the package
|
|
170
|
+
* route's, has none to read from: a function with inputs, and a dataset
|
|
171
|
+
* argument, are `invalid`, and nothing runs.
|
|
185
172
|
*
|
|
186
173
|
* @param storage - Storage backend
|
|
187
174
|
* @param repoPath - The repository
|
|
@@ -197,14 +184,17 @@ export async function describePackageFunction(storage, repoPath, pkgName, versio
|
|
|
197
184
|
* may give the function a platform package the function does not load:
|
|
198
185
|
* only `any` may (default `platform_free`)
|
|
199
186
|
* @param workspace - The workspace the call runs in, whose datasets its
|
|
200
|
-
* arguments may name
|
|
201
|
-
*
|
|
187
|
+
* arguments may name, for a host that calls a workspace's function within
|
|
188
|
+
* its request and keeps nothing; `null`, the default, for the package
|
|
189
|
+
* route's, which has none
|
|
190
|
+
* @param ceilings - The most the call may ask for (default: a server's, a
|
|
191
|
+
* 10-minute timeout, a 1 MiB result and 256 KiB of logs)
|
|
202
192
|
* @returns The call's result, or the error that stopped it
|
|
203
193
|
*/
|
|
204
|
-
export async function callFunctionSync(storage, repoPath, runner, pkgName, version, fnName, req, verbose, syncDeadlineMs, grant = 'platform_free', workspace = null) {
|
|
194
|
+
export async function callFunctionSync(storage, repoPath, runner, pkgName, version, fnName, req, verbose, syncDeadlineMs, grant = 'platform_free', workspace = null, ceilings) {
|
|
205
195
|
try {
|
|
206
196
|
const fnObj = await resolveFunction(storage, repoPath, pkgName, version, fnName);
|
|
207
|
-
const result = await executeFunction(storage, repoPath, runner, fnName, fnObj, req, workspace, syncDeadlineMs, grant, undefined, verbose);
|
|
197
|
+
const result = await executeFunction(storage, repoPath, runner, fnName, fnObj, req, workspace, syncDeadlineMs, ceilings, grant, undefined, verbose);
|
|
208
198
|
return sendSuccess(ExecuteResultType, result);
|
|
209
199
|
}
|
|
210
200
|
catch (err) {
|
|
@@ -219,8 +209,9 @@ export async function callFunctionSync(storage, repoPath, runner, pkgName, versi
|
|
|
219
209
|
* The launch applies the caller's grant, pins the call's dataset arguments and
|
|
220
210
|
* writes what the job runs (e3-core `splitCallPrepare`), then files the job and
|
|
221
211
|
* dispatches it to the compute the store chooses. An explain launches the same
|
|
222
|
-
* way, and its job plans the pieces
|
|
223
|
-
*
|
|
212
|
+
* way, and its job plans the pieces as the run would, which a run that
|
|
213
|
+
* follows plans again, finding the pieces it stored: the request does no more
|
|
214
|
+
* than the launch's small writes. A request found
|
|
224
215
|
* wrong is filed as a job already `completed` with its `invalid` result, so
|
|
225
216
|
* every call's result, whatever it is, comes back through the poll. The job
|
|
226
217
|
* records whether a caller whose grant is `platform_free` may poll it
|
|
@@ -258,6 +249,7 @@ export async function startSplitCall(storage, repoPath, repo, workspace, request
|
|
|
258
249
|
inputs: [],
|
|
259
250
|
objects: [],
|
|
260
251
|
then: none,
|
|
252
|
+
first: none,
|
|
261
253
|
limits: { timeoutMs: BigInt(limits.timeoutMs), maxResultBytes: BigInt(limits.maxResultBytes), maxLogBytes: BigInt(limits.maxLogBytes) },
|
|
262
254
|
read: [],
|
|
263
255
|
status: variant('completed', splitCallInvalid(launched)),
|
|
@@ -270,6 +262,7 @@ export async function startSplitCall(storage, repoPath, repo, workspace, request
|
|
|
270
262
|
inputs: [...launched.inputs],
|
|
271
263
|
objects: launched.objects.map((index) => BigInt(index)),
|
|
272
264
|
then: launched.then === null ? none : some(launched.then),
|
|
265
|
+
first: launched.first === null ? none : some(BigInt(launched.first)),
|
|
273
266
|
limits: {
|
|
274
267
|
timeoutMs: BigInt(launched.limits.timeoutMs),
|
|
275
268
|
maxResultBytes: BigInt(launched.limits.maxResultBytes),
|
|
@@ -285,9 +278,57 @@ export async function startSplitCall(storage, repoPath, repo, workspace, request
|
|
|
285
278
|
return sendError(PackageJobResponseType, errorToVariant(err));
|
|
286
279
|
}
|
|
287
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* The split call a caller may poll, or cancel: `null` when the workspace
|
|
283
|
+
* launched no such job.
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
* A caller whose grant is `none` polls no job, and one whose grant is
|
|
287
|
+
* `platform_free` only a job its record lets it (`platformFree`): a result
|
|
288
|
+
* persists and is found by its id, so a reader never reads that of a call only
|
|
289
|
+
* an elevated grant could run.
|
|
290
|
+
*
|
|
291
|
+
* @throws {PermissionDeniedError} (`path` `one-shot`) For a caller whose grant
|
|
292
|
+
* does not poll the job
|
|
293
|
+
*/
|
|
294
|
+
async function pollableSplitCall(splitCallStore, repo, workspace, id, grant) {
|
|
295
|
+
if (grant === 'none')
|
|
296
|
+
throw new PermissionDeniedError('one-shot');
|
|
297
|
+
const job = await splitCallStore.get(id);
|
|
298
|
+
if (job === null || job.repo !== repo || job.workspace !== workspace)
|
|
299
|
+
return null;
|
|
300
|
+
if (grant === 'platform_free' && !job.platformFree)
|
|
301
|
+
throw new PermissionDeniedError('one-shot');
|
|
302
|
+
return job;
|
|
303
|
+
}
|
|
304
|
+
/** The answer to a workspace that launched no split call `id`. */
|
|
305
|
+
function noSplitCall(workspace, id) {
|
|
306
|
+
return sendError(SplitCallStatusType, variant('internal', {
|
|
307
|
+
message: `workspace '${workspace}' has no split call '${id}'`,
|
|
308
|
+
}));
|
|
309
|
+
}
|
|
310
|
+
/** A split call's status, as a poll answers it: a finished call's value read
|
|
311
|
+
* from the store. */
|
|
312
|
+
async function splitCallStatusOf(storage, repoPath, job) {
|
|
313
|
+
const status = job.status;
|
|
314
|
+
switch (status.type) {
|
|
315
|
+
case 'processing':
|
|
316
|
+
return variant('processing', status.value);
|
|
317
|
+
case 'failed':
|
|
318
|
+
return variant('failed', status.value);
|
|
319
|
+
case 'planned':
|
|
320
|
+
return variant('planned', status.value);
|
|
321
|
+
case 'cancelled':
|
|
322
|
+
return variant('cancelled', null);
|
|
323
|
+
case 'completed': {
|
|
324
|
+
const result = await splitCallResult(storage, repoPath, status.value, job.read, Number(job.limits.maxResultBytes));
|
|
325
|
+
return variant('completed', { result, output: status.value.output, report: status.value.report });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
288
329
|
/**
|
|
289
330
|
* A split call's status: how far its job has got, its result, the pieces an
|
|
290
|
-
* explain planned,
|
|
331
|
+
* explain planned, why e3 could not run it, or that it was cancelled.
|
|
291
332
|
*
|
|
292
333
|
* @remarks
|
|
293
334
|
* A job's record holds hashes: a finished call's value is read from the store
|
|
@@ -313,29 +354,53 @@ export async function startSplitCall(storage, repoPath, repo, workspace, request
|
|
|
313
354
|
*/
|
|
314
355
|
export async function getSplitCallStatus(storage, repoPath, splitCallStore, repo, workspace, id, grant) {
|
|
315
356
|
try {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
357
|
+
const job = await pollableSplitCall(splitCallStore, repo, workspace, id, grant);
|
|
358
|
+
if (job === null)
|
|
359
|
+
return noSplitCall(workspace, id);
|
|
360
|
+
return sendSuccess(SplitCallStatusType, await splitCallStatusOf(storage, repoPath, job));
|
|
361
|
+
}
|
|
362
|
+
catch (err) {
|
|
363
|
+
return sendError(SplitCallStatusType, errorToVariant(err));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Cancel a split call: a job still `processing` ends `cancelled`, and the
|
|
368
|
+
* job's processor stops its units once it finds it so; one that has ended is
|
|
369
|
+
* left as it is.
|
|
370
|
+
*
|
|
371
|
+
* @remarks
|
|
372
|
+
* Whoever may poll the job may cancel it, by the rule
|
|
373
|
+
* {@link getSplitCallStatus} polls by. The store writes the cancel only while
|
|
374
|
+
* the job runs, in one step with its check, so a cancel never overwrites a
|
|
375
|
+
* result, nor a result a cancel. The units that finished stay cached, so a
|
|
376
|
+
* relaunch is served them.
|
|
377
|
+
*
|
|
378
|
+
* @param storage - Storage backend
|
|
379
|
+
* @param repoPath - Repository identifier
|
|
380
|
+
* @param splitCallStore - Where the job is filed
|
|
381
|
+
* @param repo - The repository's name
|
|
382
|
+
* @param workspace - Workspace name
|
|
383
|
+
* @param id - The job's id
|
|
384
|
+
* @param grant - What the caller may run: the grant the host's auth gave it
|
|
385
|
+
* @returns The response: the job's status after the cancel, as a poll answers
|
|
386
|
+
* it — `cancelled`, or the status it had ended with; or the error, as
|
|
387
|
+
* {@link getSplitCallStatus} answers it
|
|
388
|
+
*/
|
|
389
|
+
export async function cancelSplitCall(storage, repoPath, splitCallStore, repo, workspace, id, grant) {
|
|
390
|
+
try {
|
|
391
|
+
let job = await pollableSplitCall(splitCallStore, repo, workspace, id, grant);
|
|
392
|
+
if (job === null)
|
|
393
|
+
return noSplitCall(workspace, id);
|
|
394
|
+
if (job.status.type === 'processing') {
|
|
395
|
+
if (await splitCallStore.updateStatus(id, variant('cancelled', null))) {
|
|
396
|
+
job = { ...job, status: variant('cancelled', null) };
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
// It ended as the cancel came: answered as it ended.
|
|
400
|
+
job = await splitCallStore.get(id) ?? job;
|
|
337
401
|
}
|
|
338
402
|
}
|
|
403
|
+
return sendSuccess(SplitCallStatusType, await splitCallStatusOf(storage, repoPath, job));
|
|
339
404
|
}
|
|
340
405
|
catch (err) {
|
|
341
406
|
return sendError(SplitCallStatusType, errorToVariant(err));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/handlers/functions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAyC,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9G,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GAIpB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,KAAK,UAAU,eAAe,CAC5B,OAAuB,EACvB,QAAgB,EAChB,OAAe,EACf,OAAe,EACf,MAAc;IAEd,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,MAAM,GAAG,GAAG,CAA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StringType, encodeBeast2For, decodeBeast2F
|
|
|
9
9
|
import { InMemoryTransferBackend, MockTaskRunner } from '@elaraai/e3-core';
|
|
10
10
|
import { InMemoryStorage } from '@elaraai/e3-core/test';
|
|
11
11
|
import { BEAST2_CONTENT_TYPE, FunctionObjectType, PackageObjectType } from '@elaraai/e3-types';
|
|
12
|
-
import { listPackageFunctions, describePackageFunction, callFunctionSync, getSplitCallStatus, } from './functions.js';
|
|
12
|
+
import { listPackageFunctions, describePackageFunction, callFunctionSync, cancelSplitCall, getSplitCallStatus, } from './functions.js';
|
|
13
13
|
import { createOneShotRoutes, createPackageFunctionRoutes, oneShotAccessByRoles } from '../routes/functions.js';
|
|
14
14
|
import { ResponseType, FunctionSignatureType, ExecuteResultType, FunctionCallRequestType, OneShotRequestType, PackageJobResponseType, SplitCallRequestType, SplitCallStatusType, } from '../types.js';
|
|
15
15
|
import { ArrayType } from '@elaraai/east';
|
|
@@ -21,22 +21,27 @@ const encodeInt = encodeBeast2For(IntegerType);
|
|
|
21
21
|
async function decodeResponse(response, type) {
|
|
22
22
|
return decodeBeast2For(ResponseType(type))(new Uint8Array(await response.arrayBuffer()));
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/** The input `scaled` reads. */
|
|
25
|
+
const N_PATH = [variant('field', 'inputs'), variant('field', 'n')];
|
|
26
|
+
/** Seed a repo containing a function `double` (Integer -> Integer), and
|
|
27
|
+
* `scaled`, which reads `.inputs.n` and is given an Integer. */
|
|
25
28
|
async function seedPackage(storage) {
|
|
26
29
|
await storage.repos.create(REPO);
|
|
27
30
|
const bodyIrHash = await storage.objects.write(REPO, encodeInt(0n)); // stand-in IR blob
|
|
28
|
-
const fnObject = {
|
|
31
|
+
const fnObject = (inputs) => ({
|
|
29
32
|
bodyIr: bodyIrHash,
|
|
30
|
-
|
|
33
|
+
inputs,
|
|
34
|
+
argTypes: [toEastTypeValue(IntegerType)],
|
|
31
35
|
outputType: toEastTypeValue(IntegerType),
|
|
32
36
|
runner: variant('east_node', { platforms: ['@elaraai/east-node-std'], decode: variant('lazy', null) }),
|
|
33
37
|
environment: none,
|
|
34
|
-
};
|
|
35
|
-
const fnHash = await storage.objects.write(REPO, encodeBeast2For(FunctionObjectType)(fnObject));
|
|
38
|
+
});
|
|
39
|
+
const fnHash = await storage.objects.write(REPO, encodeBeast2For(FunctionObjectType)(fnObject([])));
|
|
40
|
+
const scaledHash = await storage.objects.write(REPO, encodeBeast2For(FunctionObjectType)(fnObject([N_PATH])));
|
|
36
41
|
const pkgObject = {
|
|
37
42
|
tasks: new Map(),
|
|
38
43
|
data: { structure: variant('struct', new Map()), refs: new Map() },
|
|
39
|
-
functions: new Map([['double', fnHash]]),
|
|
44
|
+
functions: new Map([['double', fnHash], ['scaled', scaledHash]]),
|
|
40
45
|
records: new Map(),
|
|
41
46
|
sources: new Map(),
|
|
42
47
|
};
|
|
@@ -55,15 +60,36 @@ describe('function handlers', () => {
|
|
|
55
60
|
runner = new MockTaskRunner();
|
|
56
61
|
await seedPackage(storage);
|
|
57
62
|
});
|
|
58
|
-
it('listPackageFunctions surfaces the
|
|
63
|
+
it('listPackageFunctions surfaces each signature, the inputs a call reads apart from its arguments', async () => {
|
|
59
64
|
const response = await listPackageFunctions(storage, REPO, PKG, VERSION);
|
|
60
65
|
const result = await decodeResponse(response, ArrayType(FunctionSignatureType));
|
|
61
66
|
assert.ok(result.type === 'success');
|
|
62
|
-
assert.
|
|
63
|
-
const
|
|
64
|
-
assert.equal(
|
|
65
|
-
assert.equal(
|
|
66
|
-
assert.equal(
|
|
67
|
+
assert.deepEqual(result.value.map((signature) => signature.name), ['double', 'scaled']);
|
|
68
|
+
const [double, scaled] = result.value;
|
|
69
|
+
assert.equal(double.argTypes.length, 1);
|
|
70
|
+
assert.equal(double.inputs.length, 0);
|
|
71
|
+
assert.equal(double.outputType.type, 'Integer');
|
|
72
|
+
assert.deepEqual(scaled.inputs, [N_PATH]);
|
|
73
|
+
assert.equal(scaled.argTypes.length, 1);
|
|
74
|
+
});
|
|
75
|
+
it('answers a function with inputs through the package, which has no workspace to read them from, invalid without executing', async () => {
|
|
76
|
+
const response = await callFunctionSync(storage, REPO, runner, PKG, VERSION, 'scaled', callRequest([encodeInt(5n)]));
|
|
77
|
+
const result = await decodeResponse(response, ExecuteResultType);
|
|
78
|
+
assert.ok(result.type === 'success');
|
|
79
|
+
const { outcome } = result.value;
|
|
80
|
+
assert.ok(outcome.type === 'invalid');
|
|
81
|
+
assert.equal(outcome.value.diagnostics[0].message, '\'scaled\' reads .inputs.n from the workspace it is called through, and a call through the package has none: '
|
|
82
|
+
+ 'call it through a workspace it is deployed to, at …/workspaces/<ws>/functions/scaled');
|
|
83
|
+
assert.equal(runner.getDetachedCalls().length, 0, 'nothing should have executed');
|
|
84
|
+
});
|
|
85
|
+
it('counts a function\'s arguments alone, never its inputs', async () => {
|
|
86
|
+
const response = await callFunctionSync(storage, REPO, runner, PKG, VERSION, 'scaled', callRequest([encodeInt(1n), encodeInt(5n)]));
|
|
87
|
+
const result = await decodeResponse(response, ExecuteResultType);
|
|
88
|
+
assert.ok(result.type === 'success');
|
|
89
|
+
const { outcome } = result.value;
|
|
90
|
+
assert.ok(outcome.type === 'invalid');
|
|
91
|
+
assert.equal(outcome.value.diagnostics[0].message, 'Expected 1 argument(s), got 2');
|
|
92
|
+
assert.equal(runner.getDetachedCalls().length, 0, 'nothing should have executed');
|
|
67
93
|
});
|
|
68
94
|
it('describePackageFunction returns task_not_found for unknown functions', async () => {
|
|
69
95
|
const response = await describePackageFunction(storage, REPO, PKG, VERSION, 'nope');
|
|
@@ -268,7 +294,7 @@ describe('one-shot access', () => {
|
|
|
268
294
|
// reader could launch, and one only an elevated grant could.
|
|
269
295
|
for (const [id, platformFree] of [['free', true], ['elevated', false]]) {
|
|
270
296
|
await store.create(id, {
|
|
271
|
-
repo: 'r', workspace: 'w', task: '', inputs: [], objects: [], then: none,
|
|
297
|
+
repo: 'r', workspace: 'w', task: '', inputs: [], objects: [], then: none, first: none,
|
|
272
298
|
limits: { timeoutMs: 1000n, maxResultBytes: 1024n, maxLogBytes: 1024n },
|
|
273
299
|
read: [], explain: true, platformFree, status: variant('planned', plan), createdAt: new Date(),
|
|
274
300
|
});
|
|
@@ -283,5 +309,36 @@ describe('one-shot access', () => {
|
|
|
283
309
|
assert.deepEqual(await poll('r', 'w', 'elevated', 'platform_free'), variant('error', variant('permission_denied', { path: 'one-shot' })));
|
|
284
310
|
assert.deepEqual(await poll('r', 'w', 'elevated', 'any'), variant('success', variant('planned', plan)));
|
|
285
311
|
});
|
|
312
|
+
it('cancels a split call for whoever may poll it, and only while it runs: a cancel never overwrites an end, nor an end a cancel (#1104)', async () => {
|
|
313
|
+
const store = new InMemoryTransferBackend({}).splitCall;
|
|
314
|
+
const plan = { pieces: 3n, over: 0n, bytes: 100n };
|
|
315
|
+
// Jobs launched in workspace `w` of repository `r`: two that run, one a
|
|
316
|
+
// reader could launch and one only an elevated grant could, and one
|
|
317
|
+
// that has ended.
|
|
318
|
+
for (const [id, platformFree, status] of [
|
|
319
|
+
['running', true, variant('processing', none)],
|
|
320
|
+
['elevated', false, variant('processing', none)],
|
|
321
|
+
['planned', true, variant('planned', plan)],
|
|
322
|
+
]) {
|
|
323
|
+
await store.create(id, {
|
|
324
|
+
repo: 'r', workspace: 'w', task: '', inputs: [], objects: [], then: none, first: none,
|
|
325
|
+
limits: { timeoutMs: 1000n, maxResultBytes: 1024n, maxLogBytes: 1024n },
|
|
326
|
+
read: [], explain: true, platformFree, status, createdAt: new Date(),
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
const cancel = async (ws, id, grant) => decodeResponse(await cancelSplitCall(new InMemoryStorage(), 'r', store, 'r', ws, id, grant), SplitCallStatusType);
|
|
330
|
+
assert.deepEqual(await cancel('w', 'running', 'none'), variant('error', variant('permission_denied', { path: 'one-shot' })));
|
|
331
|
+
assert.deepEqual(await cancel('w', 'elevated', 'platform_free'), variant('error', variant('permission_denied', { path: 'one-shot' })));
|
|
332
|
+
assert.deepEqual(await cancel('other', 'running', 'any'), variant('error', variant('internal', { message: 'workspace \'other\' has no split call \'running\'' })));
|
|
333
|
+
for (const id of ['running', 'elevated']) {
|
|
334
|
+
assert.equal((await store.get(id))?.status.type, 'processing', `no refused cancel stopped ${id}`);
|
|
335
|
+
}
|
|
336
|
+
assert.deepEqual(await cancel('w', 'running', 'platform_free'), variant('success', variant('cancelled', null)));
|
|
337
|
+
assert.deepEqual(await cancel('w', 'running', 'any'), variant('success', variant('cancelled', null)), 'cancelled again, it stays so');
|
|
338
|
+
assert.equal(await store.updateStatus('running', variant('failed', { message: 'too late' })), false, 'an end written after the cancel is refused');
|
|
339
|
+
assert.equal((await store.get('running'))?.status.type, 'cancelled');
|
|
340
|
+
assert.deepEqual(await cancel('w', 'elevated', 'any'), variant('success', variant('cancelled', null)));
|
|
341
|
+
assert.deepEqual(await cancel('w', 'planned', 'any'), variant('success', variant('planned', plan)), 'a job that has ended answers as it ended');
|
|
342
|
+
});
|
|
286
343
|
});
|
|
287
344
|
//# sourceMappingURL=functions.spec.js.map
|