How to Implement a Looping Workflow in Hera Based on a Script's Output Condition? #1349
Answered
by
elliotgunton
xiki-tempula
asked this question in
Q&A
-
Hi, I have an Argo workflow script that takes in two arguments, A, B, C = script(A, B)
while C:
A, B, C = script(A, B) How can I implement this workflow using Hera? Any guidance would be greatly appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
elliotgunton
Mar 28, 2025
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
elliotgunton
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @xiki-tempula, you can do this using a DAG that will "recurse" on itself:
There is also a recursive steps example if that's easier