notatallshaw commented on issue #7038: [AIRFLOW-4495] Allow externally 
triggered dags to run for future exec dates
URL: https://github.com/apache/airflow/pull/7038#issuecomment-578180173
 
 
   @yuqian90
   
   "Did setting start_date to the timezone you want work?"
   
   Yes, for example if you let this code run for a week:
   
       import pendulum
       from datetime import datetime
       from airflow import DAG
       from airflow.operators.dummy_operator import DummyOperator
   
       START_DATE = datetime(2020, 1, 23, 
tzinfo=pendulum.timezone('Pacific/Auckland'))
       SCHEDULE = '00 03 * * *'
       dag = DAG('nz_schedule_test', schedule_interval=SCHEDULE, 
start_date=START_DATE, catchup=True)
       dummy_task = DummyOperator(dag=dag, task_id='nz_schedule_test',)
   
   It successfully runs at the correct 3am NZ time, which is way before 
midnight UTC. But you get weird execution dates and ds_dates because Airflow 
normalizes the execution date to UTC before rendering the template or providing 
the context. So where you would normally expect Airflow to provide 2020-01-23 
as the ds date it provides the previous day 2020-01-22 (day not date, it 
literally provides yesterday not the previous schedule date because this is a 
timezone issue not a schedule issue)
   
   That's why we use the above mentioned macro system to provide dates in the 
correct timezones. With this we can happily use Airflow to schedule DAGs in 
whatever timezones is required. The only thing you still need to watch for are 
start dates and end dates and the execution date shown in the UI.
   
   Hope that helps! We've been running this successfully on 1.10.3 and 1.10.6.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to