You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`login` validates the key and automatically configures `server`, `team_id`, `user_email`, and `team_name`.
40
40
41
-
**Getting an API key:** API keys are created in the Transformer Lab web UI under team settings, or via the REST API using a JWT token. If the user gives you email/password credentials, get a JWT token first, then use it to create an API key:
42
-
43
-
```bash
44
-
# Get JWT token from email/password
45
-
TOKEN=$(curl -s -X POST https://SERVER/auth/jwt/login \
Then ask the user to provide or create an API key from the UI.
41
+
**Getting an API key:** If `lab status` fails with auth errors, **stop and ask the user to provide an API key.** Do NOT attempt to create API keys programmatically by logging in with email/password. API keys are created in the Transformer Lab web UI under team settings. The user must provide the key to you.
54
42
55
43
### Verifying You're Connected to the Right Server
Full docs: https://lab.cloud/for-teams/running-a-task/task-yaml-structure
96
+
97
+
```yaml
98
+
name: my-task # Required — task identifier
99
+
resources: # Optional but recommended
100
+
cpus: 2# CPU count (integer or string)
101
+
memory: 4# RAM in GB (integer or string, NOT "4Gi")
102
+
disk_space: 100# Storage in GB
103
+
accelerators: "H100:8"# GPU spec as "TYPE:COUNT"
104
+
num_nodes: 2# For distributed training
105
+
compute_provider: my-provider # Target provider name
106
+
setup: | # Optional — runs before main task
107
+
pip install transformerlab
108
+
pip install -r requirements.txt
109
+
run: python main.py # Required — main entry point
110
+
envs: # Optional environment variables
111
+
HF_TOKEN: "${HF_TOKEN}"
112
+
parameters: # Optional — accessible via lab.get_config()
113
+
learning_rate: 0.001
114
+
batch_size: 32
115
+
sweeps: # Optional — hyperparameter sweep
116
+
sweep_config:
117
+
learning_rate: ["1e-5", "3e-5"]
118
+
sweep_metric: "eval/loss"
119
+
lower_is_better: true
120
+
minutes_requested: 60# Optional time limit
121
+
github_repo_url: https://... # Optional — clone from git
122
+
github_repo_dir: path/in/repo
123
+
github_repo_branch: main
124
+
```
125
+
126
+
**Important:** `memory` and `disk_space` are plain numbers in GB (e.g., `4`, `16`), NOT Kubernetes-style strings like `4Gi`. The schema accepts both but the canonical format is plain integers.
127
+
128
+
### Validation
129
+
130
+
`lab task add` automatically validates task.yaml against the server schema before uploading. There is no standalone `lab task validate` command yet (TODO: add one).
131
+
132
+
To validate without creating, use `lab task add ./my-task --dry-run`.
133
+
134
+
### Lab SDK Quick Reference
135
+
136
+
Tasks use the Lab SDK (`transformerlab` PyPI package). Import pattern:
137
+
138
+
```python
139
+
from lab import lab
140
+
141
+
lab.init() # Required — connects to the job
142
+
lab.log("message") # Write to job output log
143
+
lab.update_progress(50) # Set progress 0-100
144
+
config = lab.get_config() # Read parameters from task.yaml
145
+
146
+
lab.finish(message="Done!") # Mark job as SUCCESS
147
+
lab.error(message="Something went wrong") # Mark job as FAILED
148
+
```
149
+
150
+
**Common mistakes:**
151
+
- `lab.finish()`has NO `status` parameter — just `message`. For failures, use `lab.error()`.
152
+
- Always call `lab.init()` before any other SDK call.
153
+
- Always call `lab.finish()` or `lab.error()` at the end — otherwise the job stays in RUNNING state.
154
+
155
+
### Example: Minimal Hello World Task
156
+
157
+
**task.yaml:**
158
+
```yaml
159
+
name: hello-world
160
+
setup: pip install transformerlab
161
+
run: python main.py
162
+
resources:
163
+
cpus: 2
164
+
memory: 4
165
+
```
166
+
167
+
**main.py:**
168
+
```python
169
+
import time
170
+
from lab import lab
171
+
172
+
lab.init()
173
+
lab.log("Hello from Transformer Lab!")
174
+
lab.update_progress(25)
175
+
time.sleep(3)
176
+
lab.log("Working...")
177
+
lab.update_progress(75)
178
+
time.sleep(2)
179
+
lab.log("Done!")
180
+
lab.update_progress(100)
181
+
lab.finish(message="Hello world complete!")
182
+
```
183
+
184
+
**Add it:**
185
+
```bash
186
+
lab task add ./hello-world-task --no-interactive
187
+
```
188
+
103
189
## Agent-Specific Rules
104
190
105
191
1. **Use `--format json`** when you need to parse output, but be prepared to fall back to pretty output parsing if it doesn't work
106
192
2. **Use `--no-interactive`** on `task queue` and `provider add` to avoid blocking prompts
107
-
3.**`task add` has no `--yes` flag** — pipe `echo "y"`to confirm: `echo "y" | lab task add ./my-task`
108
-
4.**Use `--yes` / `-y`** on destructive commands (`provider delete`) to skip confirmation
193
+
3. **`task add`**: Use `--no-interactive` to skip confirmation (e.g., `lab task add ./my-task --no-interactive`). Use `--dry-run` to validate without creating.
194
+
4. **Use `--no-interactive`** on destructive commands (`task delete`, `provider delete`) to skip confirmation
109
195
5. **Never use `job monitor`** — it launches a TUI that blocks; use `job list` + `job logs` instead
110
196
6. **Never use `task interactive`** unless the user specifically requests an interactive session
111
197
7. **`job logs --follow`** streams continuously and blocks until the job finishes — use when the user wants real-time monitoring
198
+
8. **Never create API keys programmatically** — if auth fails, ask the user to provide an API key from the web UI
199
+
9. **task.yaml docs**: Full reference at https://lab.cloud/for-teams/running-a-task/task-yaml-structure
112
200
113
201
## Debugging Failed Jobs
114
202
@@ -221,8 +309,8 @@ The `provider_logs` endpoint is the single best debugging tool — it returns wh
221
309
| `lab version` | Show CLI version | No |
222
310
| `lab task list` | List tasks in current experiment | Yes |
223
311
| `lab task info <id>` | Get task details | Yes |
224
-
|`lab task add [dir]`| Add task from directory or `--from-git` URL | Yes |
225
-
|`lab task delete <id>`| Delete a task | Yes |
312
+
| `lab task add [dir]` | Add task from directory or `--from-git` URL (`--no-interactive`, `--dry-run`) | Yes |
313
+
| `lab task delete <id>` | Delete a task (`--no-interactive` to skip confirmation) | Yes |
0 commit comments