Skip to content

Commit

Permalink
add sample test
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Jun 9, 2022
1 parent 947c6cb commit 64b026d
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
38 changes: 38 additions & 0 deletions sdk/python/kfp/compiler/test_data/pipeline_with_retry.py
Original file line number Diff line number Diff line change
@@ -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'))
74 changes: 74 additions & 0 deletions sdk/python/kfp/compiler/test_data/pipeline_with_retry.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 64b026d

Please sign in to comment.