Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sdk compiler):Fix v2 compile for exit handler Fixes #5854 #5899

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sdk/python/kfp/v2/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,21 @@ def _group_to_dag_spec(
pipeline_spec_pb2.PipelineTaskSpec.TriggerPolicy(
condition=condition_string))

if isinstance(subgroup, dsl.OpsGroup) and subgroup.type == 'exit_handler':

# "punch the hole", adding inputs needed by its subgroup or tasks.
dsl_component_spec.build_component_inputs_spec(
component_spec=subgroup_component_spec,
pipeline_params=subgroup_params,
is_root_component=False,
)
dsl_component_spec.build_task_inputs_spec(
subgroup_task_spec,
subgroup_params,
tasks_in_current_dag,
is_parent_component_root,
)

# Generate dependencies section for this task.
if dependencies.get(subgroup.name, None):
group_dependencies = list(dependencies[subgroup.name])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
"inputs": {
"parameters": {
"message": {
"runtimeValue": {
"constantValue": {
"stringValue": "Hello World!"
}
}
"componentInputParameter": "pipelineparam--message"
}
}
},
Expand All @@ -43,6 +39,13 @@
}
}
}
},
"inputDefinitions": {
"parameters": {
"pipelineparam--message": {
"type": "STRING"
}
}
}
},
"comp-fail-op": {
Expand Down Expand Up @@ -147,6 +150,13 @@
"componentRef": {
"name": "comp-exit-handler-1"
},
"inputs": {
"parameters": {
"pipelineparam--message": {
"componentInputParameter": "message"
}
}
},
"taskInfo": {
"name": "exit-handler-1"
}
Expand Down Expand Up @@ -177,12 +187,24 @@
}
}
}
},
"inputDefinitions": {
"parameters": {
"message": {
"type": "STRING"
}
}
}
},
"schemaVersion": "2.0.0",
"sdkVersion": "kfp-1.6.2"
"sdkVersion": "kfp-1.6.3"
},
"runtimeConfig": {
"gcsOutputDirectory": "dummy_root"
"gcsOutputDirectory": "dummy_root",
"parameters": {
"message": {
"stringValue": "Hello World!"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def fail_op(message: str):


@dsl.pipeline(name='pipeline-with-exit-handler', pipeline_root='dummy_root')
def my_pipeline():
def my_pipeline(message: str = 'Hello World!'):

exit_task = print_op('Exit handler has worked!')

with dsl.ExitHandler(exit_task):
print_op('Hello World!')
print_op(message)
fail_op('Task failed.')


Expand Down