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

add more core samples in the sample test #2030

Merged
merged 8 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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: 10 additions & 12 deletions samples/core/pipeline_transformers/pipeline_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@
import kfp
from kfp import dsl


def random_failure_op(exit_codes):
"""A component that fails randomly."""
def print_op(msg):
"""Print a message."""
return dsl.ContainerOp(
name='random_failure',
image='python:alpine3.6',
command=['python', '-c'],
arguments=['import random; import sys; exit_code = random.choice(sys.argv[1].split(",")); print(exit_code); sys.exit(exit_code)', exit_codes]
name='Print',
image='alpine:3.6',
command=['echo', msg],
)

def add_retry(op):
op.set_retry(5)
def add_annotation(op):
op.add_pod_annotation(name='hobby', value='football')
return op

@dsl.pipeline(
name='Retry random failures',
description='The pipeline includes two steps which fail randomly. It shows how to use ContainerOp(...).set_retry(...).'
)
def retry_sample_pipeline():
op1 = random_failure_op('0,1,2,3')
op2 = random_failure_op('0,1')
dsl.get_pipeline_conf().add_op_transformer(add_retry)
op1 = print_op('hey, what are you up to?')
op2 = print_op('train my model.')
dsl.get_pipeline_conf().add_op_transformer(add_annotation)

if __name__ == '__main__':
kfp.compiler.Compiler().compile(retry_sample_pipeline, __file__ + '.zip')
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
name="VolumeOp Basic",
description="A Basic Example on VolumeOp Usage."
)
def volumeop_basic(size):
def volumeop_basic(size='10M'):
vop = dsl.VolumeOp(
name="create_pvc",
resource_name="my-pvc",
modes=dsl.VOLUME_MODE_RWM,
modes=dsl.VOLUME_MODE_RWO,
gaoning777 marked this conversation as resolved.
Show resolved Hide resolved
size=size
)

Expand Down
4 changes: 4 additions & 0 deletions test/sample_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ spec:
- xgboost_training_cm
- lightweight_component
- dsl_static_type_checking
- pipeline_transformers
- secret
- sidecar
- volume_ops
gaoning777 marked this conversation as resolved.
Show resolved Hide resolved
# Build and push image
- name: build-image-by-dockerfile
inputs:
Expand Down