You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Abhishek Ray (JIRA)" <ji...@apache.org> on 2019/07/05 19:17:00 UTC
[jira] [Commented] (AIRFLOW-4830) Timezone ignored if default_args
used for multiple dags
[ https://issues.apache.org/jira/browse/AIRFLOW-4830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16879495#comment-16879495 ]
Abhishek Ray commented on AIRFLOW-4830:
---------------------------------------
I think this issue should be fixed by this pull request:
[https://github.com/apache/airflow/pull/5277]
> Timezone ignored if default_args used for multiple dags
> -------------------------------------------------------
>
> Key: AIRFLOW-4830
> URL: https://issues.apache.org/jira/browse/AIRFLOW-4830
> Project: Apache Airflow
> Issue Type: Bug
> Components: DAG
> Affects Versions: 1.10.3
> Reporter: Dean
> Priority: Major
> Attachments: Screen Shot 2019-06-20 at 4.43.16 PM.png, Screen Shot 2019-06-20 at 4.45.15 PM.png
>
>
> I created a {{default_args}} dict and passed it to two different dags. In the first dag, the job was scheduled for 'America/Los_Angeles' as specified in the dict, but for the second it was in 'UTC' (it should also be 'America/Los_Angeles'.
> {code:python}
> from airflow import DAG
> from airflow.operators.python_operator import PythonOperator
> from datetime import datetime
> import logging
> from pendulum import timezone
> def msg(s, **kwargs):
> logging.info('{}: {}'.format(s, str(kwargs['execution_date'])))
> default_args = {
> 'start_date': datetime(2018, 1, 1, tzinfo=timezone('America/Los_Angeles'))
> }
> dag1 = DAG('tz_test_shared_1',
> default_args=default_args,
> catchup=True,
> schedule_interval='0 0 * * *')
> t1 = PythonOperator(
> task_id='t1',
> provide_context=True,
> op_args=['t1'],
> python_callable=msg,
> dag=dag1)
> dag2 = DAG('tz_test_shared_2',
> default_args=default_args,
> catchup=True,
> schedule_interval='0 0 * * *')
> t2 = PythonOperator(
> task_id='t2',
> provide_context=True,
> op_args=['t2'],
> python_callable=msg,
> dag=dag2)
> {code}
> See the resulting task execution times in Screen Shot 2019-06-20 at 4.45.15 PM.png. One job happens at 08:00 UTC (as expected), but the other at 00:00 UTC.
> Compare that to this version, the only difference is the dag names and {{default_args}} is repeated:
> {code:python}
> from airflow import DAG
> from airflow.operators.python_operator import PythonOperator
> from datetime import datetime
> import logging
> from pendulum import timezone
> def msg(s, **kwargs):
> logging.info('{}: {}'.format(s, str(kwargs['execution_date'])))
> default_args = {
> 'start_date': datetime(2018, 1, 1, tzinfo=timezone('America/Los_Angeles'))
> }
> dag1 = DAG('tz_test_1',
> default_args=default_args,
> catchup=True,
> schedule_interval='0 0 * * *')
> t1 = PythonOperator(
> task_id='t1',
> provide_context=True,
> op_args=['t1'],
> python_callable=msg,
> dag=dag1)
> default_args = {
> 'start_date': datetime(2018, 1, 1, tzinfo=timezone('America/Los_Angeles'))
> }
> dag2 = DAG('tz_test_2',
> default_args=default_args,
> catchup=True,
> schedule_interval='0 0 * * *')
> t2 = PythonOperator(
> task_id='t2',
> provide_context=True,
> op_args=['t2'],
> python_callable=msg,
> dag=dag2)
> {code}
> See the resulting task execution times in Screen Shot 2019-06-20 at 4.43.16 PM.png. Both happen at 08:00 UTC (as expected).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)