Skip to content

Commit 4a3c924

Browse files
committed
fix job list
1 parent 6cc7cf5 commit 4a3c924

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

cli/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ pip install -e .
5959
uv run textual run --dev src/transformerlab_cli/commands/job_monitor/job_monitor.py
6060
```
6161

62+
and then in another window do:
63+
64+
```
65+
textual console -x SYSTEM -x EVENT -x INFO
66+
```
67+
68+
## Run Textual in Browser
69+
6270
Run in browser (for fun?)
6371
```
6472
uv run textual serve src/transformerlab_cli/commands/job_monitor/job_monitor.py

cli/src/transformerlab_cli/commands/job.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
from rich.text import Text
1010
from urllib.parse import urlparse
1111

12-
from transformerlab_cli.util.config import check_configs
12+
from transformerlab_cli.util.config import check_configs, get_config
1313
from transformerlab_cli.util import api
1414

1515
app = typer.Typer()
1616

1717
console = Console()
1818

1919

20-
def _fetch_all_jobs() -> list[dict]:
21-
"""Fetch all jobs from the API."""
22-
response = api.get("/experiment/alpha/jobs/list?type=REMOTE") # Placeholder logic for listing jobs
20+
def _fetch_all_jobs(experiment_id: str) -> list[dict]:
21+
"""Fetch all jobs from the API for a specific experiment."""
22+
response = api.get(f"/experiment/{experiment_id}/jobs/list?type=REMOTE")
2323
if response.status_code == 200:
2424
return response.json()
2525
else:
@@ -116,20 +116,20 @@ def _render_job(job) -> None:
116116
console.print(panel)
117117

118118

119-
def list_jobs():
120-
"""List all jobs."""
119+
def list_jobs(experiment_id: str):
120+
"""List all jobs for a specific experiment."""
121121
jobs = []
122122
with console.status("[bold green]Fetching jobs[/bold green]", spinner="dots"):
123-
jobs = _fetch_all_jobs()
123+
jobs = _fetch_all_jobs(experiment_id)
124124
table = _render_jobs(jobs)
125125
print(table)
126126

127127

128-
def info_job(job_id: str):
128+
def info_job(job_id: str, experiment_id: str):
129129
"""Get details of a specific job."""
130130
jobs = []
131131
with console.status("[bold green]Fetching jobs[/bold green]", spinner="dots"):
132-
jobs = _fetch_all_jobs()
132+
jobs = _fetch_all_jobs(experiment_id)
133133

134134
# filter the job with the given job_id
135135
job = next((job for job in jobs if str(job.get("id")) == job_id), None)
@@ -257,7 +257,12 @@ def command_job_download(
257257
def command_job_list():
258258
"""List all jobs."""
259259
check_configs()
260-
list_jobs() # Delegate to job_commands.list_jobs
260+
current_experiment = get_config("current_experiment")
261+
if not current_experiment or not str(current_experiment).strip():
262+
console.print("[yellow]current_experiment is not set in config.[/yellow]")
263+
console.print("Set it first with: [bold]lab config current_experiment <experiment_name>[/bold]")
264+
raise typer.Exit(1)
265+
list_jobs(current_experiment) # Delegate to job_commands.list_jobs
261266

262267

263268
@app.command("info")
@@ -266,7 +271,12 @@ def command_job_info(
266271
):
267272
"""Get job details."""
268273
check_configs()
269-
info_job(job_id) # Delegate to job_commands.info_job
274+
current_experiment = get_config("current_experiment")
275+
if not current_experiment or not str(current_experiment).strip():
276+
console.print("[yellow]current_experiment is not set in config.[/yellow]")
277+
console.print("Set it first with: [bold]lab config current_experiment <experiment_name>[/bold]")
278+
raise typer.Exit(1)
279+
info_job(job_id, current_experiment)
270280

271281

272282
@app.command("monitor")

0 commit comments

Comments
 (0)