本文介绍了气流跳过当前任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Airflow是否可以从(Python)Operator中跳过当前任务?例如:
Is there a way for Airflow to skip current task from within the (Python)Operator? For example:
def execute():
if condition:
skip_current_task()
task = PythonOperator(task_id='task', python_callable=execute, dag=some_dag)
跳过下游任务不适合我(此答案中提出的解决方案:),以及分支。有没有一种方法可以从操作员内部将任务的状态标记为跳过
?
Skipping downstream tasks doesn't suit me (a solution proposed in this answer: How to skip tasks on Airflow?), as well as branching. Is there a way for a task to mark its state as skipped
from within the Operator?
推荐答案
想通了!跳过任务很容易:
Figured it out! Skipping task is as easy as:
def execute():
if condition:
raise AirflowSkipException
task = PythonOperator(task_id='task', python_callable=execute, dag=some_dag)
这篇关于气流跳过当前任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!