What parameters can be passed to Airflow @task decorator?


I am using Airflow 2.4.0.

from airflow.decorators import task
from airflow import DAG

with DAG(
        start_date=datetime(2022, 1, 1),
) as dag:
    def get_name():
        return {
            'first_name': 'Hongbo',
            'last_name': 'Miao',


Currently I am using @task(). Based on the document https://airflow.apache.org/docs/apache-airflow/stable/tutorial/taskflow.html, it seems I can also use


However, it does not include the explanation.

When I use multiple_outputs=True or multiple_outputs=False, or not it, the task still runs well. So I am wondering what is the purposes of it.

Is there a document listing all parameters for @task decorator that I can use and their actual functions? Thanks!

Asked By: Hongbo Miao



Save the multiple_outputs optional argument declared in the task_decoratory_factory, every other option passed is forwarded to the underlying Airflow Operator.

When using task decorator as-is like

def fn(): pass

the default operator is the PythonOperator.

You can explore the mandatory/optional parameters for the Airflow Operator encapsulated by the decorator to have a better idea of the signature for the specific task.

Answered By: Oluwafemi Sule
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.