Reputation: 1390
Is there a way for Airflow to skip current task from the PythonOperator? For example:
def execute():
if condition:
skip_current_task()
task = PythonOperator(task_id='task', python_callable=execute, dag=some_dag)
And also marking the task as "Skipped" in Airflow UI?
Upvotes: 11
Views: 13008
Reputation: 1390
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)
Upvotes: 28
Reputation: 1570
The easiest solution to skip a task:
def execute():
if condition:
return
task = PythonOperator(task_id='task', python_callable=execute, dag=some_dag)
Unfortunately, it will mark task as DONE
Upvotes: 0