Skip to content

Commit

Permalink
[SDK] Fix list artifact tags in httpdb (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Aug 10, 2021
1 parent f1f0c84 commit 74b891c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mlrun/db/httpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@ def del_artifacts(self, name=None, project=None, tag=None, labels=None, days_ago
error = "del artifacts"
self.api_call("DELETE", "artifacts", error, params=params)

def list_artifact_tags(self, project=None):
def list_artifact_tags(self, project=None) -> List[str]:
""" Return a list of all the tags assigned to artifacts in the scope of the given project."""

project = project or config.default_project
error_message = f"Failed listing artifact tags. project={project}"
response = self.api_call(
"GET", f"/projects/{project}/artifact-tags", error_message
"GET", f"projects/{project}/artifact-tags", error_message
)
return response.json()
return response.json()["tags"]

def store_function(self, function, name, project="", tag=None, versioned=False):
""" Store a function object. Function is identified by its name and tag, and can be versioned."""
Expand Down
Empty file.
30 changes: 30 additions & 0 deletions tests/integration/sdk_api/artifacts/test_artifact_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import deepdiff
import pandas

import mlrun
import mlrun.artifacts
import tests.integration.sdk_api.base


class TestArtifactTags(tests.integration.sdk_api.base.TestMLRunIntegration):
def test_list_artifact_tags(self):
project_name = "some-project"
project = mlrun.new_project(project_name)
project.save_to_db()
artifact_tags = mlrun.get_run_db().list_artifact_tags(project_name)
assert artifact_tags == []
key = "some-key"
data_frame = pandas.DataFrame({"x": [1, 2]})
artifact = mlrun.artifacts.dataset.DatasetArtifact(key, data_frame)
uid = "some-uid"
uid_2 = "some-uid-2"
tag = "some-tag"
tag_2 = "some-tag-2"
mlrun.get_run_db().store_artifact(
key, artifact.to_dict(), uid, tag=tag, project=project_name
)
mlrun.get_run_db().store_artifact(
key, artifact.to_dict(), uid_2, tag=tag_2, project=project_name
)
artifact_tags = mlrun.get_run_db().list_artifact_tags(project_name)
assert deepdiff.DeepDiff(artifact_tags, [tag, tag_2], ignore_order=True,) == {}

0 comments on commit 74b891c

Please sign in to comment.