Airflow : dag run with execution_date = trigger_date = fixed_schedule

后端 未结 3 1055
情书的邮戳
情书的邮戳 2021-02-04 13:32

in airflow, I would like to run a dag each monday at 8am (the execution_date should be of course \"current day monday 8 am\"). The relevant parameters to set up for this workflo

3条回答
  •  佛祖请我去吃肉
    2021-02-04 13:48

    That is how airflow behaves, it always runs when the duration is completed. Detailed behavior here and airflow faq.

    But in order to somehow make it run for current week, what we can do is manipulate execution_date of DAG. That may be in form of adding 7 days to a datetime object (if weekly schedule) or may use {{ next_execution_date }} macro.

    Agreed that this is only possible if somehow dates are used in your DAG or dependencies are triggered by it.

    Just to be clear again, DAG is still running as per its normal behavior. Only thing what we trying to do is manipulate date in program/DAG.

    args = { ....
        'start_date': datetime.datetime(2018,3,18)
    }
    dag = DAG(...
        schedule_interval = "@weekly"
    )
    
    # DAG would run on 3/25/2018 for week of 18th March
    
    # but lets say we manipulate here 
    # {{ next_execution_date }} macro
    # or add 7 days 
    # So basically we are running with date 3/25/2018 instead of 3/18/2018 for the week of 18th March 
    

提交回复
热议问题