@@ -478,11 +478,13 @@ def list_artifacts(
478
478
479
479
def _retrieve_artifacts_from_server (
480
480
self , run_id : str , name : str
481
- ) -> typing . Generator [ tuple [ str , Artifact ], None , None ] :
481
+ ) -> FileArtifact | ObjectArtifact | None :
482
482
return Artifact .from_name (
483
483
run_id = run_id ,
484
484
name = name ,
485
- ) # type: ignore
485
+ server_url = self ._user_config .server .url ,
486
+ server_token = self ._user_config .server .token ,
487
+ )
486
488
487
489
@prettify_pydantic
488
490
@pydantic .validate_call
@@ -530,12 +532,14 @@ def get_artifact(
530
532
RuntimeError
531
533
if retrieval of artifact from the server failed
532
534
"""
533
- _artifact = Artifact .from_name (
534
- run_id = run_id ,
535
- name = name ,
536
- server_url = self ._user_config .server .url ,
537
- server_token = self ._user_config .server .token ,
538
- )
535
+ _artifact = self ._retrieve_artifacts_from_server (run_id , name )
536
+
537
+ if not _artifact :
538
+ raise ObjectNotFoundError (
539
+ obj_type = "artifact" ,
540
+ name = name ,
541
+ extra = f"for run '{ run_id } '" ,
542
+ )
539
543
540
544
_content = b"" .join (_artifact .download_content ())
541
545
@@ -577,6 +581,13 @@ def get_artifact_as_file(
577
581
"""
578
582
_artifact = self ._retrieve_artifacts_from_server (run_id , name )
579
583
584
+ if not _artifact :
585
+ raise ObjectNotFoundError (
586
+ obj_type = "artifact" ,
587
+ name = name ,
588
+ extra = f"for run '{ run_id } '" ,
589
+ )
590
+
580
591
_download_artifact_to_file (_artifact , output_dir )
581
592
582
593
@prettify_pydantic
0 commit comments