For a pipeline like below, sensor was set to softfail= True
I’m trying to figure out how to only skip certain tasks when the sensor fails. For example only have B and D fail but still execute C and E. Many thanks for your help.
Sensor A >> B >> C >> D >> E
Advertisement
Answer
I think you could use TriggerRule
(https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html#concepts-trigger-rules)
e.g
JavaScript
x
17
17
1
with DAG(dag_id='branch',
2
start_date=datetime(2022, 8, 30),
3
max_active_runs=1,
4
schedule_interval=None,
5
catchup=False
6
) as dag:
7
8
#DummyOperators
9
a = DummyOperator(task_id='a')
10
b = DummyOperator(task_id='b') # assume failed
11
c = DummyOperator(
12
task_id='c',
13
trigger_rule=TriggerRule.one_failed
14
)
15
16
a >> b >> c
17