'How to override the arguement of a particular task in airflow DAG

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

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 overide the value of retries from 2 to 3 for t1 in the same DAG which contains default arguements of retries as 2

How can I do it.



Solution 1:[1]

Simply do:

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

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Elad Kalif