question about Complex depends condition in Hera #541
-
Hello Hera workflow team. I have a question about complex condition in hera workflow. I am currently using argo workflow on my complex job processing and have decided to change from yaml to hera's. but I wonder about the proper way to create complex workflow in Hera like argo workflow yaml. for example, my argo workflow yaml has these conditions: - name: complex-conditions
depends: (decoder.Skipped && extractor.Skipped) || (decoder.Succeeded || extractor.Succeeded)
...
...
- name: complex-condition-2
depends: (decoder.Skipped && filecheck.Skipped && extractor.Omitted) || (decoder.Succeeded || redictor.Succeeded)
...
... parentheses depends is here. I thought that the with Workflow(...) as w:
example_function = Task('example-function', RandConditional)
example_function2 = Task('example-function2', RandConditional)
example_function3 = Task('example-function3', RandConditional)
example_function4 = Task('example-function4', RandConditional)
example_function5 = Task('example-function5', RandConditional)
example_function.next(example_function2)
example_function.next(example_function3)
example_function.next(example_function4)
example_function2.next(example_function5, Operator.And, TaskResult.Failed)
example_function3.next(example_function5, Operator.And, TaskResult.Succeeded)
example_function4.next(example_function5, Operator.And, TaskResult.Succeeded) this code to - name: example-function
template: example-function
- depends: example-function
name: example-function2
template: example-function2
- depends: example-function
name: example-function3
template: example-function3
- depends: example-function
name: example-function4
template: example-function4
- depends: example-function2.Failed && example-function3.Succeeded && example-function4.Succeeded
name: example-function5
template: example-function5 but ...
...
example_function.next(example_function3)
example_function.next(example_function4)
example_function2.next(example_function5, Operator.And, TaskResult.Failed)
example_function3.next(example_function5, Operator.And, TaskResult.Succeeded)
example_function4.next(example_function5, Operator.And, TaskResult.Succeeded)
example_function2.next(example_function5, Operator.Or, TaskResult.Success)
example_function3.next(example_function5, Operator.And, TaskResult.Success)
... I expected complex depends but i got #expected
- depends: example-function2.Failed && example-function3.Succeeded && example-function4.Succeeded || example-function2.Succeedeed && example-function3.Succeedeed
name: example-function5
template: example-function5
# ValueError: example-function2 already in example-function5's depends: example-function2.Failed && example-function3.Succeeded && example-function4.Succeeded I want to any suggestion on these problem. I read manual and hera's issue many times, but i cannot found. How to I solve this situations? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Hi @sparkstar! Thank you for the question! Any chance you checked out the Hera expr module? It's supposed to help create these complex expressions. Once you have an expression, you can modify the |
Beta Was this translation helpful? Give feedback.
-
Thanks. I will try to use expr. |
Beta Was this translation helpful? Give feedback.
-
@sparkstar I am closing this for now. If you'd like to further discuss the use of expression feel free to reopen this issue! Thanks again for the question :) |
Beta Was this translation helpful? Give feedback.
Hi @sparkstar! Thank you for the question! Any chance you checked out the Hera expr module? It's supposed to help create these complex expressions. Once you have an expression, you can modify the
Task.depends
field manually. Hera cannot capture the enormous complexity of thedepends
field via pure functions so we went with anexpr
module that allows expressing this complexity, plus made thedepends
field a public attribute so the condition can be set! Does this help?