From 457f9e65aa5e4f9b76dc5da19cab1276bd8101b2 Mon Sep 17 00:00:00 2001 From: Yaqi Date: Thu, 23 Dec 2021 12:50:46 -0800 Subject: [PATCH] metadata --- sdk/python/kfp/v2/compiler/pipeline_spec_builder.py | 9 ++++++--- .../test_data/pipeline_with_after.json | 2 +- .../test_data/pipeline_with_importer.json | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sdk/python/kfp/v2/compiler/pipeline_spec_builder.py b/sdk/python/kfp/v2/compiler/pipeline_spec_builder.py index 9bff9152320..b84b9fdcba7 100644 --- a/sdk/python/kfp/v2/compiler/pipeline_spec_builder.py +++ b/sdk/python/kfp/v2/compiler/pipeline_spec_builder.py @@ -23,7 +23,6 @@ from kfp.v2.components import pipeline_channel from kfp.v2.components import pipeline_task from kfp.v2.components import placeholders -from kfp.v2.components import structures from kfp.v2.components import tasks_group from kfp.v2.components.types import artifact_types from kfp.v2.components.types import type_utils @@ -355,8 +354,12 @@ def build_importer_spec_for_task( type_schema = type_utils.get_artifact_type_schema(task.importer_spec.type_schema) importer_spec = pipeline_spec_pb2.PipelineDeploymentConfig.ImporterSpec( type_schema=type_schema, - reimport=task.importer_spec.reimport, - metadata=task.importer_spec.metadata) + reimport=task.importer_spec.reimport) + + if task.importer_spec.metadata and len(task.importer_spec.metadata) != 0: + metadata_protobuf_struct = struct_pb2.Struct() + metadata_protobuf_struct.update(task.importer_spec.metadata) + importer_spec.metadata.CopyFrom(metadata_protobuf_struct) if isinstance(task.importer_spec.artifact_uri, pipeline_channel.PipelineParameterChannel): importer_spec.artifact_uri.runtime_parameter = 'uri' diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_after.json b/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_after.json index e70c21d9f07..d835b4cbd16 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_after.json +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_after.json @@ -146,5 +146,5 @@ } }, "schemaVersion": "2.1.0", - "sdkVersion": "kfp-2.0.0-beta0" + "sdkVersion": "kfp-1.8.10" } \ No newline at end of file diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_importer.json b/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_importer.json index 37c9f59db83..476b0db9aa8 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_importer.json +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_importer.json @@ -163,7 +163,9 @@ "artifactUri": { "constant": "gs://ml-pipeline-playground/shakespeare1.txt" }, - "metadata": {}, + "metadata": { + "key": "value" + }, "typeSchema": { "schemaTitle": "system.Artifact", "schemaVersion": "0.0.1" @@ -175,7 +177,6 @@ "artifactUri": { "runtimeParameter": "uri" }, - "metadata": {}, "reimport": true, "typeSchema": { "schemaTitle": "system.Artifact",