Skip to content
Open
Changes from all 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
33 changes: 33 additions & 0 deletions codes/graph_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from kfp import components, dsl

@components.func_to_container_op
def task_op() -> int:
from random import randint
return randint(1, 10)


@components.func_to_container_op
def print_op(message: str):
print(message)


@dsl.graph_component
def train_loop(input: int):
with dsl.Condition(input >= 6):
print_op('final: ' + str(input))

with dsl.Condition(input < 6):
op = task_op()
train_loop(op.output)


@dsl.pipeline()
def my_pipeline():
op = task_op()
tr_op = train_loop(op.output)
tr_op.after(op)


if __name__ == '__main__':
import kfp.compiler as compiler
compiler.Compiler().compile(my_pipeline, (__file__ + '.yaml').replace('.py', ''))