[BUG] Conditionals do not work correctly with nested workflows
- Dominant language
- Go
- Stars
- 7.5k
- Forks
- 886
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 120
Description
### Describe the bug
Consider the following code:
```
from flytekit import task, workflow, conditional
@workflow
def sub_workflow() -> bool:
some_test = do_test()
(
conditional("maybe_do_nothing")
.if_(some_test.is_true())
.then(do_nothing1())
.else_()
.then(do_nothing2())
)
return True
@workflow
def top_workflow(
input_value: bool = False,
) -> None:
(
conditional("maybe_workflow")
.if_(input_value.is_true())
.then(sub_workflow())
.else_()
.then(do_nothing3())
)
@task
def do_nothing1() -> bool:
print("do_nothing1")
return True
@task
def do_nothing2() -> bool:
print("do_nothing2")
return True
@task
def do_nothing3() -> bool:
print("do_nothing3")
return True
@task
def do_test() -> bool:
print("do_test")
return False
top_workflow(input_value=True)
````
I have top_workflow which calls a sub_workflow based on a condition. The sub_workflow does another conditional. But I see that it is executing both branches in the sub_workflow
```
do_test
do_nothing1
do_nothing2
```
### Expected behavior
The sub_workflow contitional should only execute on the branch that evaluates to true
In the example above the expected output is
```
do_test
do_nothing1
```
### Additional context to reproduce
_No response_
### Screenshots
_No response_
### Are you sure this issue hasn't been raised already?
- [x] Yes
### Have you read the Code of Conduct?
- [x] Yes
Contributor guide
Assessment
This issue has not been assessed yet.