diff --git a/sdk/RELEASE.md b/sdk/RELEASE.md index 231858833c2..276a09c7f77 100644 --- a/sdk/RELEASE.md +++ b/sdk/RELEASE.md @@ -17,6 +17,7 @@ ## Bug Fixes and Other Changes * Fix importer ignoring reimport setting, and switch to Protobuf.Value for import uri [\#6827](https://github.com/kubeflow/pipelines/pull/6827) +* Fix display name support for groups [\#6832](https://github.com/kubeflow/pipelines/pull/6832) ## Documentation Updates diff --git a/sdk/python/kfp/v2/compiler/experimental/pipeline_spec_builder.py b/sdk/python/kfp/v2/compiler/experimental/pipeline_spec_builder.py index b2339c57584..688f69fceee 100644 --- a/sdk/python/kfp/v2/compiler/experimental/pipeline_spec_builder.py +++ b/sdk/python/kfp/v2/compiler/experimental/pipeline_spec_builder.py @@ -729,7 +729,7 @@ def build_task_spec_for_group( A PipelineTaskSpec object representing the group. """ pipeline_task_spec = pipeline_spec_pb2.PipelineTaskSpec() - pipeline_task_spec.task_info.name = group.name + pipeline_task_spec.task_info.name = group.display_name or group.name pipeline_task_spec.component_ref.name = ( component_utils.sanitize_component_name(group.name)) diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.json b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.json index 28249e636d0..1de61289bda 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.json +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.json @@ -137,7 +137,7 @@ } }, "taskInfo": { - "name": "exit-handler-1" + "name": "Pipeline with exit handler" } }, "print-op": { @@ -160,7 +160,7 @@ } }, "taskInfo": { - "name": "print-op" + "name": "my exit handler" }, "triggerPolicy": { "strategy": "ALL_UPSTREAM_TASKS_COMPLETED" @@ -178,5 +178,5 @@ } }, "schemaVersion": "2.1.0", - "sdkVersion": "kfp-1.8.6" + "sdkVersion": "kfp-1.8.7" } \ No newline at end of file diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.py b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.py index fb88b5252f9..a0c1b496770 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.py +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_exit_handler.py @@ -54,9 +54,10 @@ @dsl.pipeline(name='pipeline-with-exit-handler') def my_pipeline(message: str = 'Hello World!'): - exit_task = print_op(msg='Exit handler has worked!') + exit_task = print_op( + msg='Exit handler has worked!').set_display_name('my exit handler') - with dsl.ExitHandler(exit_task): + with dsl.ExitHandler(exit_task, name='Pipeline with exit handler'): print_op(msg=message) fail_op(msg='Task failed.') diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.json b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.json index 9a20d3dde4d..8ed0bb61700 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.json +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.json @@ -383,7 +383,7 @@ } }, "taskInfo": { - "name": "for-loop-1" + "name": "loop through a list" } }, "for-loop-2": { @@ -438,5 +438,5 @@ } }, "schemaVersion": "2.1.0", - "sdkVersion": "kfp-1.8.6" + "sdkVersion": "kfp-1.8.7" } \ No newline at end of file diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.py b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.py index 522b97a67cb..7567535cdca 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.py +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_loops.py @@ -79,7 +79,7 @@ def my_pipeline(loop_parameter: List[str]): # Loop argument is from a pipeline input - with dsl.ParallelFor(loop_parameter) as item: + with dsl.ParallelFor(loop_parameter, name='loop through a list') as item: print_op(msg=item) # Loop argument is from a component output diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.json b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.json index 59c34e2b35a..b4c4050f0ba 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.json +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.json @@ -490,7 +490,7 @@ } }, "taskInfo": { - "name": "condition-1" + "name": "it was heads!" }, "triggerPolicy": { "condition": "inputs.parameter_values['pipelinechannel--flip-coin-output'] == 'heads'" @@ -514,7 +514,7 @@ } }, "taskInfo": { - "name": "condition-4" + "name": "it was tails!" }, "triggerPolicy": { "condition": "inputs.parameter_values['pipelinechannel--flip-coin-output'] == 'tails'" @@ -535,5 +535,5 @@ } }, "schemaVersion": "2.1.0", - "sdkVersion": "kfp-1.8.6" + "sdkVersion": "kfp-1.8.7" } \ No newline at end of file diff --git a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.py b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.py index ea9c84db652..07cbb023545 100644 --- a/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.py +++ b/sdk/python/kfp/v2/compiler_cli_tests/test_data/experimental_pipeline_with_nested_conditions_yaml.py @@ -70,14 +70,14 @@ def random_num_op(low, high): description='Shows how to use dsl.Condition().') def my_pipeline(): flip = flip_coin_op() - with dsl.Condition(flip.output == 'heads'): + with dsl.Condition(flip.output == 'heads', name='it was heads!'): random_num_head = random_num_op(0, 9)() with dsl.Condition(random_num_head.output > 5): print_op(msg='heads and %s > 5!' % random_num_head.output) with dsl.Condition(random_num_head.output <= 5): print_op(msg='heads and %s <= 5!' % random_num_head.output) - with dsl.Condition(flip.output == 'tails'): + with dsl.Condition(flip.output == 'tails', name='it was tails!'): random_num_tail = random_num_op(10, 19)() with dsl.Condition(random_num_tail.output > 15): print_op(msg='tails and %s > 15!' % random_num_tail.output) diff --git a/sdk/python/kfp/v2/components/experimental/tasks_group.py b/sdk/python/kfp/v2/components/experimental/tasks_group.py index 1c142c7f2a2..244a48da86d 100644 --- a/sdk/python/kfp/v2/components/experimental/tasks_group.py +++ b/sdk/python/kfp/v2/components/experimental/tasks_group.py @@ -42,7 +42,7 @@ class TasksGroup: group_type: The type of the TasksGroup. tasks: A list of all PipelineTasks in this group. groups: A list of TasksGroups in this group. - name: The optional user given name of the group. + display_name: The optional user given name of the group. dependencies: A list of tasks or groups this group depends on. """ @@ -55,12 +55,12 @@ def __init__( Args: group_type: The type of the group. - name: Optional; the name of the group. + name: Optional; the name of the group. Used as display name in UI. """ self.group_type = group_type self.tasks = list() self.groups = list() - self.name = name + self.display_name = name self.dependencies = [] def __enter__(self): @@ -80,10 +80,9 @@ def _make_name_unique(self): if not pipeline_context.Pipeline.get_default_pipeline(): raise ValueError('Default pipeline not defined.') - self.name = ( - self.group_type + '-' + - ('' if self.name is None else self.name + '-') + pipeline_context - .Pipeline.get_default_pipeline().get_next_group_id()) + group_id = pipeline_context.Pipeline.get_default_pipeline( + ).get_next_group_id() + self.name = f'{self.group_type}-{group_id}' self.name = self.name.replace('_', '-') def remove_task_recursive(self, task: pipeline_task.PipelineTask):