@toloka-platform/sdk 0.19.0 → 0.19.1
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 +15 -13
- package/dist/cli/toloka.js +108 -106
- 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 +8 -7
- package/skills/catalog.json +5 -5
- package/src/cli/commands/auth.ts +2 -2
- package/src/cli/commands/batch-inference.ts +5 -5
- package/src/cli/commands/config.ts +4 -3
- package/src/cli/commands/dataset.ts +2 -2
- package/src/cli/commands/models.ts +1 -1
- package/src/cli/commands/pipeline.ts +1 -1
- package/src/cli/commands/report.ts +1 -1
- package/src/cli/commands/training.ts +16 -16
- package/src/cli/commands/ui.ts +1 -1
- package/src/cli/program.ts +3 -3
- package/src/transport.ts +18 -0
- package/docs/authoring.md +0 -320
- package/docs/cli-v2.md +0 -224
- package/docs/cli.md +0 -561
- package/docs/datasets.md +0 -213
- package/docs/getting-started.md +0 -147
- package/docs/limitations.md +0 -58
- package/docs/nodes.md +0 -104
- package/docs/testing-examples.md +0 -248
- package/docs/testing.md +0 -125
- package/docs/troubleshooting.md +0 -115
package/docs/authoring.md
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
# Authoring
|
|
2
|
-
|
|
3
|
-
How to express a pipeline project in TypeScript: fields, nodes, ports, and assembly.
|
|
4
|
-
|
|
5
|
-
## Source layout
|
|
6
|
-
|
|
7
|
-
A project root is the directory holding `toloka.json` and `pipelines/`. Commands walk up from the working directory to find it.
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
toloka.json CLI-managed identity state, never hand-edited
|
|
11
|
-
fields.ts field declarations shared across nodes
|
|
12
|
-
pipelines/
|
|
13
|
-
cat-labeling/
|
|
14
|
-
pipeline.ts default-exports definePipeline(...)
|
|
15
|
-
nodes/
|
|
16
|
-
collection/node.ts
|
|
17
|
-
annotate-cats/node.ts
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
One file per node keeps edits local: changing a prompt or a price touches one file, and a reviewer sees exactly which node changed. `pipeline.ts` holds the topology and nothing else.
|
|
21
|
-
|
|
22
|
-
## Declare fields once
|
|
23
|
-
|
|
24
|
-
A field is a named data contract with a JSON Schema. Declare it once and import it wherever it is used.
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
import { field } from "@toloka-platform/sdk";
|
|
28
|
-
|
|
29
|
-
export const imageUrl = field("image_url", { type: "string", format: "uri" });
|
|
30
|
-
export const annotations = field("annotations", {
|
|
31
|
-
type: "array",
|
|
32
|
-
items: { type: "object", additionalProperties: true },
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
The name is a bare identifier. When a field is a pipeline **input**, its name must match a column on the bound dataset, case-sensitively. Output-only and intermediate fields can be named freely.
|
|
37
|
-
|
|
38
|
-
## Node constructors
|
|
39
|
-
|
|
40
|
-
Four work-node constructors take a name, settings, and optional `{ id }`: `code`, `generation`, `quorum`, and `match`. `root` is the single pipeline boundary and takes only settings plus optional `{ id }`.
|
|
41
|
-
|
|
42
|
-
### root
|
|
43
|
-
|
|
44
|
-
Defines the pipeline's input and output contract. `started` is what each item carries in from the dataset; `completed` is what gets written back.
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
import { optional, root } from "@toloka-platform/sdk";
|
|
48
|
-
|
|
49
|
-
export const collection = root({
|
|
50
|
-
started: [imageUrl],
|
|
51
|
-
completed: [optional(annotations)],
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Pass a bare field for a required binding. Use `optional(field)` for new optional bindings. The explicit `{ field, optional }` form remains supported and may appear in imported source.
|
|
56
|
-
|
|
57
|
-
`root()` deliberately has no name argument: a pipeline has exactly one boundary, and its default wire id is `root`.
|
|
58
|
-
|
|
59
|
-
### code
|
|
60
|
-
|
|
61
|
-
Deterministic work: transformations, HTTP calls, LLM calls. The Python program is an inline string.
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
import { code } from "@toloka-platform/sdk";
|
|
65
|
-
|
|
66
|
-
export const orderFaces = code("order_faces", {
|
|
67
|
-
about: { name: "order_faces", description: "Sort annotations top-left to bottom-right." },
|
|
68
|
-
envVars: [],
|
|
69
|
-
input: [{ field: draftFaces, optional: false }],
|
|
70
|
-
output: [{ field: faces, optional: false }],
|
|
71
|
-
code: {
|
|
72
|
-
code: `from main_types import Inputs, Outputs
|
|
73
|
-
|
|
74
|
-
async def main(inputs: Inputs) -> Outputs:
|
|
75
|
-
ordered = sorted(inputs["draft_faces"], key=lambda f: (f["boundingBox"]["y"], f["boundingBox"]["x"]))
|
|
76
|
-
return {"faces": ordered}`,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
If the program calls an external service, list the secret names in `envVars`. The sandbox has no ambient environment.
|
|
82
|
-
|
|
83
|
-
Register authored code behavior with `test.code(pipeline, node, name, callback)` from `@toloka-platform/sdk/testing`, execute its bound `run` helper, and cover representative inputs, boundaries, deterministic behavior, and real failures. Bare `runCodeNode` calls remain useful for exploratory tests but do not satisfy `toloka check` coverage.
|
|
84
|
-
|
|
85
|
-
### generation
|
|
86
|
-
|
|
87
|
-
One human-work task type. The node owns the entire expert journey: instruction, UI, entity schemas, quality criteria, quality assurance, audience, pricing, Training, and Exam.
|
|
88
|
-
|
|
89
|
-
Choose entity cardinality from the task, not from the component's JavaScript value shape. If one labeler produces one logical result, keep the entity static: omit `dynamic` and `maxEntities`, and use a path without `[*]`.
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
{
|
|
93
|
-
field: caption,
|
|
94
|
-
entityType: "SHORT_ANSWER",
|
|
95
|
-
jsonPath: "$.caption",
|
|
96
|
-
description: "The one caption written for this image.",
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Use `dynamic: true` only when one labeler produces multiple independent entities. Set `maxEntities` to a task-grounded upper bound rather than a generic default. A component may expose an array while still producing one logical entity; for a single upload or recording, keep a scalar field and static entity and select the completed first value with a path such as `$.video_file[0].downloadLink`.
|
|
101
|
-
|
|
102
|
-
Entity types and labels are checked locally, for both generation and quorum nodes, before anything is sent to the platform:
|
|
103
|
-
|
|
104
|
-
- `entityType` on every input and output entity must be one of the platform's core entity types. The list ships with the SDK in `src/core-entity-types.json`, generated from the server schema: `JUDGEMENT`, `EXPLANATION`, `PROMPT`, `USER_PROMPT`, `RESPONSE`, `RESPONSE_EVALUATION`, `RUBRIC`, `RUBRICS_GROUP`, `DIALOG`, `DIALOG_STEP`, `DIALOG_EVALUATION`, `SHORT_ANSWER`, `FEEDBACK`, `CONTEXT`, `IMAGE`, `ANNOTATION`, `SINGLE_LABEL`, `MULTI_LABEL`, `VIDEO`, `DOCUMENT`, `GOLDEN_SET`, `LOGS`, `SOLUTION`, `CODE`, `METADATA`, `AUDIO`, `AGENT_TRAJECTORY`, `MCP_SERVER`, `CONTAINER`, `CUSTOM`.
|
|
105
|
-
- An output entity of type `SINGLE_LABEL` or `MULTI_LABEL` needs `allowedLabels` with at least two entries.
|
|
106
|
-
- Every label `value` must be snake_case (`first_video`, not `firstVideo` or `First Video`).
|
|
107
|
-
|
|
108
|
-
A violation is thrown as `PipelineGraphValidationError`, with one issue per offending path, as soon as the pipeline source is loaded — so `toloka check`, `toloka plan`, `toloka apply` and `toloka validate` all fail on it locally before any platform request.
|
|
109
|
-
|
|
110
|
-
The following task is legitimately dynamic because the labeler can draw one independent box for every visible face:
|
|
111
|
-
|
|
112
|
-
```ts
|
|
113
|
-
import { generation } from "@toloka-platform/sdk";
|
|
114
|
-
|
|
115
|
-
export const annotateFaces = generation("annotate_faces", {
|
|
116
|
-
about: { description: "Draw a box around every visible face.", projectType: "general" },
|
|
117
|
-
publicName: "Face annotation",
|
|
118
|
-
instruction: "Draw one tight rectangular box around every visible human face.",
|
|
119
|
-
entities: {
|
|
120
|
-
input: [{ field: imageUrl, entityType: "IMAGE", description: "Public URL of the image." }],
|
|
121
|
-
output: [
|
|
122
|
-
{
|
|
123
|
-
field: draftFaces,
|
|
124
|
-
entityType: "ANNOTATION",
|
|
125
|
-
jsonPath: "$.draft_faces[*]",
|
|
126
|
-
description: "One tight box per visible face.",
|
|
127
|
-
dynamic: true,
|
|
128
|
-
maxEntities: 50,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
},
|
|
132
|
-
qualityCriteria: [
|
|
133
|
-
{
|
|
134
|
-
id: "123e4567-e89b-42d3-a456-426614174000",
|
|
135
|
-
qualityElement: "Completeness",
|
|
136
|
-
thresholds: { pass: "Every visible face is boxed.", fail: "A visible face is missing." },
|
|
137
|
-
targetEntity: draftFaces,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
ui: {
|
|
141
|
-
code: "<Field.ImageAnnotation path={'draft_faces'} image={actions.get('image_url', '')} tools={['rectangle']} />",
|
|
142
|
-
data: '{"image_url":"https://example.com/face.jpg"}',
|
|
143
|
-
preprocess: "return {}",
|
|
144
|
-
postprocess: "return {};",
|
|
145
|
-
constants: "{}",
|
|
146
|
-
},
|
|
147
|
-
audienceAndPricing: {
|
|
148
|
-
audienceType: "human",
|
|
149
|
-
verifiedExperts: true,
|
|
150
|
-
audience: {
|
|
151
|
-
languages: { type: "and", values: [{ value: "English" }] },
|
|
152
|
-
specializations: { type: "and", values: [] },
|
|
153
|
-
countries: { type: "or", values: [] },
|
|
154
|
-
},
|
|
155
|
-
pricePerTask: 0.2,
|
|
156
|
-
timeForTask: 60,
|
|
157
|
-
perExpertCapEnabled: false,
|
|
158
|
-
perExpertCapValue: 1,
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
To require a specialization, add `{ value, qualificationId }` entries to `audience.specializations.values`. Both come from the platform catalog — `toloka audience specialization list` — where `NAME` is the `value`, `ID` is the `qualificationId`, and `EXPERTS` tells you how large the pool is. Specializations require `verifiedExperts: true`.
|
|
164
|
-
|
|
165
|
-
Test the interface locally before applying it. The SDK's Vitest fixture renders this exact `ui` block in Chromium, interacts with Fields by `path`, runs postprocess, validates output entities, and saves screenshots. See [Test pipelines locally](./testing.md).
|
|
166
|
-
|
|
167
|
-
### quorum
|
|
168
|
-
|
|
169
|
-
The same item labeled by N independent people, with disagreement preserved. Every output field becomes a top-level array with one element per labeler.
|
|
170
|
-
|
|
171
|
-
```ts
|
|
172
|
-
import { quorum } from "@toloka-platform/sdk";
|
|
173
|
-
|
|
174
|
-
export const ratePair = quorum("rate_pair", {
|
|
175
|
-
about: { name: "rate_pair" },
|
|
176
|
-
publicName: "Rate the pair",
|
|
177
|
-
overlap: 3,
|
|
178
|
-
entities: {
|
|
179
|
-
input: [{ field: pairUrl, entityType: "CONTEXT" }],
|
|
180
|
-
output: [
|
|
181
|
-
{
|
|
182
|
-
field: verdict,
|
|
183
|
-
entityType: "SINGLE_LABEL",
|
|
184
|
-
allowedLabels: [
|
|
185
|
-
{ label: "First video", value: "first" },
|
|
186
|
-
{ label: "Second video", value: "second" },
|
|
187
|
-
],
|
|
188
|
-
},
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
qualityCriteria: [],
|
|
192
|
-
instruction: "Pick the better of the two videos.",
|
|
193
|
-
ui: {
|
|
194
|
-
code: "<View.Card><Field.RadioGroup path={'verdict'} label={'Better video'} options={[{ label: 'First video', value: 'first' }, { label: 'Second video', value: 'second' }]} validation={[{ required: true }]} /></View.Card>",
|
|
195
|
-
data: "{}",
|
|
196
|
-
preprocess: "return {}",
|
|
197
|
-
postprocess: "return {};",
|
|
198
|
-
constants: "{}",
|
|
199
|
-
},
|
|
200
|
-
onboarding: {
|
|
201
|
-
enabled: true,
|
|
202
|
-
steps: [
|
|
203
|
-
{
|
|
204
|
-
id: "step-1",
|
|
205
|
-
blocks: [
|
|
206
|
-
{
|
|
207
|
-
id: "block-1",
|
|
208
|
-
type: "text",
|
|
209
|
-
content: [{ type: "markdown", value: "Watch both videos." }],
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
info: {
|
|
215
|
-
estimatedTime: "1 minute",
|
|
216
|
-
role: "Rater",
|
|
217
|
-
goal: "Rate the pair",
|
|
218
|
-
successCriteria: "Submit a rating",
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
A quorum node **requires** an `onboarding` block: the Training course is part of the node, not an optional extra. The platform additionally requires at least three steps with at least one quiz block before the pipeline can deploy, which the type system does not enforce — a one-step placeholder compiles and applies but will not launch.
|
|
225
|
-
|
|
226
|
-
### match
|
|
227
|
-
|
|
228
|
-
Predicate routing. Conditions are evaluated in declaration order. A condition's `logic` defaults to `'and'`, so every predicate must match; set `logic: 'or'` when any one predicate should match. `match()` writes the default into the graph, as the platform stores it, so `toloka plan` does not report the condition as changed after an apply.
|
|
229
|
-
|
|
230
|
-
```ts
|
|
231
|
-
import { match } from "@toloka-platform/sdk";
|
|
232
|
-
|
|
233
|
-
export const routeDisputed = match("route_disputed", {
|
|
234
|
-
about: { name: "route_disputed" },
|
|
235
|
-
conditions: [
|
|
236
|
-
{
|
|
237
|
-
name: "is_disputed",
|
|
238
|
-
predicates: [{ field: verdict, jsonPath: "$", operator: "text_eq", value: "disputed" }],
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
input: [{ field: verdict, optional: false }],
|
|
242
|
-
});
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
Each condition name must be unique within the Match node and contain 2–32 characters. Start with a lowercase letter, use only lowercase letters, digits, and underscores, and end with a letter or digit. `match()` rejects invalid or duplicate names locally before any platform request.
|
|
246
|
-
|
|
247
|
-
## Connect ports
|
|
248
|
-
|
|
249
|
-
`connect(from, to)` is the only way to create an edge. Ports are typed, so a wrong direction is a compile error.
|
|
250
|
-
|
|
251
|
-
| node | ports |
|
|
252
|
-
| ------------ | ------------------------------------------------- |
|
|
253
|
-
| `root` | `started` (out), `completed` (in) |
|
|
254
|
-
| `code` | `input` (in), `output` (out) |
|
|
255
|
-
| `generation` | `input` (in), `output` (out) |
|
|
256
|
-
| `quorum` | `input` (in), `output` (out) |
|
|
257
|
-
| `match` | `input` (in), `matched(i)` (out), `default` (out) |
|
|
258
|
-
|
|
259
|
-
```ts
|
|
260
|
-
connections: [
|
|
261
|
-
connect(collection.started, annotateFaces.input),
|
|
262
|
-
connect(annotateFaces.output, orderFaces.input),
|
|
263
|
-
connect(orderFaces.output, collection.completed),
|
|
264
|
-
connect(routeDisputed.matched(0), adjudicate.input),
|
|
265
|
-
connect(routeDisputed.default, merge.input),
|
|
266
|
-
];
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
The graph is acyclic. Review, retry, redo, Training, Exam, appeal, and payment retry are **settings inside the owning human-work node**, not extra nodes — there is no loop to draw.
|
|
270
|
-
|
|
271
|
-
## Assemble the project
|
|
272
|
-
|
|
273
|
-
```ts
|
|
274
|
-
import { connect, definePipeline } from "@toloka-platform/sdk";
|
|
275
|
-
|
|
276
|
-
export default definePipeline({
|
|
277
|
-
dataset: "cat-images",
|
|
278
|
-
fields: [imageUrl, annotations],
|
|
279
|
-
nodes: [collection, annotateCats],
|
|
280
|
-
connections: [
|
|
281
|
-
connect(collection.started, annotateCats.input),
|
|
282
|
-
connect(annotateCats.output, collection.completed),
|
|
283
|
-
],
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
`dataset` names the source dataset. `apply` creates it if it is absent, binds it to the pipeline, and records the resolved id in `toloka.json`.
|
|
288
|
-
|
|
289
|
-
Leave `dataset` out for a pipeline that has no dataset yet, such as one created from a template in the platform UI. `plan` and `apply` then edit its graph without binding a dataset, and `toloka import` writes such a pipeline the same way. The pipeline cannot run until it has a dataset: add `dataset` to its source later, or bind one in the platform UI and import again. Apply never removes a bound dataset, so it refuses to apply a source that drops `dataset` from a pipeline that has one.
|
|
290
|
-
|
|
291
|
-
Each `pipelines/<name>/pipeline.ts` is one pipeline. A project can hold several; each names its own dataset, and a dataset can be shared.
|
|
292
|
-
|
|
293
|
-
Because assembly is ordinary TypeScript, a family of near-identical pipelines can be produced by a function that returns `definePipeline(...)`. The `connections` array stays literal and readable, which is the property worth protecting: topology should never be something a reader has to infer from a helper's implementation.
|
|
294
|
-
|
|
295
|
-
## Identity
|
|
296
|
-
|
|
297
|
-
Constructors mint deterministic ids from the node name, so authored source needs no ids at all.
|
|
298
|
-
|
|
299
|
-
`toloka import` emits explicit `{ id }` options for nodes and fields that already exist on the platform. **Preserve them.** They are how reconciliation recognizes the same resource instead of replacing it.
|
|
300
|
-
|
|
301
|
-
Never hand-write `fp_…`, `ds.…`, `pl.…`, or `pp.…` values into settings, and never author a `layout` block: layout is not authored, existing nodes keep their canvas position, and the server places new nodes one column after their rightmost input and moves End to the right when they reach it.
|
|
302
|
-
|
|
303
|
-
## Validate
|
|
304
|
-
|
|
305
|
-
```sh
|
|
306
|
-
toloka check
|
|
307
|
-
toloka validate
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
`definePipeline` and the typed ports add local declaration and connection invariants. `toloka check` also reports, as warnings, the platform rules that would reject a node connected to the root: node names, unique quality elements, quality-criterion thresholds, the minimum task and Human QA review times, a positive price per task, a media upload component on a human `data_collection` node, and the limits of an enabled exam. `toloka apply` refuses to write a new or changed pipeline that breaks them, before any platform write; an unchanged pipeline, such as a draft saved in the platform UI, does not block apply of the others. `toloka validate` posts each bound pipeline to `POST /pipelines/:pipelineId/graph/validate` and reports platform spec errors, warnings, and the latest matching check jobs. It does not write the graph.
|
|
311
|
-
|
|
312
|
-
A pipeline that is not on the platform yet is skipped until `toloka apply` creates it. The published JSON contract is still available as `validate(graph)` for importer and fixture tests; that helper also runs the local entity checks described under [generation](#generation) and makes no network call.
|
|
313
|
-
|
|
314
|
-
A successful validate is necessary, not sufficient for launch. Gates outside the graph contract — a Training course that is enabled but unbuilt, a task UI that was never validated — can still block deployment. See [limitations](./limitations.md).
|
|
315
|
-
|
|
316
|
-
## Next
|
|
317
|
-
|
|
318
|
-
- [Nodes](./nodes.md) — choosing a node, and the price range it must stay within
|
|
319
|
-
- [Datasets](./datasets.md) — columns and immutability
|
|
320
|
-
- [CLI](./cli.md) — the reconcile loop
|
package/docs/cli-v2.md
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
# CLI v2: project as the root
|
|
2
|
-
|
|
3
|
-
How `toloka` should work in the next version. Beta remains a clean cutover rather than a compatibility layer.
|
|
4
|
-
|
|
5
|
-
The platform object is a **project** (`pp.…`, today's pipeline project). Windmill calls the same role a workspace. PostHog calls it a project. We keep **project** so the CLI matches the API and the console.
|
|
6
|
-
|
|
7
|
-
## Why the current CLI is wrong
|
|
8
|
-
|
|
9
|
-
Today the checkout is a pipeline tree that happens to mention a project.
|
|
10
|
-
|
|
11
|
-
- A directory is a project root if it has `toloka.json` **or** a `pipelines/` folder. No pipelines, no root.
|
|
12
|
-
- `init` writes agent skills before a project exists. It writes `toloka.json` only from an explicit `--project-id`, `TOLOKA_PROJECT_ID`, or an existing checkout; it never binds a new checkout from the machine registry.
|
|
13
|
-
- A checkout attaches when `project create` or `import` writes `toloka.json`, or when `init` receives explicit project identity.
|
|
14
|
-
- `run`, `status`, `runs`, and `cost` pick a pipeline from `toloka.json`. Zero pipelines is an error. Several pipelines opens a picker. The command names pretend there is "the" pipeline.
|
|
15
|
-
- `status` means "latest run of some pipeline", not "this project".
|
|
16
|
-
|
|
17
|
-
That design cannot grow. Datasets, secrets, files, checks, and anything we add later are project children. Some projects will never have a pipeline. Searching for a pipeline before those commands can run is the bug.
|
|
18
|
-
|
|
19
|
-
Windmill and PostHog both invert this: pick the project (workspace), then operate on resources inside it. A Windmill workspace with no flows is still a workspace. A PostHog project with no dashboards is still a project.
|
|
20
|
-
|
|
21
|
-
## Two layers of context
|
|
22
|
-
|
|
23
|
-
### Machine auth
|
|
24
|
-
|
|
25
|
-
`~/.config/toloka/credentials.json` stays the home for the API key and base URL. `login` / `logout` / `whoami` do not need a project.
|
|
26
|
-
|
|
27
|
-
The file also becomes a small local registry, Windmill-style:
|
|
28
|
-
|
|
29
|
-
```json
|
|
30
|
-
{
|
|
31
|
-
"baseUrl": "https://platform.toloka.ai",
|
|
32
|
-
"apiKey": "…",
|
|
33
|
-
"current": "cat-labeling",
|
|
34
|
-
"projects": {
|
|
35
|
-
"cat-labeling": { "id": "pp.019f…", "name": "Cat labeling" },
|
|
36
|
-
"staging": { "id": "pp.019e…", "name": "Staging" }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`current` is a local alias, not a platform field. Same key, several projects, switch without re-login. CI never uses this file.
|
|
42
|
-
|
|
43
|
-
### Checkout
|
|
44
|
-
|
|
45
|
-
A directory becomes a project checkout when it contains `toloka.json`. That is the only root marker. `pipelines/` alone is not a project.
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"projectId": "pp.019f…",
|
|
50
|
-
"pipelines": {},
|
|
51
|
-
"datasets": {}
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Empty `pipelines` and `datasets` are valid. Bindings are a cache of live ids after import/apply, not a requirement to run commands. Do not hand-edit this file.
|
|
56
|
-
|
|
57
|
-
A checkout can later grow other folders (`datasets/`, `files/`, whatever we author). None of them define the root.
|
|
58
|
-
|
|
59
|
-
## How a command finds its project
|
|
60
|
-
|
|
61
|
-
Highest wins:
|
|
62
|
-
|
|
63
|
-
1. `--project-id`
|
|
64
|
-
2. `TOLOKA_PROJECT_ID` (the legacy `POTATO_*` names are still read for one preview cycle with a deprecation warning)
|
|
65
|
-
3. `toloka.json` in the discovered checkout (walk up from cwd, or `--source-root`)
|
|
66
|
-
4. `current` in the machine registry
|
|
67
|
-
5. Fail: `No project selected. Run toloka project create for a new project, toloka project add for an existing project, or cd into a checkout.`
|
|
68
|
-
|
|
69
|
-
A checkout wins over the machine default so a repo is self-describing for agents and CI. Flags and env still win over both, same as PostHog (`POSTHOG_CLI_PROJECT_ID`) and Windmill (`--workspace`).
|
|
70
|
-
|
|
71
|
-
`whoami` prints the resolved project and which layer supplied it.
|
|
72
|
-
|
|
73
|
-
## Setting up a project
|
|
74
|
-
|
|
75
|
-
This is the Windmill `workspace add` / PostHog "this is project 12345" step. Every later command assumes it already happened.
|
|
76
|
-
|
|
77
|
-
```sh
|
|
78
|
-
toloka login
|
|
79
|
-
toloka project list # remote projects this key can see
|
|
80
|
-
toloka project add cat-labeling pp.019f… # register + select
|
|
81
|
-
toloka project switch cat-labeling
|
|
82
|
-
toloka project current # alias of the project line in whoami
|
|
83
|
-
toloka project url # print the selected project's UI URL
|
|
84
|
-
toloka project remove cat-labeling # local unbind only
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
`project add` with no arguments prompts for alias and id, like `wmill workspace add`. The new alias becomes `current`.
|
|
88
|
-
|
|
89
|
-
Create a live project and bind it in one step. The delivery order follows the owning team, not the account (`toloka whoami` marks internal teams `(internal)` on its `Teams:` line): a project in an internal team must carry an active id from `toloka delivery-order list`, and a project in an external team must not carry one, even when the account is internal:
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
toloka project create cat-labeling --team-id <teamId>
|
|
93
|
-
toloka project create cat-labeling --team-id <teamId> --delivery-order-id <orderId>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
`POST /projects` requires `teamId`. `GET /me` lists the caller's teams with their write access, so `--team-id` is optional when the account has exactly one writable team; with several, the CLI refuses and names them.
|
|
97
|
-
|
|
98
|
-
`project create` writes the machine alias, sets `current`, and if cwd has no `toloka.json`, writes one.
|
|
99
|
-
|
|
100
|
-
UI links follow the resource-first shape `toloka <resource> url`. `project url` is available now; future pipeline, dataset, and other entity links belong under their existing resource groups. Every `url` command prints exactly one URL with no label to stdout. Opening a browser, if added, must be an explicit `--web` option rather than the default.
|
|
101
|
-
|
|
102
|
-
### init
|
|
103
|
-
|
|
104
|
-
`init` sets up **this directory** for an agent. A selected platform project is optional.
|
|
105
|
-
|
|
106
|
-
```sh
|
|
107
|
-
toloka init
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
It writes the agent entry points without calling the platform. It never binds a new checkout from the machine registry. With an explicit `--project-id` or project-id environment variable, it also writes `toloka.json` with empty bindings. It does not require `pipelines/`; `project create` creates the live project.
|
|
111
|
-
|
|
112
|
-
`import` stays the "pull an existing live project into this checkout" path. After v2 it uses the selected project when the id is omitted:
|
|
113
|
-
|
|
114
|
-
```sh
|
|
115
|
-
toloka import # pull the current project
|
|
116
|
-
toloka import pp.019f… # pull that id, then bind it
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Commands after a project is selected
|
|
120
|
-
|
|
121
|
-
Resource commands never search the disk for a pipeline first. They load the project, then the named child if the verb needs one.
|
|
122
|
-
|
|
123
|
-
| Command | Scope | Pipeline required? |
|
|
124
|
-
| ----------------------------- | ----------------------------- | ------------------ |
|
|
125
|
-
| `project url` | project UI URL | no |
|
|
126
|
-
| `plan` / `apply` / `validate` | whole project | no |
|
|
127
|
-
| `secret set` | project | no |
|
|
128
|
-
| `dataset list` | project | no |
|
|
129
|
-
| `dataset create <name>` | project | no |
|
|
130
|
-
| `dataset fields <name>` | named dataset in this project | no |
|
|
131
|
-
| `dataset load <name>` | named dataset in this project | no |
|
|
132
|
-
| `dataset upload <name>` | named dataset in this project | no |
|
|
133
|
-
| `status` | project | no |
|
|
134
|
-
| `pipeline list` | project | no |
|
|
135
|
-
| `pipeline run <name>` | one pipeline | yes |
|
|
136
|
-
| `pipeline status <name>` | one pipeline | yes |
|
|
137
|
-
| `pipeline runs <name>` | one pipeline | yes |
|
|
138
|
-
| `pipeline cost <name>` | one pipeline | yes |
|
|
139
|
-
| `pipeline cancel <runId>` | run id | run id only |
|
|
140
|
-
| `pipeline results <runId>` | run id | run id only |
|
|
141
|
-
|
|
142
|
-
`status` (no prefix) is project health: id, name, team, how many pipelines/datasets/secrets, and pending source changes (`Source has no pending changes.`). Unbound live resources are not pending. It is valid on an empty project.
|
|
143
|
-
|
|
144
|
-
Pipeline verbs move under `pipeline` and take an explicit name. No implicit "the only pipeline". No interactive picker as the default for scripts. A TTY may still offer a picker if the name is omitted **and** the project has more than one pipeline; non-TTY still errors with the list.
|
|
145
|
-
|
|
146
|
-
A project with zero pipelines:
|
|
147
|
-
|
|
148
|
-
```
|
|
149
|
-
$ toloka pipeline run
|
|
150
|
-
This project has no pipelines.
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
`plan` / `apply` on that same project: `No changes.`
|
|
154
|
-
|
|
155
|
-
## Datasets: catalog, not the table
|
|
156
|
-
|
|
157
|
-
A live dataset can be huge. The checkout never holds the rows unless you ask.
|
|
158
|
-
|
|
159
|
-
What is always local:
|
|
160
|
-
|
|
161
|
-
- name and platform id in `toloka.json`
|
|
162
|
-
- field names and JSON schemas (authored, or pulled as declarations)
|
|
163
|
-
|
|
164
|
-
What stays on the platform until you pull it:
|
|
165
|
-
|
|
166
|
-
- every item
|
|
167
|
-
- upload history
|
|
168
|
-
- anything a pipeline writes back
|
|
169
|
-
|
|
170
|
-
`import`, `init`, `plan`, `apply`, `status`, and `dataset list` talk to the catalog only: names, ids, field schemas, item counts if the API returns them. They do not page items and they do not write a data file. `apply` may create an empty dataset and missing columns. It never copies rows down or up.
|
|
171
|
-
|
|
172
|
-
Loading rows is a separate, explicit command:
|
|
173
|
-
|
|
174
|
-
```sh
|
|
175
|
-
toloka dataset list
|
|
176
|
-
toloka dataset fields images
|
|
177
|
-
toloka dataset load images --out ./data/images.jsonl
|
|
178
|
-
toloka dataset load images --limit 100 --out ./data/images.sample.jsonl
|
|
179
|
-
toloka dataset upload images ./new.jsonl
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
`load` starts a platform export, waits (default 60s; pass `--timeout`), downloads a JSON array, and writes JSONL to `--out`. Omit `--limit` only when you mean the whole table. `--limit` slices after that download; it still waits for the full export. There is no implicit load on `import` or `init`. A 10-million-row dataset and an empty one look the same in the checkout until you run `load`.
|
|
183
|
-
|
|
184
|
-
Same rule as today, restated for a project-first CLI: source describes shape; the platform stores data; you pull or push rows when you want them on disk.
|
|
185
|
-
|
|
186
|
-
## What we stop doing
|
|
187
|
-
|
|
188
|
-
- Discovering a root from `pipelines/`.
|
|
189
|
-
- Making `run` / `status` / `runs` / `cost` top-level commands that hunt a pipeline.
|
|
190
|
-
- Requiring a pipeline binding before the CLI will talk to a project.
|
|
191
|
-
- Using "pipeline project" in user-facing CLI text. The noun is project.
|
|
192
|
-
|
|
193
|
-
## Later entities
|
|
194
|
-
|
|
195
|
-
New resources attach to the same project the same way Windmill attaches `script` / `flow` / `app` to a workspace, and the same way PostHog attaches dashboards and flags to a project.
|
|
196
|
-
|
|
197
|
-
```
|
|
198
|
-
toloka <resource> list
|
|
199
|
-
toloka <resource> get <name>
|
|
200
|
-
toloka <resource> …
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Do not add those groups until the resource exists. The rule is already fixed: the project is in context; the command names the child.
|
|
204
|
-
|
|
205
|
-
## Mapping from v1
|
|
206
|
-
|
|
207
|
-
| v1 | v2 |
|
|
208
|
-
| --------------------------------------------- | ------------------------------------------------------------------ |
|
|
209
|
-
| `toloka init` (skills only) | `toloka init` (checkout + skills) |
|
|
210
|
-
| `toloka import <id>` | `toloka project add` then `toloka import`, or `toloka import <id>` |
|
|
211
|
-
| `toloka plan --project-id` | `toloka project add` / checkout, then `toloka plan` |
|
|
212
|
-
| `toloka run [pipeline]` | `toloka pipeline run <name>` |
|
|
213
|
-
| `toloka status [pipeline]` | `toloka status` (project) or `toloka pipeline status <name>` |
|
|
214
|
-
| `toloka runs` / `cost` / `cancel` / `results` | `toloka pipeline …` |
|
|
215
|
-
| root = `toloka.json` or `pipelines/` | root = `toloka.json` only |
|
|
216
|
-
|
|
217
|
-
No shims. Beta callers update.
|
|
218
|
-
|
|
219
|
-
## Out of scope
|
|
220
|
-
|
|
221
|
-
- Browser login, key rotation, revoke-on-logout.
|
|
222
|
-
- Multi-project apply from one checkout (one `toloka.json`, one `projectId`).
|
|
223
|
-
- Deletes (`destroy`).
|
|
224
|
-
- Authoring a project that is not a platform project. If we ever have a different project type, it is still selected the same way; only the child commands change.
|