feat(sdk): add workaround for google artifact (support custom artifact types pt. 4) (#8279)

This commit is contained in:
Connor McCarthy 2022-09-19 16:32:38 -06:00 committed by GitHub
parent 0cb0d99d69
commit 8ab690f3ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -331,7 +331,11 @@ def create_artifact_instance(
artifact_cls = artifact_types._SCHEMA_TITLE_TO_TYPE.get(
schema_title, artifact_cls)
return artifact_cls(
return artifact_cls._from_executor_fields(
uri=runtime_artifact.get('uri', ''),
name=runtime_artifact.get('name', ''),
metadata=runtime_artifact.get('metadata', {}),
) if hasattr(artifact_cls, '_from_executor_fields') else artifact_cls(
uri=runtime_artifact.get('uri', ''),
name=runtime_artifact.get('name', ''),
metadata=runtime_artifact.get('metadata', {}),

View File

@ -1007,10 +1007,19 @@ class VertexDataset:
schema_title = 'google.VertexDataset'
schema_version = '0.0.0'
def __init__(self, name: str, uri: str, metadata: dict) -> None:
self.name = name
self.uri = uri
self.metadata = metadata
@classmethod
def _from_executor_fields(
cls,
name: str,
uri: str,
metadata: dict,
) -> 'VertexDataset':
instance = VertexDataset()
instance.name = name
instance.uri = uri
instance.metadata = metadata
return instance
@property
def path(self) -> str:
@ -1132,7 +1141,7 @@ class TestDictToArtifact(parameterized.TestCase):
self.assertIsInstance(
executor.create_artifact_instance(runtime_artifact), expected_type)
def test_dict_to_artifact_nonkfp_artifact(self):
def test_dict_to_artifact_google_artifact(self):
runtime_artifact = {
'metadata': {},
'name': 'input_artifact_one',