Skip to content

Commit dd3e584

Browse files
committed
🐛 Fix single file download
Fixes issue with downloading files from tenant runs
1 parent 9732276 commit dd3e584

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

simvue/client.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from .models import FOLDER_REGEX, NAME_REGEX
3333
from .config.user import SimvueConfiguration
3434
from .api.request import get_json_from_response
35-
from .api.objects import Run, Folder, Tag, Artifact, Alert
35+
from .api.objects import Run, Folder, Tag, Artifact, Alert, FileArtifact, ObjectArtifact
3636

3737

3838
CONCURRENT_DOWNLOADS = 10
@@ -42,8 +42,10 @@
4242

4343

4444
def _download_artifact_to_file(
45-
artifact: Artifact, output_dir: pathlib.Path | None
45+
artifact: FileArtifact | ObjectArtifact, output_dir: pathlib.Path | None
4646
) -> None:
47+
if not artifact.name:
48+
raise RuntimeError(f"Expected artifact '{artifact.id}' to have a name")
4749
_output_file = (output_dir or pathlib.Path.cwd()).joinpath(artifact.name)
4850
# If this is a hierarchical structure being downloaded, need to create directories
4951
_output_file.parent.mkdir(parents=True, exist_ok=True)
@@ -475,12 +477,11 @@ def list_artifacts(
475477
) # type: ignore
476478

477479
def _retrieve_artifacts_from_server(
478-
self, run_id: str, name: str, count: int | None = None
480+
self, run_id: str, name: str
479481
) -> typing.Generator[tuple[str, Artifact], None, None]:
480-
return Artifact.get(
481-
runs=json.dumps([run_id]),
482-
filters=json.dumps([f"name == {name}"]),
483-
count=count,
482+
return Artifact.from_name(
483+
run_id=run_id,
484+
name=name,
484485
) # type: ignore
485486

486487
@prettify_pydantic
@@ -574,12 +575,7 @@ def get_artifact_as_file(
574575
if there was a failure during retrieval of information from the
575576
server
576577
"""
577-
_artifacts = self._retrieve_artifacts_from_server(run_id, name, count=1)
578-
579-
try:
580-
_id, _artifact = next(_artifacts)
581-
except StopIteration as e:
582-
raise ValueError(f"No artifact '{name}' found for run '{run_id}'") from e
578+
_artifact = self._retrieve_artifacts_from_server(run_id, name)
583579

584580
_download_artifact_to_file(_artifact, output_dir)
585581

0 commit comments

Comments
 (0)