Skip to content
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

Add a property external_id to Artifact class #6776

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tfx/types/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ def producer_component(self, producer_component: str):
"""Set producer component of the artifact."""
self._set_system_property('producer_component', producer_component)

@property
@doc_controls.do_not_doc_in_subclasses
def external_id(self) -> str:
"""external id of the underlying artifact."""
return self._artifact.external_id

@external_id.setter
def external_id(self, external_id: str):
"""Set external id of the underlying artifact."""
self._artifact.external_id = external_id

# LINT.IfChange
@property
@doc_controls.do_not_doc_in_subclasses
Expand Down
10 changes: 10 additions & 0 deletions tfx/types/artifact_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def testArtifact(self):
self.assertEqual('MyTypeName', instance.type_name)
self.assertEqual('', instance.state)
self.assertFalse(instance.is_external)
self.assertEqual('', instance.external_id)

# Default property does not have span or split_names.
with self.assertRaisesRegex(AttributeError, "has no property 'span'"):
Expand Down Expand Up @@ -229,6 +230,14 @@ def testArtifact(self):
)
self.assertFalse(instance.get_bool_custom_property('fake_key'))

instance.mlmd_artifact.external_id = (
'mlmd://prod:owner/project_name:pipeline_name:type:artifact:100'
)
self.assertEqual(
'mlmd://prod:owner/project_name:pipeline_name:type:artifact:100',
instance.external_id,
)

self.assertEqual(
textwrap.dedent("""\
Artifact(artifact: id: 1
Expand Down Expand Up @@ -272,6 +281,7 @@ def testArtifact(self):
}
state: DELETED
name: "test_artifact"
external_id: "mlmd://prod:owner/project_name:pipeline_name:type:artifact:100"
, artifact_type: name: "MyTypeName"
properties {
key: "bool1"
Expand Down