Skip to content

Commit

Permalink
fix(sdk.v2): Fix display name support for groups (#6832)
Browse files Browse the repository at this point in the history
* fix display name for experimental tasks_group

* release note
  • Loading branch information
chensun authored Oct 29, 2021
1 parent eeb0b9c commit 0f2cab9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions sdk/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
}
},
"taskInfo": {
"name": "exit-handler-1"
"name": "Pipeline with exit handler"
}
},
"print-op": {
Expand All @@ -160,7 +160,7 @@
}
},
"taskInfo": {
"name": "print-op"
"name": "my exit handler"
},
"triggerPolicy": {
"strategy": "ALL_UPSTREAM_TASKS_COMPLETED"
Expand All @@ -178,5 +178,5 @@
}
},
"schemaVersion": "2.1.0",
"sdkVersion": "kfp-1.8.6"
"sdkVersion": "kfp-1.8.7"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
}
},
"taskInfo": {
"name": "for-loop-1"
"name": "loop through a list"
}
},
"for-loop-2": {
Expand Down Expand Up @@ -438,5 +438,5 @@
}
},
"schemaVersion": "2.1.0",
"sdkVersion": "kfp-1.8.6"
"sdkVersion": "kfp-1.8.7"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
}
},
"taskInfo": {
"name": "condition-1"
"name": "it was heads!"
},
"triggerPolicy": {
"condition": "inputs.parameter_values['pipelinechannel--flip-coin-output'] == 'heads'"
Expand All @@ -514,7 +514,7 @@
}
},
"taskInfo": {
"name": "condition-4"
"name": "it was tails!"
},
"triggerPolicy": {
"condition": "inputs.parameter_values['pipelinechannel--flip-coin-output'] == 'tails'"
Expand All @@ -535,5 +535,5 @@
}
},
"schemaVersion": "2.1.0",
"sdkVersion": "kfp-1.8.6"
"sdkVersion": "kfp-1.8.7"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions sdk/python/kfp/v2/components/experimental/tasks_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 0f2cab9

Please sign in to comment.