diff --git a/sdk/python/kfp/compiler/test_data/pipeline_with_retry.py b/sdk/python/kfp/compiler/test_data/pipeline_with_retry.py new file mode 100644 index 000000000000..050b04e72224 --- /dev/null +++ b/sdk/python/kfp/compiler/test_data/pipeline_with_retry.py @@ -0,0 +1,38 @@ +# Copyright 2022 The Kubeflow Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from kfp import compiler +from kfp import dsl + + +@dsl.component +def add(a: float, b: float) -> float: + return a + b + + +@dsl.pipeline(name='test-pipeline') +def my_pipeline(a: float = 1, b: float = 7): + add_task = add(a=a, b=b) + add_task.set_retry( + num_retries=3, + backoff_duration='30s', + backoff_factor=1.0, + backoff_max_duration='3h', + ) + + +if __name__ == '__main__': + compiler.Compiler().compile( + pipeline_func=my_pipeline, + package_path=__file__.replace('.py', '.yaml')) diff --git a/sdk/python/kfp/compiler/test_data/pipeline_with_retry.yaml b/sdk/python/kfp/compiler/test_data/pipeline_with_retry.yaml new file mode 100644 index 000000000000..13f5aa193026 --- /dev/null +++ b/sdk/python/kfp/compiler/test_data/pipeline_with_retry.yaml @@ -0,0 +1,74 @@ +components: + comp-add: + executorLabel: exec-add + inputDefinitions: + parameters: + a: + parameterType: NUMBER_DOUBLE + b: + parameterType: NUMBER_DOUBLE + outputDefinitions: + parameters: + Output: + parameterType: NUMBER_DOUBLE +deploymentSpec: + executors: + exec-add: + container: + args: + - --executor_input + - '{{$}}' + - --function_to_execute + - add + command: + - sh + - -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-alpha.5'\ + \ && \"$0\" \"$@\"\n" + - sh + - -ec + - 'program_path=$(mktemp -d) + + printf "%s" "$0" > "$program_path/ephemeral_component.py" + + python3 -m kfp.components.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@" + + ' + - "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\ + \ *\n\ndef add(a: float, b: float) -> float:\n return a + b\n\n" + image: python:3.7 +pipelineInfo: + name: test-pipeline +root: + dag: + tasks: + add: + cachingOptions: + enableCache: true + componentRef: + name: comp-add + inputs: + parameters: + a: + componentInputParameter: a + b: + componentInputParameter: b + retryPolicy: + backoffDuration: 30s + backoffFactor: 1.0 + backoffMaxDuration: 3600s + maxRetryCount: 3 + taskInfo: + name: add + inputDefinitions: + parameters: + a: + defaultValue: 1.0 + parameterType: NUMBER_DOUBLE + b: + defaultValue: 7.0 + parameterType: NUMBER_DOUBLE +schemaVersion: 2.1.0 +sdkVersion: kfp-2.0.0-alpha.5