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

feat(sdk): support writing TASK_FINAL_STATUS parameter type #9080

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
22 changes: 22 additions & 0 deletions sdk/python/kfp/compiler/compiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,28 @@ def test_use_task_final_status_in_non_exit_op_yaml(self):
def my_pipeline(text: bool):
print_op()

def test_task_final_status_parameter_type_is_used(self):
# previously compiled to STRUCT type, so checking that this is updated

@dsl.component
def identity(string: str) -> str:
return string

@dsl.component
def exit_comp(status: dsl.PipelineTaskFinalStatus):
print(status)

@dsl.pipeline
def my_pipeline():
exit_task = exit_comp()
with dsl.ExitHandler(exit_task=exit_task):
identity(string='hi')

self.assertEqual(
my_pipeline.pipeline_spec.components['comp-exit-comp']
.input_definitions.parameters['status'].parameter_type,
pipeline_spec_pb2.ParameterType.TASK_FINAL_STATUS)

def test_compile_parallel_for_with_valid_parallelism(self):

@dsl.component
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/kfp/compiler/pipeline_spec_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def _build_component_spec_from_component_spec_structure(
# Special handling for PipelineTaskFinalStatus first.
if type_utils.is_task_final_status_type(input_spec.type):
component_spec.input_definitions.parameters[
input_name].parameter_type = pipeline_spec_pb2.ParameterType.STRUCT
input_name].parameter_type = pipeline_spec_pb2.ParameterType.TASK_FINAL_STATUS
component_spec.input_definitions.parameters[
input_name].is_optional = True
if input_spec.description:
Expand Down
12 changes: 6 additions & 6 deletions sdk/python/test_data/pipelines/pipeline_as_exit_task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ components:
parameters:
status:
isOptional: true
parameterType: STRUCT
parameterType: TASK_FINAL_STATUS
comp-exit-handler-1:
dag:
tasks:
Expand Down Expand Up @@ -129,7 +129,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand All @@ -156,7 +156,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand All @@ -183,7 +183,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand All @@ -210,7 +210,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand Down Expand Up @@ -262,4 +262,4 @@ root:
isOptional: true
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.0.0-beta.16
sdkVersion: kfp-2.0.0-beta.17
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ components:
parameters:
status:
isOptional: true
parameterType: STRUCT
parameterType: TASK_FINAL_STATUS
user_input:
parameterType: STRING
comp-fail-op:
Expand Down Expand Up @@ -68,7 +68,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand Down Expand Up @@ -99,7 +99,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand All @@ -126,7 +126,7 @@ deploymentSpec:
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.16'\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.17'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
Expand Down Expand Up @@ -180,4 +180,4 @@ root:
isOptional: true
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.0.0-beta.16
sdkVersion: kfp-2.0.0-beta.17
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ components:
parameters:
status:
isOptional: true
parameterType: STRUCT
parameterType: TASK_FINAL_STATUS
user_input:
parameterType: STRING
comp-print-op:
Expand Down Expand Up @@ -92,4 +92,4 @@ root:
isOptional: true
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.0.0-beta.16
sdkVersion: kfp-2.0.0-beta.17