Skip to content

Commit

Permalink
[Artifacts] Fix producer uid not passed to artifact path template (#5603
Browse files Browse the repository at this point in the history
)
  • Loading branch information
TomerShor committed May 21, 2024
1 parent 743ea32 commit b96eb9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mlrun/artifacts/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def __init__(self, kind, project, name, tag=None, owner=None):
def get_meta(self) -> dict:
return {"kind": self.kind, "name": self.name, "tag": self.tag}

@property
def uid(self):
return None


def dict_to_artifact(struct: dict) -> Artifact:
kind = struct.get("kind", "")
Expand Down Expand Up @@ -262,7 +266,7 @@ def log_artifact(
if target_path and item.is_dir and not target_path.endswith("/"):
target_path += "/"
target_path = template_artifact_path(
artifact_path=target_path, project=producer.project
artifact_path=target_path, project=producer.project, run_uid=producer.uid
)
item.target_path = target_path

Expand Down
3 changes: 2 additions & 1 deletion mlrun/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,14 +1183,15 @@ def calculate_dataframe_hash(dataframe: pandas.DataFrame):
return hashlib.sha1(pandas.util.hash_pandas_object(dataframe).values).hexdigest()


def template_artifact_path(artifact_path, project, run_uid="project"):
def template_artifact_path(artifact_path, project, run_uid=None):
"""
Replace {{run.uid}} with the run uid and {{project}} with the project name in the artifact path.
If no run uid is provided, the word `project` will be used instead as it is assumed to be a project
level artifact.
"""
if not artifact_path:
return artifact_path
run_uid = run_uid or "project"
artifact_path = artifact_path.replace("{{run.uid}}", run_uid)
artifact_path = _fill_project_path_template(artifact_path, project)
return artifact_path
Expand Down

0 comments on commit b96eb9b

Please sign in to comment.