Skip to content
Discussion options

You must be logged in to vote

Hey @xiki-tempula, you can do this using a DAG that will "recurse" on itself:

from hera.workflows import DAG, Task, Workflow, script

@script()
def random_roll():
    import random

    print(random.randint(1, 6))

with Workflow(generate_name="recursive-dag-", entrypoint="dag") as w:
    with DAG(name="dag") as dag:
        random_number = random_roll(name="roll")
        recurse = Task(
            name="recurse-if-not-six",
            template=dag,
            when=f"{random_number.result} != 6",
        )
        random_number >> recurse

There is also a recursive steps example if that's easier

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@elliotgunton
Comment options

Answer selected by elliotgunton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants