-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(launcher): move artifact metadata to metadata struct field. Fixes #5788 #5793
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
from dataclasses import dataclass, asdict | ||
from pprint import pprint | ||
from typing import Dict, List, Callable, Optional | ||
from google.protobuf.json_format import MessageToDict | ||
|
||
import kfp | ||
import kfp_server_api | ||
|
@@ -222,34 +223,28 @@ class KfpArtifact: | |
name: str | ||
uri: str | ||
type: str | ||
custom_properties: dict | ||
metadata: dict | ||
|
||
@classmethod | ||
def new( | ||
cls, mlmd_artifact: metadata_store_pb2.Artifact, | ||
mlmd_artifact_type: metadata_store_pb2.ArtifactType | ||
): | ||
custom_properties = {} | ||
for k, v in mlmd_artifact.custom_properties.items(): | ||
raw_value = None | ||
if v.string_value: | ||
raw_value = v.string_value | ||
if v.int_value: | ||
raw_value = v.int_value | ||
if v.double_value: | ||
raw_value = v.double_value | ||
custom_properties[k] = raw_value | ||
artifact_name = '' | ||
if mlmd_artifact.name != '': | ||
if mlmd_artifact.name: | ||
artifact_name = mlmd_artifact.name | ||
else: | ||
if 'name' in custom_properties.keys(): | ||
artifact_name = custom_properties['name'] | ||
if 'name' in mlmd_artifact.custom_properties.keys(): | ||
artifact_name = mlmd_artifact.custom_properties['name' | ||
].string_value | ||
metadata = MessageToDict( | ||
mlmd_artifact.custom_properties.get('metadata').struct_value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the usage of transfer mlmd_artifact.custom_properties.get('metadata') to a metadata struct? Can't we just verify the custom_properties in tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test util script tries to hide MLMD implementation details from KFP data model and let e2e tests decouple from specific MLMD implementation. Because in this way, tests assert on KFP data model -- the metadata struct contains all user logged metadata. Benefits:
|
||
) | ||
return cls( | ||
name=artifact_name, | ||
type=mlmd_artifact_type.name, | ||
uri=mlmd_artifact.uri, | ||
custom_properties=custom_properties | ||
metadata=metadata | ||
) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import packages or modules, but not classes or functions:
https://google.github.io/styleguide/pyguide.html#22-imports
especially since this
ANY
could be confused withAny
fromtyping
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll fix this. I think our sample pipelines and documentation has many violations, it'll be good to fix them too. Is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed