Skip to content

Instantly share code, notes, and snippets.

@ftnext
Last active November 11, 2023 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ftnext/9dd64bd49bb1443c0eda4734a2a18a7f to your computer and use it in GitHub Desktop.
Save ftnext/9dd64bd49bb1443c0eda4734a2a18a7f to your computer and use it in GitHub Desktop.
# See https://gist.github.com/ftnext/4b87d23d1671bb45e2fa3bf2dcce2739
from kfp import compiler, dsl
from kfp.components import func_to_container_op
@func_to_container_op
def print_op(message: str):
print(message)
@func_to_container_op
def fail_op(message: str):
import sys
print(message)
sys.exit(1)
@dsl.pipeline(
name="tutorial-control-flows-exithandler",
description="This example fails. Use kfp.dsl.ExitHandler",
)
def control_flows_pipeline():
start_print_task = print_op("Pipeline start")
fail_task = fail_op("This fails!").after(start_print_task)
end_print_task = print_op("Pipeline end").after(fail_task)
if __name__ == "__main__":
compiler.Compiler().compile(control_flows_pipeline, __file__ + ".yaml")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment