dsh-runnpu 0.1.0
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/LICENSE +21 -0
- package/README.md +16 -0
- package/compute-mode/preset/agent.cordis.yml +368 -0
- package/compute-mode/preset/preset.yml +3 -0
- package/compute-mode/preset/skills/runnpu/SKILL.md +233 -0
- package/compute-mode/preset/skills/runnpu/VENDOR.txt +11 -0
- package/compute-mode/preset/skills/runnpu/examples/01-dev-environment.sh +26 -0
- package/compute-mode/preset/skills/runnpu/examples/02-training-job.sh +26 -0
- package/compute-mode/preset/skills/runnpu/examples/03-inference-service.sh +24 -0
- package/compute-mode/preset/skills/runnpu/examples/04-fractional-vnpu.sh +14 -0
- package/compute-mode/preset/skills/runnpu/examples/05-troubleshoot.sh +17 -0
- package/compute-mode/preset/skills/runnpu/references/admin.md +60 -0
- package/compute-mode/preset/skills/runnpu/references/data-sources.md +35 -0
- package/compute-mode/preset/skills/runnpu/references/templates-assets.md +61 -0
- package/compute-mode/preset/skills/runnpu/references/training-runs.md +56 -0
- package/compute-mode/preset/skills/runnpu/references/troubleshooting.md +75 -0
- package/compute-mode/preset/skills/runnpu/references/workload-types.md +47 -0
- package/cordis.patch.yml +80 -0
- package/dist/chunk-JLZMOSQC.mjs +1 -0
- package/dist/chunk-JUBIWGKW.mjs +4 -0
- package/dist/chunk-JZXLCA2E.mjs +1 -0
- package/dist/chunk-KQOFBYGE.mjs +9 -0
- package/dist/chunk-XMZG2NP7.mjs +2 -0
- package/dist/chunk-XQPU3AJN.mjs +1 -0
- package/dist/chunk-YKASEMP3.mjs +1 -0
- package/dist/chunk-YPL4VUYF.mjs +4 -0
- package/dist/compute-node.mjs +1 -0
- package/dist/compute-tools.mjs +41 -0
- package/dist/connectors.mjs +3 -0
- package/dist/dsh-runnpu.mjs +43 -0
- package/dist/json.mjs +1 -0
- package/dist/pins.mjs +1 -0
- package/dist/series.mjs +1 -0
- package/dist/training-node.mjs +2 -0
- package/dist/training-tools.mjs +30 -0
- package/dist/ui-host.mjs +1 -0
- package/lib/client.js +189 -0
- package/package.json +78 -0
- package/training-mode/preset/agent.cordis.yml +343 -0
- package/training-mode/preset/preset.yml +3 -0
- package/training-mode/preset/skills/runnpu/SKILL.md +233 -0
- package/training-mode/preset/skills/runnpu/VENDOR.txt +11 -0
- package/training-mode/preset/skills/runnpu/examples/01-dev-environment.sh +26 -0
- package/training-mode/preset/skills/runnpu/examples/02-training-job.sh +26 -0
- package/training-mode/preset/skills/runnpu/examples/03-inference-service.sh +24 -0
- package/training-mode/preset/skills/runnpu/examples/04-fractional-vnpu.sh +14 -0
- package/training-mode/preset/skills/runnpu/examples/05-troubleshoot.sh +17 -0
- package/training-mode/preset/skills/runnpu/references/admin.md +60 -0
- package/training-mode/preset/skills/runnpu/references/data-sources.md +35 -0
- package/training-mode/preset/skills/runnpu/references/templates-assets.md +61 -0
- package/training-mode/preset/skills/runnpu/references/training-runs.md +56 -0
- package/training-mode/preset/skills/runnpu/references/troubleshooting.md +75 -0
- package/training-mode/preset/skills/runnpu/references/workload-types.md +47 -0
- package/training-mode/preset/skills/swanlab-skill/LICENSE +21 -0
- package/training-mode/preset/skills/swanlab-skill/SKILL.md +163 -0
- package/training-mode/preset/skills/swanlab-skill/VENDOR.txt +9 -0
- package/training-mode/preset/skills/swanlab-skill/references/ANALYSIS_GUIDE.md +83 -0
- package/training-mode/preset/skills/swanlab-skill/references/CLI_REFERENCE.md +510 -0
- package/training-mode/preset/skills/swanlab-skill/references/SDK_QUICKSTART.md +341 -0
- package/training-mode/preset/skills/swanlab-skill/references/SWANLAB_CONCEPTS.md +523 -0
- package/training-mode/preset/skills/swanlab-skill/scripts/plot_metrics.py +353 -0
- package/training-mode/preset/skills/swanlab-skill/scripts/runs_benchmark.py +550 -0
- package/training-mode/preset/skills/training-research/SKILL.md +33 -0
- package/training-mode/preset/skills/training-research/references/pipeline.md +45 -0
- package/training-mode/preset/skills/training-research/references/research.md +76 -0
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
# SwanLab CLI Reference (`swanlab api`)
|
|
2
|
+
|
|
3
|
+
Complete reference for all `swanlab api` CLI subcommands. All commands output JSON to stdout. Use `--save` to persist results to a file.
|
|
4
|
+
|
|
5
|
+
**Prerequisite**: The user must be logged in (`swanlab login`), or supply `--host` / `--api-key` explicitly.
|
|
6
|
+
|
|
7
|
+
Read `references/SWANLAB_CONCEPTS.md` when you need to understand the data model, entity hierarchy, or disambiguate user requests.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Version Applicability (SDK ≥ 0.9.0)
|
|
12
|
+
|
|
13
|
+
| Command | Applicability |
|
|
14
|
+
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `run series` | **Added in SDK `0.9.0`.** The recommended way to list an experiment's metric keys. |
|
|
16
|
+
| `run column` / `run columns` | **Deprecated since SDK `0.9.0` (multi-view version).** Not applicable to multi-view experiments — use `run series` instead. Only use these for legacy experiments on SDK `< 0.9.0`. |
|
|
17
|
+
| All other commands | No version restriction. |
|
|
18
|
+
|
|
19
|
+
When the installed SDK is `< 0.9.0`, `run series` does not exist — fall back to `run columns` for key discovery.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Common Options
|
|
24
|
+
|
|
25
|
+
Every command accepts these global authentication/override options:
|
|
26
|
+
|
|
27
|
+
| Option | Short | Type | Description |
|
|
28
|
+
| ----------- | ----- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| `--host` | `-h` | string | SwanLab server host URL. Defaults to the logged-in host. |
|
|
30
|
+
| `--api-key` | `-k` | string | API key for authentication. Defaults to the logged-in key. |
|
|
31
|
+
| `--save` | | flag | Save JSON output to a file in the current directory. Use `--save <filename>` for a custom name. When used bare, auto-generates `swanlab-YYYYMMDD_HHMMSS-xxxx.json`. |
|
|
32
|
+
|
|
33
|
+
> `--save` always writes to the **current working directory** (there is no output-dir option) — before a multi-command analysis session, `cd` into a scratch directory (or pass an explicit `--save path/to/file.json`) to avoid littering the project root.
|
|
34
|
+
|
|
35
|
+
## Path Convention
|
|
36
|
+
|
|
37
|
+
Several commands take a `PATH` argument. See `references/SWANLAB_CONCEPTS.md > Path Convention` for the full format and rules. In short:
|
|
38
|
+
|
|
39
|
+
- **Project path**: `username/project_name`
|
|
40
|
+
- **Experiment path**: `username/project_name/run_id`
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Commands Reference
|
|
45
|
+
|
|
46
|
+
### 1. User
|
|
47
|
+
|
|
48
|
+
#### `swanlab api user info`
|
|
49
|
+
|
|
50
|
+
Get the currently authenticated user's profile.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
swanlab api user info [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### 2. Workspace
|
|
59
|
+
|
|
60
|
+
#### `swanlab api workspace info USERNAME`
|
|
61
|
+
|
|
62
|
+
Get workspace details for a given username.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
swanlab api workspace info USERNAME [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Argument | Required | Description |
|
|
69
|
+
| ---------- | -------- | --------------------------------- |
|
|
70
|
+
| `USERNAME` | yes | The workspace username to look up |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### 3. Project
|
|
75
|
+
|
|
76
|
+
#### `swanlab api project info PATH`
|
|
77
|
+
|
|
78
|
+
Get project details by path.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
swanlab api project info PATH [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Argument | Required | Description |
|
|
85
|
+
| -------- | -------- | ---------------------------------------------- |
|
|
86
|
+
| `PATH` | yes | Project path in `username/project_name` format |
|
|
87
|
+
|
|
88
|
+
#### `swanlab api project list`
|
|
89
|
+
|
|
90
|
+
List projects under a workspace. Paginated by default.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
swanlab api project list [OPTIONS]
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Option | Short | Default | Description |
|
|
97
|
+
| ------------- | ----- | -------------- | -------------------------------------------------- |
|
|
98
|
+
| `--page_num` | `-n` | 1 | Page number (>= 1) |
|
|
99
|
+
| `--page_size` | `-s` | 20 | Page size. One of: 10, 12, 15, 20, 24, 27, 50, 100 |
|
|
100
|
+
| `--workspace` | | logged-in user | Workspace username to list projects from |
|
|
101
|
+
| `--all` | | false | Fetch all pages at once |
|
|
102
|
+
| `--save` | | off | Save output to file |
|
|
103
|
+
|
|
104
|
+
#### `swanlab api project create`
|
|
105
|
+
|
|
106
|
+
Create a new project.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
swanlab api project create -n NAME [OPTIONS]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Option | Short | Default | Description |
|
|
113
|
+
| --------------- | ----- | -------------- | ----------------------------------------------- |
|
|
114
|
+
| `--name` | `-n` | (required) | Project name. 1-100 chars, only `0-9a-zA-Z-_.+` |
|
|
115
|
+
| `--visibility` | `-v` | PRIVATE | `PUBLIC` or `PRIVATE` |
|
|
116
|
+
| `--description` | `-d` | none | Project description |
|
|
117
|
+
| `--workspace` | `-w` | logged-in user | Target workspace username |
|
|
118
|
+
| `--save` | | off | Save output to file |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### 4. Experiment (Run)
|
|
123
|
+
|
|
124
|
+
#### `swanlab api run info PATH`
|
|
125
|
+
|
|
126
|
+
Get experiment details. Returns the full run object — see `SWANLAB_CONCEPTS.md > Run Object Schema` for the response fields (`run_id`, `state`, `created_at` / `finished_at`, `profile`, etc.).
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
swanlab api run info PATH [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
| Argument | Required | Description |
|
|
133
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
134
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
135
|
+
|
|
136
|
+
#### `swanlab api run list PROJECT_PATH`
|
|
137
|
+
|
|
138
|
+
List experiments under a project. Paginated by default. Items use the run-object shape documented in `SWANLAB_CONCEPTS.md > Run Object Schema` — note every item embeds its full `profile`, so extract only the fields you need rather than dumping the raw JSON.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
swanlab api run list PROJECT_PATH [OPTIONS]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
| Argument | Required | Description |
|
|
145
|
+
| -------------- | -------- | ---------------------------------------------- |
|
|
146
|
+
| `PROJECT_PATH` | yes | Project path in `username/project_name` format |
|
|
147
|
+
|
|
148
|
+
| Option | Short | Default | Description |
|
|
149
|
+
| ------------- | ----- | ------- | -------------------------------------------------- |
|
|
150
|
+
| `--page_num` | `-n` | 1 | Page number (>= 1) |
|
|
151
|
+
| `--page_size` | `-s` | 20 | Page size. One of: 10, 12, 15, 20, 24, 27, 50, 100 |
|
|
152
|
+
| `--all` | | false | Fetch all pages |
|
|
153
|
+
| `--save` | | off | Save output to file |
|
|
154
|
+
|
|
155
|
+
#### `swanlab api run filter PROJECT_PATH -f FILTER_QUERY`
|
|
156
|
+
|
|
157
|
+
Filter experiments under a project by a structured query. Returns matching experiments without pagination.
|
|
158
|
+
|
|
159
|
+
See `references/SWANLAB_CONCEPTS.md > Filter Query` for the full filter object structure, supported types, operators, and constraints.
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
swanlab api run filter PROJECT_PATH -f FILTER_QUERY [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
| Argument | Required | Description |
|
|
166
|
+
| -------------- | -------- | ---------------------------------------------- |
|
|
167
|
+
| `PROJECT_PATH` | yes | Project path in `username/project_name` format |
|
|
168
|
+
|
|
169
|
+
| Option | Short | Default | Description |
|
|
170
|
+
| ---------------- | ----- | ---------- | --------------------------------------------------------------- |
|
|
171
|
+
| `--filter_query` | `-f` | (required) | Filter query as an inline JSON string or path to a `.json` file |
|
|
172
|
+
| `--save` | | off | Save output to file |
|
|
173
|
+
|
|
174
|
+
**Quick examples:**
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Filter by state
|
|
178
|
+
swanlab api run filter user/project -f '[{"key":"state","type":"STABLE","op":"EQ","value":["FINISHED"]}]'
|
|
179
|
+
|
|
180
|
+
# From a JSON file
|
|
181
|
+
swanlab api run filter user/project -f ./filters.json
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
For full filter syntax, operators, and advanced examples (config, scalar, time range, multi-condition), see `SWANLAB_CONCEPTS.md > Filter Query`.
|
|
185
|
+
|
|
186
|
+
#### `swanlab api run series PATH`
|
|
187
|
+
|
|
188
|
+
> **SDK ≥ 0.9.0.** Recommended replacement for the deprecated `column` / `columns` commands.
|
|
189
|
+
|
|
190
|
+
List an experiment's metric keys, with optional filters by metric type, class, and keyword.
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
swanlab api run series PATH [OPTIONS]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
| Argument | Required | Description |
|
|
197
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
198
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
199
|
+
|
|
200
|
+
| Option | Short | Default | Description |
|
|
201
|
+
| ---------- | ----- | -------- | ------------------------------------------------------------------------------- |
|
|
202
|
+
| `--type` | | `scalar` | Metric type: `scalar` or `media` |
|
|
203
|
+
| `--class` | | `custom` | Metric class: `custom` or `system` (see `SWANLAB_CONCEPTS.md > Column Classes`) |
|
|
204
|
+
| `--search` | | none | Fuzzy search keyword (case-insensitive substring match on key names) |
|
|
205
|
+
| `--save` | | off | Save output to file |
|
|
206
|
+
|
|
207
|
+
**Quick examples:**
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# List all custom scalar keys
|
|
211
|
+
swanlab api run series user/project/run_id
|
|
212
|
+
|
|
213
|
+
# Fuzzy search
|
|
214
|
+
swanlab api run series user/project/run_id --search loss
|
|
215
|
+
|
|
216
|
+
# System metrics (CPU, GPU, memory, ...)
|
|
217
|
+
swanlab api run series user/project/run_id --class system
|
|
218
|
+
|
|
219
|
+
# Media metric keys
|
|
220
|
+
swanlab api run series user/project/run_id --type media
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### `swanlab api run columns PATH`
|
|
224
|
+
|
|
225
|
+
> **⚠️ DEPRECATED since SDK `0.9.0` (multi-view version).** Not applicable to multi-view experiments — use [`run series`](#swanlab-api-run-series-path) instead. Only use this for legacy experiments on SDK `< 0.9.0`.
|
|
226
|
+
|
|
227
|
+
List columns (metric definitions) under an experiment.
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
swanlab api run columns PATH [OPTIONS]
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
| Argument | Required | Description |
|
|
234
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
235
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
236
|
+
|
|
237
|
+
| Option | Short | Default | Description |
|
|
238
|
+
| ------------- | ----- | ------- | ------------------------------------------------------------------------------------- |
|
|
239
|
+
| `--page_num` | `-n` | 1 | Page number (>= 1) |
|
|
240
|
+
| `--page_size` | `-s` | 20 | Page size. One of: 10, 12, 15, 20, 24, 27, 50, 100 |
|
|
241
|
+
| `--search` | | none | Fuzzy search keyword (matches column **name**, case-insensitive) |
|
|
242
|
+
| `--class` | | CUSTOM | Column class: `CUSTOM` or `SYSTEM` (see `SWANLAB_CONCEPTS.md > Column Classes`) |
|
|
243
|
+
| `--type` | | all | Data type filter (see `SWANLAB_CONCEPTS.md > Column Data Types` for all valid values) |
|
|
244
|
+
| `--all` | | false | Fetch all pages |
|
|
245
|
+
| `--save` | | off | Save output to file |
|
|
246
|
+
|
|
247
|
+
> **Notes on columns**:
|
|
248
|
+
>
|
|
249
|
+
> - Columns are **paginated** — use `--page_num` / `--page_size` to iterate in order to fetch all pages.
|
|
250
|
+
> - To query system metrics (CPU, GPU, memory, etc.), you must explicitly pass `--class SYSTEM`. The default is `CUSTOM` (user-defined metrics only).
|
|
251
|
+
> - **Resumed experiments have no system columns.** When an experiment is resumed via `swanlab.init(resume=...)`, system metrics (hardware monitoring) are not re-collected, so `--class SYSTEM` will return an empty list.
|
|
252
|
+
|
|
253
|
+
#### `swanlab api run column PATH --key KEY`
|
|
254
|
+
|
|
255
|
+
> **⚠️ DEPRECATED since SDK `0.9.0` (multi-view version).** Not applicable to multi-view experiments — use [`run series`](#swanlab-api-run-series-path) instead. Only use this for legacy experiments on SDK `< 0.9.0`.
|
|
256
|
+
|
|
257
|
+
Get a single column by key name.
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
swanlab api run column PATH --key KEY [OPTIONS]
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
| Argument | Required | Description |
|
|
264
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
265
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
266
|
+
|
|
267
|
+
| Option | Short | Default | Description |
|
|
268
|
+
| --------- | ----- | ---------- | ----------------------------------------------------------------- |
|
|
269
|
+
| `--key` | | (required) | Column key name |
|
|
270
|
+
| `--class` | | CUSTOM | `CUSTOM` or `SYSTEM` (see `SWANLAB_CONCEPTS.md > Column Classes`) |
|
|
271
|
+
| `--type` | | all | Data type filter (see `SWANLAB_CONCEPTS.md > Column Data Types`) |
|
|
272
|
+
| `--save` | | off | Save output to file |
|
|
273
|
+
|
|
274
|
+
#### `swanlab api run metrics PATH --keys KEYS`
|
|
275
|
+
|
|
276
|
+
Get scalar metric data for specified keys.
|
|
277
|
+
Keys is a comma-separated list of column keys, e.g. `loss,acc`.
|
|
278
|
+
Returns `{"ok", "errmsg", "data"}` where `data.list` holds one entry per key: `key`, sampled `metrics` points (`index`/`data`/`timestamp`), and server-side statistics (`min`/`max`/`avg`/`median`/`latest`). Use `--all` to fetch all data points without sampling limit. See `SWANLAB_CONCEPTS.md > Scalar Metrics` for data structure details.
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
swanlab api run metrics PATH --keys KEYS [OPTIONS]
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
| Argument | Required | Description |
|
|
285
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
286
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
287
|
+
|
|
288
|
+
| Option | Short | Default | Description |
|
|
289
|
+
| -------------------- | ----- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
290
|
+
| `--keys` | | (required) | Comma-separated metric keys, e.g. `loss,acc` |
|
|
291
|
+
| `--sample` | `-s` | 1500 | Sample size for scalars (>= 1). Max 1500; use `--all` for full export. |
|
|
292
|
+
| `--ignore-timestamp` | | false | Strip timestamps from metric data |
|
|
293
|
+
| `--all` | | false | Fetch all data points without sampling limit |
|
|
294
|
+
| `--range-type` | | `step` | Range filter axis: `step` or `timestamp`. Defaults to `step` when any range option is provided. |
|
|
295
|
+
| `--range-start` | | none | Range start value (inclusive). For `step` type: step number (int >= 0). For `timestamp` type: Unix timestamp in **milliseconds** (int >= 0). |
|
|
296
|
+
| `--range-end` | | none | Range end value (inclusive). Same type as `--range-start`. |
|
|
297
|
+
| `--range-head` | | none | Return only the first N data points (int >= 1). Mutually exclusive with `--range-tail`. |
|
|
298
|
+
| `--range-tail` | | none | Return only the last N data points (int >= 1). Mutually exclusive with `--range-head`. |
|
|
299
|
+
| `--range-last` | | none | Last N milliseconds of data (int >= 1). Mutually exclusive with `--range-start`/`--range-end`. Can combine with `--range-head`/`--range-tail`. |
|
|
300
|
+
| `--save` | | off | Save output to file |
|
|
301
|
+
|
|
302
|
+
**Range query constraints:**
|
|
303
|
+
|
|
304
|
+
- `--range-head` and `--range-tail` are mutually exclusive.
|
|
305
|
+
- `--range-last` is mutually exclusive with `--range-start`/`--range-end`.
|
|
306
|
+
- `--range-start` must be ≤ `--range-end`.
|
|
307
|
+
- `--range-head`/`--range-tail` can be combined with `--range-last` or `--range-start`/`--range-end`.
|
|
308
|
+
- Range query is only supported for SCALAR metrics. It downloads CSV data and applies client-side filtering.
|
|
309
|
+
- When using `--range-type timestamp`, each CSV row must have a timestamp column. Rows missing timestamps are skipped with a warning.
|
|
310
|
+
|
|
311
|
+
**Quick examples:**
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# Get steps 100–200
|
|
315
|
+
swanlab api run metrics PATH --keys loss --range-start 100 --range-end 200
|
|
316
|
+
|
|
317
|
+
# Get first 50 data points
|
|
318
|
+
swanlab api run metrics PATH --keys loss --range-head 50
|
|
319
|
+
|
|
320
|
+
# Get data by timestamp range (Unix milliseconds)
|
|
321
|
+
swanlab api run metrics PATH --keys loss --range-type timestamp --range-start 1714368000000 --range-end 1714454400000
|
|
322
|
+
|
|
323
|
+
# Get data from the last 5 minutes
|
|
324
|
+
swanlab api run metrics PATH --keys loss --range-last 300000
|
|
325
|
+
|
|
326
|
+
# Get last 30 data points
|
|
327
|
+
swanlab api run metrics PATH --keys loss --range-tail 30
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
> **Tip**: For large metric data, use `--save` to write JSON to file, then plot with `scripts/plot_metrics.py --data file.json -k loss`. For quick stats, prefer `run summary` over full metrics.
|
|
331
|
+
|
|
332
|
+
#### `swanlab api run summary PATH`
|
|
333
|
+
|
|
334
|
+
Get scalar metric summaries (statistics) for an experiment. Returns per-key aggregates: last step/value, min/max, avg, median, stdDev. See `SWANLAB_CONCEPTS.md > Scalar Summary` for response structure details.
|
|
335
|
+
|
|
336
|
+
> **Note**: summary only returns each key's **latest value** (plus aggregates) — not the time series. To read the values of a specific key over steps, use `swanlab api run metrics PATH --keys KEY`.
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
swanlab api run summary PATH [--keys KEYS] [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
| Argument | Required | Description |
|
|
343
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
344
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
345
|
+
|
|
346
|
+
| Option | Short | Default | Description |
|
|
347
|
+
| -------- | ----- | ------- | ---------------------------------------------------------------------------- |
|
|
348
|
+
| `--keys` | | all | Comma-separated scalar keys, e.g. `loss,acc`. Omit to query all scalar keys. |
|
|
349
|
+
| `--save` | | off | Save output to file |
|
|
350
|
+
|
|
351
|
+
#### `swanlab api run medias PATH --keys KEYS`
|
|
352
|
+
|
|
353
|
+
Get media data for specified keys. See `SWANLAB_CONCEPTS.md > Media Metrics` for the response structure and how presigned URLs work.
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
swanlab api run medias PATH --keys KEYS [OPTIONS]
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
| Argument | Required | Description |
|
|
360
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
361
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
362
|
+
|
|
363
|
+
| Option | Short | Default | Description |
|
|
364
|
+
| -------- | ----- | ---------- | ---------------------------------------------- |
|
|
365
|
+
| `--keys` | | (required) | Comma-separated media keys, e.g. `image,audio` |
|
|
366
|
+
| `--step` | `-s` | 0 | Step number to retrieve |
|
|
367
|
+
| `--all` | | false | Fetch all steps |
|
|
368
|
+
| `--save` | | off | Save output to file |
|
|
369
|
+
|
|
370
|
+
#### `swanlab api run logs PATH`
|
|
371
|
+
|
|
372
|
+
Get console logs captured during a run. See `SWANLAB_CONCEPTS.md > Console Logs` for shard-based pagination details.
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
swanlab api run logs PATH [OPTIONS]
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
| Argument | Required | Description |
|
|
379
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
380
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
381
|
+
|
|
382
|
+
| Option | Short | Default | Description |
|
|
383
|
+
| -------------------- | ----- | ------- | ------------------------------------------- |
|
|
384
|
+
| `--offset` | `-o` | 0 | Log offset (shard index) |
|
|
385
|
+
| `--level` | `-l` | INFO | Log level: `DEBUG`, `INFO`, `WARN`, `ERROR` |
|
|
386
|
+
| `--ignore-timestamp` | | false | Strip timestamps from log entries |
|
|
387
|
+
| `--save` | | off | Save output to file |
|
|
388
|
+
|
|
389
|
+
#### `swanlab api run export-logs PATH`
|
|
390
|
+
|
|
391
|
+
Export experiment console logs as a downloadable `.log` file. Returns a presigned download URL. See `SWANLAB_CONCEPTS.md > Log Export` for conceptual details.
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
swanlab api run export-logs PATH [OPTIONS]
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
| Argument | Required | Description |
|
|
398
|
+
| -------- | -------- | -------------------------------------------------------- |
|
|
399
|
+
| `PATH` | yes | Experiment path in `username/project_name/run_id` format |
|
|
400
|
+
|
|
401
|
+
| Option | Short | Default | Description |
|
|
402
|
+
| --------- | ----- | ------- | ----------------------------------- |
|
|
403
|
+
| `--start` | | 0 | Start row index (0-based) |
|
|
404
|
+
| `--rows` | `-r` | 500000 | Number of rows to export (1–500000) |
|
|
405
|
+
| `--save` | | off | Save the export URL as JSON to file |
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
### 5. Self-Hosted
|
|
410
|
+
|
|
411
|
+
These commands are only valid for **self-hosted SwanLab instances**. All self-hosted management commands require **root (admin) privileges**. See `SWANLAB_CONCEPTS.md > Self-Hosted Instance` for the host detection rule — do not use these commands if the resolved host contains `swanlab.cn`.
|
|
412
|
+
|
|
413
|
+
#### `swanlab api self-hosted info`
|
|
414
|
+
|
|
415
|
+
Show self-hosted instance info.
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
swanlab api self-hosted info [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
#### `swanlab api self-hosted create-user`
|
|
422
|
+
|
|
423
|
+
Create a user in the self-hosted instance (root only).
|
|
424
|
+
|
|
425
|
+
```bash
|
|
426
|
+
swanlab api self-hosted create-user -u USERNAME -p PASSWORD
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
| Option | Short | Description |
|
|
430
|
+
| ------------ | ----- | ------------------------------------ |
|
|
431
|
+
| `--username` | `-u` | Username to create (required) |
|
|
432
|
+
| `--password` | `-p` | Password for the new user (required) |
|
|
433
|
+
|
|
434
|
+
#### `swanlab api self-hosted list-users`
|
|
435
|
+
|
|
436
|
+
List users in the self-hosted instance (root only).
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
swanlab api self-hosted list-users [OPTIONS]
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
| Option | Short | Default | Description |
|
|
443
|
+
| ------------- | ----- | ------- | --------------- |
|
|
444
|
+
| `--page_num` | `-n` | 1 | Page number |
|
|
445
|
+
| `--page_size` | `-s` | 20 | Page size |
|
|
446
|
+
| `--all` | | false | Fetch all users |
|
|
447
|
+
|
|
448
|
+
#### `swanlab api self-hosted list-projects`
|
|
449
|
+
|
|
450
|
+
List all projects across the self-hosted instance (root only). Supports filtering by creator, workspace, and keyword search.
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
swanlab api self-hosted list-projects [OPTIONS]
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
| Option | Short | Default | Description |
|
|
457
|
+
| ------------- | ----- | ------- | ---------------------------- |
|
|
458
|
+
| `--page_num` | `-n` | 1 | Page number |
|
|
459
|
+
| `--page_size` | `-s` | 20 | Page size |
|
|
460
|
+
| `--all` | | false | Fetch all projects |
|
|
461
|
+
| `--search` | | none | Search keyword |
|
|
462
|
+
| `--creator` | | none | Filter by creator username |
|
|
463
|
+
| `--workspace` | | none | Filter by workspace username |
|
|
464
|
+
|
|
465
|
+
#### `swanlab api self-hosted list-workspaces`
|
|
466
|
+
|
|
467
|
+
List all workspaces in the self-hosted instance (root only).
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
swanlab api self-hosted list-workspaces [OPTIONS]
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
| Option | Short | Default | Description |
|
|
474
|
+
| ------------- | ----- | ------- | -------------------- |
|
|
475
|
+
| `--page_num` | `-n` | 1 | Page number |
|
|
476
|
+
| `--page_size` | `-s` | 20 | Page size |
|
|
477
|
+
| `--all` | | false | Fetch all workspaces |
|
|
478
|
+
| `--search` | | none | Search keyword |
|
|
479
|
+
|
|
480
|
+
#### `swanlab api self-hosted summary`
|
|
481
|
+
|
|
482
|
+
Show system usage summary for the self-hosted instance (root only). Includes aggregate statistics such as total users, projects, experiments, and storage usage. See `SWANLAB_CONCEPTS.md > Self-Hosted Instance > Usage Summary` for details.
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
swanlab api self-hosted summary [--save [FILENAME]] [--host HOST] [--api-key KEY]
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Troubleshooting
|
|
491
|
+
|
|
492
|
+
| Symptom | Likely cause | Fix |
|
|
493
|
+
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
494
|
+
| `project info` / `run list` / `run info` → `404 Not_Found` | **Wrong host** — the project lives on another instance (public `swanlab.cn` vs self-hosted) | Run `swanlab verify` to see your host; re-issue with `--host <URL> --api-key <KEY>`. The name is not wrong — don't page `project list`. |
|
|
495
|
+
| `401 Unauthorized` after passing `--host` | The API key belongs to another instance — credentials are per-instance | Use the key issued by the target instance, or `swanlab login --host <URL>` against it. |
|
|
496
|
+
| `{"ok": false, ...}` JSON on stdout | The query itself failed — server or transport error during the request (the normal failure shape) | Read `errmsg`: wrong path/host → fix it (rows above); transient → retry once. |
|
|
497
|
+
| Empty stdout, exit code ≠ 0 | `Api()` init failed before the query — bad/missing credentials (persistent) or network error at the login check; errors go to stderr only | Check exit code and stderr first. Credentials → `swanlab login` / `--api-key` (retry won't help); network → retry. |
|
|
498
|
+
|
|
499
|
+
See `SWANLAB_CONCEPTS.md > Instances, Hosts & Credentials` for the full multi-instance model.
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
## Behavioral Constraints
|
|
504
|
+
|
|
505
|
+
- **Use `--all` only when the user explicitly asks for it.** This flag bypasses pagination and fetches the entire dataset in one go, which puts heavy load on the database. For paginated list commands, always use default pagination (`--page_num` / `--page_size`). Only add `--all` when the user says something like "fetch all", "get everything", or "I want the complete list".
|
|
506
|
+
- **Always ask the user for specific metric keys before running `run metrics` or `run medias`.** These commands accept a `--keys` parameter. Querying without a specific key forces the server to scan and return data for all metrics, which is expensive. If the user doesn't know the key names, first run `run series PATH` to list available keys, then use the returned keys for targeted queries. Always discover key names from `run series` output before querying specific metrics. (On SDK `< 0.9.0` where `run series` does not exist, fall back to `run columns PATH`.)
|
|
507
|
+
- **Always add `--ignore-timestamp` for `run metrics` and `run logs`.** Unless the user specifically asks to keep timestamps, include this flag by default. It produces cleaner, more readable output by removing Unix timestamps from every data point.
|
|
508
|
+
- All output is JSON to stdout. Pipe to `jq` or similar tools for further processing.
|
|
509
|
+
- `--save` without a filename auto-generates `swanlab-YYYYMMDD_HHMMSS-xxxx.json` in the current directory.
|
|
510
|
+
- If not logged in, supply both `--host` and `--api-key` on every invocation. See `SWANLAB_CONCEPTS.md > Key Environment Variables` for the full variable list.
|