'DAG run as per timezone

I want to run my dag as per new york time zone. As the data comes as per the new york time zone and dag fails for the initial runs and skips last runs data as well since UTC is 4 hours ahead and the day gets completed for UTC 4 hours earlier than for new york.

I have done

timezone = pendulum.timezone("America/New_York")

default_args = {
    'depends_on_past': False,
    'start_date': pendulum.datetime(2022, 5, 13, tzinfo=timezone),
...
}

test_dag = DAG(
    'test_data_import_tz', default_args=default_args,
    schedule_interval="0 * * * *", catchup=False)


DAG CODE works with:
yesterday_report_date = context.get('yesterday_ds_nodash')
report_date = context.get('ds_nodash')

But when the DAG runs as per UTC only and the initial run fails as data is not present.

enter image description here

Dag Run times are: 2022-05-13T00:00:00+00:00 2022-05-13T01:00:00+00:00 and so on

whereas I want this to start from 2022-05-13T04:00:00+00:00 2022-05-13T05:00:00+00:00



Sources

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

Source: Stack Overflow

Solution Source