| 分支算子 | BranchPythonOperator / @task.branch |
|---|---|
| 跳过语义 | 未选中分支标记 skipped |
| 常用触发规则 | all_success / all_done / one_success / none_failed |
| 典型用法 | 收尾清理任务用 all_done |
分支与收尾示意
分支与收尾示意
from airflow.operators.python import BranchPythonOperator, PythonOperator
from airflow.utils.trigger_rule import TriggerRule
choose = BranchPythonOperator(task_id="choose", python_callable=lambda: "full")
clean = PythonOperator(task_id="clean", python_callable=clean_fn,
trigger_rule=TriggerRule.ALL_DONE)下游任务默认 all_success;上游有 skipped 时也会导致下游跳过,收尾任务记得改 all_done。