airflow

How to override the argument of a particular task in airflow DAG


I have a DAG which contains two tasks. The Dag has been created like this:

default_args = {
    'catchup': False,
    'depends_on_past': False,
    'start_date': datetime(2022, 1, 30),
    'retries': '2',
    'retry_delay': timedelta(minutes=3),
    'queue': us_constants.CELERY_QUEUE
}

with DAG(dag.dag_id+'.'+task_id, default_args=default_args, schedule_interval=dag.schedule_interval) as temp_dag:
    
   t0 = DummyOperator(task_id='t0')
   
   t1 = DummyOperator(task_id='t1')

Now I want to override the value of retries from 2 to 3 for t1 in the same DAG which contains default arguments of retries as 2

How can I do that?


Solution

  • Simply do:

    t1 = DummyOperator(task_id='t1', retries=3)
    

    parameters passed on operator level take precedence over values set in default_args.