-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): add retry policy support to kfp v2 (#7867)
* depend on kfp-pipeline-spec>=0.1.16 * implement RetryPolicy structure * implement RetryPolicy structure tests * implement .set_retry method on PipelineTask * implement retry policy compilation logic * implement compiler tests for retry * implement pipeline with retry compilation test * add release note * clean up
- Loading branch information
1 parent
2d81e7b
commit 850a750
Showing
9 changed files
with
339 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
sdk/python/kfp/compiler/test_data/pipelines/pipeline_with_retry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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) | ||
|
||
|
||
if __name__ == '__main__': | ||
compiler.Compiler().compile( | ||
pipeline_func=my_pipeline, | ||
package_path=__file__.replace('.py', '.yaml')) |
74 changes: 74 additions & 0 deletions
74
sdk/python/kfp/compiler/test_data/pipelines/pipeline_with_retry.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 0s | ||
backoffFactor: 2.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.