如何跳过气流操作员中的任务?

zey*_*ger 7 python airflow airflow-scheduler airflow-operator

Airflow 有没有办法从 PythonOperator 跳过当前任务?例如:

def execute():
    if condition:
        skip_current_task()

task = PythonOperator(task_id='task', python_callable=execute, dag=some_dag)
Run Code Online (Sandbox Code Playgroud)

并且还在 Airflow UI 中将任务标记为“已跳过”?

zey*_*ger 14

弄清楚了!跳过任务很简单:

def execute():
    if condition:
        raise AirflowSkipException

task = PythonOperator(task_id='task', python_callable=execute, dag=some_dag)
Run Code Online (Sandbox Code Playgroud)