This is an automated email from the ASF dual-hosted git repository. ash pushed a commit to branch task-sdk-first-code in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 166dab2de0f5afcf7b296537bb4c9c92912c2cca Author: Kaxil Naik <[email protected]> AuthorDate: Tue Oct 29 17:18:26 2024 +0000 Fix timezone from default_args test --- task_sdk/src/airflow/sdk/definitions/dag.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/task_sdk/src/airflow/sdk/definitions/dag.py b/task_sdk/src/airflow/sdk/definitions/dag.py index b54cddb9746..479c1ea09b8 100644 --- a/task_sdk/src/airflow/sdk/definitions/dag.py +++ b/task_sdk/src/airflow/sdk/definitions/dag.py @@ -514,11 +514,16 @@ class DAG: from airflow.utils import timezone - # TODO: Task-SDK: get default dag tz from settings - tz = timezone.utc - if instance.start_date and (tzinfo := instance.start_date.tzinfo): - tzinfo = None if tzinfo else tz - tz = pendulum.instance(instance.start_date, tz=tzinfo).timezone + start_date = instance.start_date or instance.default_args.get("start_date") + + if start_date: + if not isinstance(start_date, datetime): + start_date = timezone.parse(start_date) + tzinfo = start_date.tzinfo or settings.TIMEZONE + tz = pendulum.instance(start_date, tz=tzinfo).timezone + else: + tz = settings.TIMEZONE + return tz @has_on_success_callback.default
