@toloka-platform/sdk 0.26.1 → 0.26.2
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/dist/cli/toloka.js +143 -143
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/package.json +2 -2
- package/skills/catalog.json +6 -6
- package/skills/toloka-build/SKILL.md +1 -1
- package/src/cli/poll.ts +26 -0
- package/src/cli/project.ts +16 -23
- package/src/cli/runs.ts +13 -14
package/dist/cli/toloka.js.jsc
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
41ea5ed778785de3bc1c7d7afc22672e77a8a9cd390e96c24b1cf6bc9696b0f6 toloka.js.jsc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9f8d3ba912063ce04cf5a16fc76889223c36d33646678072c37a426b1c178b31 toloka.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toloka-platform/sdk",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build, inspect, and operate Toloka pipeline projects as TypeScript source. The public API may change between minor versions before 1.0.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
"bun": ">=1.4.0"
|
|
79
79
|
},
|
|
80
80
|
"tolokaBuild": {
|
|
81
|
-
"commit": "
|
|
81
|
+
"commit": "760207ffdf03139ad90ac44acec02779a575bb10"
|
|
82
82
|
}
|
|
83
83
|
}
|
package/skills/catalog.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"testing",
|
|
12
12
|
"checks"
|
|
13
13
|
],
|
|
14
|
-
"version": "0.26.
|
|
15
|
-
"digest": "
|
|
14
|
+
"version": "0.26.2",
|
|
15
|
+
"digest": "9207bbd632069a209a588b711a40c7e8bddb44c25775cfebee5068cc8c86b11c",
|
|
16
16
|
"files": [
|
|
17
17
|
"SKILL.md",
|
|
18
18
|
"references/human-work.md",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"bug",
|
|
34
34
|
"report"
|
|
35
35
|
],
|
|
36
|
-
"version": "0.26.
|
|
36
|
+
"version": "0.26.2",
|
|
37
37
|
"digest": "70f0bd2c80b32f87896aeb27c363b8a2d37f40e22424f57fe1aad142e125ad67",
|
|
38
38
|
"files": [
|
|
39
39
|
"SKILL.md",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"getting-started",
|
|
51
51
|
"agent"
|
|
52
52
|
],
|
|
53
|
-
"version": "0.26.
|
|
53
|
+
"version": "0.26.2",
|
|
54
54
|
"digest": "2278adeb46a792356579395fcf73c42322cb23bcd0c61e20856ccabdad6762d1",
|
|
55
55
|
"files": [
|
|
56
56
|
"SKILL.md"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"sft",
|
|
68
68
|
"models"
|
|
69
69
|
],
|
|
70
|
-
"version": "0.26.
|
|
70
|
+
"version": "0.26.2",
|
|
71
71
|
"digest": "3ce10dee5d3c283d8b5fdea15134a58fc738c7af2c1bb19eb5a0bf70ea0bca13",
|
|
72
72
|
"files": [
|
|
73
73
|
"SKILL.md"
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"prompt",
|
|
85
85
|
"models"
|
|
86
86
|
],
|
|
87
|
-
"version": "0.26.
|
|
87
|
+
"version": "0.26.2",
|
|
88
88
|
"digest": "be8bce8d9cf7241ccb60d2b2a9b7cc07d7755a76e8ff8ec1b0847c49efbb3469",
|
|
89
89
|
"files": [
|
|
90
90
|
"SKILL.md"
|
|
@@ -90,7 +90,7 @@ Let constructors mint IDs for new declarations. Preserve `id` options generated
|
|
|
90
90
|
| `checks-running` | Only with `--wait`: a lint was still running when the wait ended. |
|
|
91
91
|
| `skipped` | The pipeline or its dataset is not on the platform yet; `toloka apply` creates it. |
|
|
92
92
|
|
|
93
|
-
The platform's lints, such as the Task UI interface lint and the quality-criteria lint, start by themselves a few seconds after every apply and take about a minute. Until they finish, plain `toloka validate` lists each as a `running_node_check` warning and can still print `valid` with exit 0, so it does not prove the lints passed. After applying a change, run `toloka validate --wait`: it validates again
|
|
93
|
+
The platform's lints, such as the Task UI interface lint and the quality-criteria lint, start by themselves a few seconds after every apply and take about a minute. Until they finish, plain `toloka validate` lists each as a `running_node_check` warning and can still print `valid` with exit 0, so it does not prove the lints passed. After applying a change, run `toloka validate --wait`: it validates again after 1 second, then at growing intervals of up to 5 seconds, for up to 5 minutes, until no lint is running, and does not wait for a pipeline whose source has unapplied changes. Report the pipeline as valid only after that. A lint does not restart by itself when dataset items or their values change, or after it fails or times out (after 5 minutes running or 15 minutes waiting to start): run `toloka pipeline lint <name> --wait`, which starts every lint without a current result and waits for it, then validate again. `validate` names this case: `Check "<name>" ran before the dataset changed`. When a reviewed plan adds a dataset field already bound by an existing live pipeline, pre-apply validation can report that exact field as missing; apply only the reviewed additive plan, then require post-apply validation to clear source/spec errors. Never rewrite valid source because a stored test case on the Checks tab has not run.
|
|
94
94
|
|
|
95
95
|
Register every code-node behavior with `test.code(pipeline, node, name, callback)`; its callback receives a bound `run(inputs, options?)` helper with the node's Python execution contract, and the test counts only after `run` executes, an assertion runs, and the callback passes. Register required human-work behavior with `test.ui(pipeline, node, name, callback)`; its callback receives a bound `render(options?)`, and the test counts only after a successful `submit`, at least one assertion, and a passing callback. Add at least one `test.pipeline(pipeline, name, callback)` scenario: treat the fixture as `root.started` item state, execute connected nodes in order with the callback's bound `runCode` and `renderUi` helpers, merge only each node's declared outputs, and assert the final `root.completed` fields. Cover meaningful match branches, optional paths, and failures as well as the happy path.
|
|
96
96
|
|
package/src/cli/poll.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const FIRST_POLL_INTERVAL_MS = 1_000;
|
|
2
|
+
|
|
3
|
+
export const pollUntil = async <T>({
|
|
4
|
+
initial,
|
|
5
|
+
settled,
|
|
6
|
+
poll,
|
|
7
|
+
deadline,
|
|
8
|
+
maxIntervalMs,
|
|
9
|
+
}: {
|
|
10
|
+
readonly initial: T;
|
|
11
|
+
readonly settled: (state: T) => boolean;
|
|
12
|
+
readonly poll: (state: T) => Promise<T>;
|
|
13
|
+
readonly deadline: number;
|
|
14
|
+
readonly maxIntervalMs: number;
|
|
15
|
+
}): Promise<T> => {
|
|
16
|
+
let state = initial;
|
|
17
|
+
let intervalMs = Math.min(FIRST_POLL_INTERVAL_MS, maxIntervalMs);
|
|
18
|
+
while (!settled(state) && Date.now() < deadline) {
|
|
19
|
+
await new Promise<void>((resolve) => {
|
|
20
|
+
setTimeout(resolve, Math.min(intervalMs, deadline - Date.now()));
|
|
21
|
+
});
|
|
22
|
+
state = await poll(state);
|
|
23
|
+
intervalMs = Math.min(intervalMs * 2, maxIntervalMs);
|
|
24
|
+
}
|
|
25
|
+
return state;
|
|
26
|
+
};
|
package/src/cli/project.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { listPipelineSourceDirectories, loadProjectSource } from "./source";
|
|
|
18
18
|
import type { ProjectPipelineSource, ProjectSource } from "./source";
|
|
19
19
|
import { pipelineDirectoryName, resolvePipelineDirectories } from "./pipeline-selector";
|
|
20
20
|
import { assertCli, REPORT_HINT } from "./cli-error";
|
|
21
|
+
import { pollUntil } from "./poll";
|
|
21
22
|
|
|
22
23
|
export type PipelinePlanChange = {
|
|
23
24
|
readonly kind: "node" | "connection" | "field" | "layout";
|
|
@@ -1258,11 +1259,6 @@ type RunningValidation = {
|
|
|
1258
1259
|
readonly failure?: string;
|
|
1259
1260
|
};
|
|
1260
1261
|
|
|
1261
|
-
const sleep = (ms: number) =>
|
|
1262
|
-
new Promise<void>((resolve) => {
|
|
1263
|
-
setTimeout(resolve, ms);
|
|
1264
|
-
});
|
|
1265
|
-
|
|
1266
1262
|
const pollValidationEntry = async (
|
|
1267
1263
|
results: PipelineValidationResult[],
|
|
1268
1264
|
entry: RunningValidation,
|
|
@@ -1282,17 +1278,16 @@ const waitForRunningChecks = async (
|
|
|
1282
1278
|
wait: NonNullable<ValidateProjectOptions["wait"]>,
|
|
1283
1279
|
startedAt: number,
|
|
1284
1280
|
) => {
|
|
1285
|
-
const
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
}
|
|
1281
|
+
const pending = await pollUntil({
|
|
1282
|
+
initial: running,
|
|
1283
|
+
settled: (entries) => entries.length === 0,
|
|
1284
|
+
poll: async (entries) =>
|
|
1285
|
+
(await Promise.all(entries.map((entry) => pollValidationEntry(results, entry)))).filter(
|
|
1286
|
+
(entry): entry is RunningValidation => entry !== undefined,
|
|
1287
|
+
),
|
|
1288
|
+
deadline: startedAt + wait.timeoutMs,
|
|
1289
|
+
maxIntervalMs: wait.pollIntervalMs,
|
|
1290
|
+
});
|
|
1296
1291
|
const waitedSeconds = Math.round((Date.now() - startedAt) / 1000);
|
|
1297
1292
|
for (const entry of pending) {
|
|
1298
1293
|
const result = results[entry.index]!;
|
|
@@ -1379,13 +1374,11 @@ export async function validateProject(
|
|
|
1379
1374
|
const startedAt = Date.now();
|
|
1380
1375
|
const inspection = await inspectProject(client, options);
|
|
1381
1376
|
const { wait } = options;
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
if (poll !== undefined) running.push({ index: results.length - 1, validate: poll });
|
|
1388
|
-
}
|
|
1377
|
+
const entries = await Promise.all(
|
|
1378
|
+
inspection.pipelines.map((pipeline) => validatePipelineEntry(client, inspection, pipeline, wait)),
|
|
1379
|
+
);
|
|
1380
|
+
const results = entries.map(({ result }) => result);
|
|
1381
|
+
const running = entries.flatMap(({ poll }, index) => (poll === undefined ? [] : [{ index, validate: poll }]));
|
|
1389
1382
|
if (wait !== undefined) await waitForRunningChecks(results, running, wait, startedAt);
|
|
1390
1383
|
const valid = results.every(
|
|
1391
1384
|
(result) => result.status !== "invalid" && result.status !== "checks_running",
|
package/src/cli/runs.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { RunItem, RunJob } from "../index";
|
|
|
6
6
|
import { assertCli } from "./cli-error";
|
|
7
7
|
import { apiErrorDetails } from "./format-error";
|
|
8
8
|
import { matchesNormalizedPipelineName } from "./pipeline-selector";
|
|
9
|
+
import { pollUntil } from "./poll";
|
|
9
10
|
|
|
10
11
|
export type PipelineRef = {
|
|
11
12
|
readonly pipelineId: string;
|
|
@@ -266,24 +267,22 @@ type LintJob = Awaited<ReturnType<PotatoClient["checks"]["runLints"]>>["checks"]
|
|
|
266
267
|
|
|
267
268
|
const isLintFinished = (job: LintJob) => job.status === "succeeded" || job.status === "failed";
|
|
268
269
|
|
|
269
|
-
const waitForLints =
|
|
270
|
+
const waitForLints = (
|
|
270
271
|
client: PotatoClient,
|
|
271
272
|
jobs: readonly LintJob[],
|
|
272
273
|
timeoutMs: number,
|
|
273
274
|
intervalMs: number,
|
|
274
|
-
): Promise<readonly LintJob[]> =>
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
return current;
|
|
286
|
-
};
|
|
275
|
+
): Promise<readonly LintJob[]> =>
|
|
276
|
+
pollUntil({
|
|
277
|
+
initial: jobs,
|
|
278
|
+
settled: (current) => current.every(isLintFinished),
|
|
279
|
+
poll: (current) =>
|
|
280
|
+
Promise.all(
|
|
281
|
+
current.map(async (job) => (isLintFinished(job) ? job : client.checks.get({ checkRunId: job.id }))),
|
|
282
|
+
),
|
|
283
|
+
deadline: Date.now() + timeoutMs,
|
|
284
|
+
maxIntervalMs: intervalMs,
|
|
285
|
+
});
|
|
287
286
|
|
|
288
287
|
const runLints = async (
|
|
289
288
|
client: PotatoClient,
|