From ba657deded0594ab40c67be3a7125344ef84e43a Mon Sep 17 00:00:00 2001 From: Greg Sheremeta Date: Sat, 17 Aug 2024 12:10:46 -0400 Subject: [PATCH] DRAFT WIP - do not merge - demonstration of PipelineConfig Demonstration of proposed KFP DSL PipelineConfig class. Signed-off-by: Greg Sheremeta --- .../go/pipelinespec/pipeline_spec.pb.go | 25 ++++++++++++++----- api/v2alpha1/pipeline_spec.proto | 2 +- .../kfp/compiler/pipeline_spec_builder.py | 4 ++- sdk/python/kfp/dsl/pipeline_config.py | 10 ++++++-- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/api/v2alpha1/go/pipelinespec/pipeline_spec.pb.go b/api/v2alpha1/go/pipelinespec/pipeline_spec.pb.go index edf61ebfe9b..dac55cdbc2b 100644 --- a/api/v2alpha1/go/pipelinespec/pipeline_spec.pb.go +++ b/api/v2alpha1/go/pipelinespec/pipeline_spec.pb.go @@ -2498,6 +2498,8 @@ type PipelineConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + ExamplePipelineConfig string `protobuf:"bytes,1,opt,name=example_pipeline_config,json=examplePipelineConfig,proto3" json:"example_pipeline_config,omitempty"` } func (x *PipelineConfig) Reset() { @@ -2532,6 +2534,13 @@ func (*PipelineConfig) Descriptor() ([]byte, []int) { return file_pipeline_spec_proto_rawDescGZIP(), []int{30} } +func (x *PipelineConfig) GetExamplePipelineConfig() string { + if x != nil { + return x.ExamplePipelineConfig + } + return "" +} + // The runtime config of a PipelineJob. type PipelineJob_RuntimeConfig struct { state protoimpl.MessageState @@ -6377,12 +6386,16 @@ var file_pipeline_spec_proto_rawDesc = []byte{ 0x2d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0x10, 0x0a, 0x0e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x66, 0x6c, 0x6f, 0x77, 0x2f, 0x70, 0x69, 0x70, 0x65, - 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x70, - 0x65, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x38, 0x01, 0x22, 0x48, 0x0a, 0x0e, 0x50, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x36, 0x0a, 0x17, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, + 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x50, 0x69, + 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x3c, 0x5a, 0x3a, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x66, + 0x6c, 0x6f, 0x77, 0x2f, 0x70, 0x69, 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x2f, 0x61, 0x70, + 0x69, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x69, + 0x70, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x70, 0x65, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/api/v2alpha1/pipeline_spec.proto b/api/v2alpha1/pipeline_spec.proto index 6b7651af8f9..40c1b4ae919 100644 --- a/api/v2alpha1/pipeline_spec.proto +++ b/api/v2alpha1/pipeline_spec.proto @@ -1058,5 +1058,5 @@ message PlatformDeploymentConfig { // Spec for pipeline-level config options. See PipelineConfig DSL class. message PipelineConfig { - // TODO add pipeline-level configs + string example_pipeline_config = 1; } diff --git a/sdk/python/kfp/compiler/pipeline_spec_builder.py b/sdk/python/kfp/compiler/pipeline_spec_builder.py index a2b90aca850..0cad31cf2fe 100644 --- a/sdk/python/kfp/compiler/pipeline_spec_builder.py +++ b/sdk/python/kfp/compiler/pipeline_spec_builder.py @@ -1879,7 +1879,9 @@ def create_pipeline_spec( # pipeline-level config options pipeline_config_spec = pipeline_spec_pb2.PipelineConfig() - # TODO add pipeline-level config options + if pipeline_config.example_pipeline_config is not None and pipeline_config.example_pipeline_config != "": + pipeline_config_spec.example_pipeline_config = pipeline_config.example_pipeline_config + pipeline_spec.root.CopyFrom( _build_component_spec_from_component_spec_structure(component_spec)) diff --git a/sdk/python/kfp/dsl/pipeline_config.py b/sdk/python/kfp/dsl/pipeline_config.py index 523457f1047..7a52487378d 100644 --- a/sdk/python/kfp/dsl/pipeline_config.py +++ b/sdk/python/kfp/dsl/pipeline_config.py @@ -18,7 +18,13 @@ class PipelineConfig: """PipelineConfig contains pipeline-level config options.""" def __init__(self): - pass + self.example_pipeline_config = "some-important-value" - # TODO add pipeline level configs + def set_example_pipeline_config(self, example_pipeline_config: str): + """Example of a pipeline-level config option. + Args: + example_pipeline_config: example setting to set in the PipelineConfig spec + """ + self.example_pipeline_config = example_pipeline_config + return self