Skip to content

Commit 6d73126

Browse files
depppMichael
andauthored
feat: Add interface pull and draft sync support (#811)
Co-authored-by: Michael <michael@Michaels-Mac-Studio.local>
1 parent 6b85a14 commit 6d73126

3 files changed

Lines changed: 829 additions & 62 deletions

File tree

interface-cli.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,23 @@ cd sentiment-interface
3939
Validate the interface statically and run its browser scenario:
4040

4141
```bash
42-
label-studio-sdk interface validate Screen.jsx --scenario scenarios.js
42+
label-studio-sdk interface validate .
4343
```
4444

4545
Open the live playground and sync local file changes as you edit:
4646

4747
```bash
48-
label-studio-sdk interface preview Screen.jsx --task task.json
48+
label-studio-sdk interface preview .
4949
```
5050

51-
Create or update a saved interface in Label Studio:
51+
Pull an existing interface and continue locally:
52+
53+
```bash
54+
label-studio-sdk interface pull --id 73 ./existing-interface
55+
cd existing-interface
56+
```
57+
58+
Create or update a saved interface in Label Studio. By default, this creates a local draft version:
5259

5360
```bash
5461
label-studio-sdk interface sync Screen.jsx \
@@ -59,7 +66,7 @@ label-studio-sdk interface sync Screen.jsx \
5966
Create a project that uses the synced interface:
6067

6168
```bash
62-
label-studio-sdk interface start Screen.jsx \
69+
label-studio-sdk interface start . \
6370
--project-title "Sentiment Review Project" \
6471
--workspace 3
6572
```
@@ -137,6 +144,7 @@ Without `--force`, the command refuses to overwrite existing scaffold files.
137144
Run offline validation.
138145

139146
```bash
147+
label-studio-sdk interface validate ./my-interface
140148
label-studio-sdk interface validate Screen.jsx
141149
label-studio-sdk interface validate Screen.jsx --scenario scenarios.js
142150
label-studio-sdk interface validate Screen.jsx --json
@@ -190,20 +198,22 @@ The scenario context includes:
190198
Open the Label Studio interface playground and live-sync source changes.
191199

192200
```bash
201+
label-studio-sdk interface preview ./my-interface
193202
label-studio-sdk interface preview Screen.jsx --task task.json
194203
label-studio-sdk interface preview Screen.jsx --task task.json --no-open
195204
label-studio-sdk interface preview Screen.jsx --lse-url http://localhost:8080
196205
```
197206

198-
`preview` starts a local file watcher. On each save, it pushes the current source to the playground session. The initial push can include task data from `--task`; later pushes update only the code.
207+
`preview` starts a local file watcher. Pass a directory to use the scaffolded bundle defaults: `Screen.jsx` for the interface and `task.json` or `sample.json` for example task data. On each save, it pushes the current source to the playground session. The initial push can include task data from `--task` or the bundle's task-data file; later source saves update the code, and task-data saves update the task.
199208

200209
### `sync`
201210

202-
Create or update a saved interface.
211+
Create or update a saved interface. `sync` creates an unpublished local draft by default so you can review it in Label Studio before publishing.
203212

204213
```bash
205214
label-studio-sdk interface sync Screen.jsx --title "Review UI"
206215
label-studio-sdk interface sync Screen.jsx --id 12 --message "Tighten parser"
216+
label-studio-sdk interface sync Screen.jsx --id 12 --publish
207217
label-studio-sdk interface sync Screen.jsx --workspace-title "Data Science"
208218
label-studio-sdk interface sync Screen.jsx --dry-run
209219
```
@@ -213,6 +223,7 @@ By default, `sync`:
213223
- validates and compiles the file
214224
- creates a new interface when no id or sidecar entry exists
215225
- updates the existing interface when `--id` or a sidecar entry is available
226+
- appends a new draft version without replacing existing versions
216227
- skips upload when the local source hash has not changed
217228
- writes a sidecar file next to the JSX source
218229

@@ -222,11 +233,24 @@ Useful options:
222233
- `--title`: set the interface title.
223234
- `--workspace`: use a workspace id for newly created interfaces.
224235
- `--workspace-title`: resolve a workspace by exact title.
236+
- `--publish`: create a published version instead of a local draft.
225237
- `--no-validate`: skip the validation gate, while still requiring successful compilation.
226238
- `--force`: upload even when hashes match.
227239
- `--dry-run`: print the planned action without writing to the server.
228240
- `--message`: store a history message for the synced version.
229241

242+
### `pull`
243+
244+
Pull a saved interface into a local bundle.
245+
246+
```bash
247+
label-studio-sdk interface pull --id 12 ./review-ui
248+
label-studio-sdk interface pull --id 12 --version 4 ./review-ui
249+
label-studio-sdk interface pull --id 12 ./review-ui --force
250+
```
251+
252+
`pull` writes `Screen.jsx`, `task.json`, optional `params.json` defaults from `paramsSchema`, and a sidecar file. Without `--version`, it pulls the latest version, including local drafts.
253+
230254
### `start`
231255

232256
Sync the interface, create a project that uses it, and open the project data page.
@@ -237,7 +261,8 @@ label-studio-sdk interface start Screen.jsx \
237261
--params params.json
238262
```
239263

240-
`--params` must point to a JSON file. The JSON is saved as the project interface params and is passed into the component as `params`.
264+
`start` syncs a published version so the new project can safely reference it. `--params` must point to a JSON file. The JSON is saved as the project interface params and is passed into the component as `params`.
265+
When you pass a directory, `start` uses `Screen.jsx` for the interface and `params.json` for project params when present.
241266

242267
Useful options:
243268

@@ -274,7 +299,7 @@ The command checks Node.js, npm, the API token, validator dependency installatio
274299

275300
## Sidecar Files
276301

277-
After a successful `sync`, the CLI writes a sidecar next to the source file:
302+
After a successful `sync` or `pull`, the CLI writes a sidecar next to the source file:
278303

279304
```text
280305
Screen.jsx.ls-interface.json
@@ -289,7 +314,7 @@ The sidecar is keyed by Label Studio base URL and stores:
289314
- last pushed source hash
290315
- last pushed timestamp
291316

292-
This lets future `sync`, `start`, and `open` commands find the saved interface without requiring `--id`.
317+
This lets future `sync`, `start`, and `open` commands find the saved interface without requiring `--id`. A sidecar source version can point at a draft version until you publish it.
293318

294319
## Auth and URL Resolution
295320

0 commit comments

Comments
 (0)