GitHub user Chais edited a discussion: ShortCircuitOperator not
short-circuiting as expected with expanded tasks
Here's my DAG:
```python
import random
from typing import List
import pendulum
from airflow.decorators import dag, task
@dag(
"test_foo",
schedule=None,
start_date=pendulum.now(),
render_template_as_native_obj=True,
dag_display_name="Test random things",
)
def test_foo():
@task.python
def start() -> List[int]:
return [i for i in range(10)]
@task.short_circuit
def step_one(i: int) -> bool:
print(f"Hello from task {i}")
return random.random() >= 0.5
@task.python
def step_two(do: bool):
print(f"{"D" if do else "Not d"}oing stuff")
step_two.expand(do=step_one.expand(i=start()))
test_foo()
```
This results in 21 tasks total, as expected. My issue, or misunderstanding
maybe, is that in `step_one` if the output is `False` the ShortCircuitOperator
logs `No downstream tasks; nothing to do`, even though there clearly is one for
each task.
How do I get this to behave as expected?
GitHub link: https://github.com/apache/airflow/discussions/43816
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]