99from rich .text import Text
1010from 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
1313from transformerlab_cli .util import api
1414
1515app = typer .Typer ()
1616
1717console = 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(
257257def 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