@@ -371,13 +371,14 @@ def info_job(job_id: str, experiment_id: str):
371371 console .print (f"[error]Error:[/error] Job with ID { job_id } not found." )
372372
373373
374- def list_artifacts (job_id : str , output_format : str = "pretty" ) -> list [dict ]:
374+ def list_artifacts (job_id : str , experiment_id : str , output_format : str = "pretty" ) -> list [dict ]:
375375 """List artifacts for a job by ID. Returns list of artifact dicts."""
376+ artifacts_url = f"/experiment/{ experiment_id } /jobs/{ job_id } /artifacts"
376377 if output_format != "json" :
377378 with console .status (f"[bold success]Fetching artifacts for job { job_id } ...[/bold success]" , spinner = "dots" ):
378- response = api .get (f"/jobs/ { job_id } /artifacts" )
379+ response = api .get (artifacts_url )
379380 else :
380- response = api .get (f"/jobs/ { job_id } /artifacts" )
381+ response = api .get (artifacts_url )
381382
382383 if response .status_code != 200 :
383384 if output_format == "json" :
@@ -410,7 +411,7 @@ def list_artifacts(job_id: str, output_format: str = "pretty") -> list[dict]:
410411 return artifacts
411412
412413
413- def download_artifacts (job_id : str , output_dir : str = None ) -> None :
414+ def download_artifacts (job_id : str , experiment_id : str , output_dir : str | None = None ) -> None :
414415 """Download all artifacts for a job as a zip file."""
415416 if output_dir is None :
416417 output_dir = os .getcwd ()
@@ -426,9 +427,10 @@ def download_artifacts(job_id: str, output_dir: str = None) -> None:
426427 if os .path .exists (output_path ):
427428 console .print (f"[warning]Warning:[/warning] File { output_path } already exists. It will be overwritten." )
428429
430+ download_all_url = f"/experiment/{ experiment_id } /jobs/{ job_id } /artifacts/download_all"
429431 try :
430432 with console .status (f"[bold success]Downloading artifacts for job { job_id } ...[/bold success]" , spinner = "dots" ):
431- response = api .get (f"/jobs/ { job_id } /artifacts/download_all" , timeout = 300.0 )
433+ response = api .get (download_all_url , timeout = 300.0 )
432434
433435 if response .status_code == 200 :
434436 # Get filename from Content-Disposition header if available
@@ -485,7 +487,8 @@ def command_job_artifacts(
485487):
486488 """List artifacts for a job."""
487489 check_configs (output_format = cli_state .output_format )
488- list_artifacts (job_id , output_format = cli_state .output_format )
490+ current_experiment = require_current_experiment ()
491+ list_artifacts (job_id , current_experiment , output_format = cli_state .output_format )
489492
490493
491494@app .command ("download" )
@@ -502,14 +505,15 @@ def command_job_download(
502505):
503506 """Download artifacts for a job. Use --file to download specific files."""
504507 check_configs (output_format = cli_state .output_format )
508+ current_experiment = require_current_experiment ()
505509 out = os .path .abspath (output_dir ) if output_dir else os .getcwd ()
506510 output_format = cli_state .output_format
507511
508512 if not file :
509- download_artifacts (job_id , output_dir )
513+ download_artifacts (job_id , current_experiment , output_dir )
510514 return
511515
512- raw_resp = api .get (f"/jobs/{ job_id } /artifacts" )
516+ raw_resp = api .get (f"/experiment/ { current_experiment } / jobs/{ job_id } /artifacts" )
513517 if raw_resp .status_code != 200 :
514518 if output_format == "json" :
515519 print (json .dumps ({"error" : f"Failed to fetch artifacts. Status code: { raw_resp .status_code } " }))
@@ -532,7 +536,7 @@ def command_job_download(
532536 for filename in matched :
533537 if output_format != "json" :
534538 console .print (f"Downloading [cyan]{ filename } [/cyan]..." )
535- path = download_single_artifact (job_id , filename , out )
539+ path = download_single_artifact (job_id , current_experiment , filename , out )
536540 if path :
537541 downloaded .append ({"filename" : filename , "path" : path })
538542 elif output_format != "json" :
@@ -544,17 +548,18 @@ def command_job_download(
544548 console .print (f"[green]✓[/green] Downloaded { len (downloaded )} /{ len (matched )} file(s) to { out } " )
545549
546550
547- def download_single_artifact (job_id : str , filename : str , output_dir : str ) -> str | None :
551+ def download_single_artifact (job_id : str , experiment_id : str , filename : str , output_dir : str ) -> str | None :
548552 """Download a single artifact by filename. Returns local path or None on failure."""
549553 output_path = os .path .join (output_dir , filename )
554+ base_url = f"/experiment/{ experiment_id } /jobs/{ job_id } "
550555 try :
551- response = api .get (f"/jobs/ { job_id } /artifact/{ filename } ?task=download" , timeout = 300.0 )
556+ response = api .get (f"{ base_url } /artifact/{ filename } ?task=download" , timeout = 300.0 )
552557 if response .status_code == 200 :
553558 with open (output_path , "wb" ) as f :
554559 f .write (response .content )
555560 return output_path
556561 if response .status_code in (404 , 405 ):
557- zip_response = api .get (f"/jobs/ { job_id } /artifacts/download_all" , timeout = 300.0 )
562+ zip_response = api .get (f"{ base_url } /artifacts/download_all" , timeout = 300.0 )
558563 if zip_response .status_code == 200 :
559564 with zipfile .ZipFile (io .BytesIO (zip_response .content )) as zf :
560565 names = zf .namelist ()
0 commit comments