You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2019/07/28 18:52:00 UTC

[jira] [Commented] (AIRFLOW-4788) prev_execution_date is not always pendulum.datetime class

    [ https://issues.apache.org/jira/browse/AIRFLOW-4788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16894766#comment-16894766 ] 

ASF subversion and git services commented on AIRFLOW-4788:
----------------------------------------------------------

Commit ab63c26e9dea054225c9caca69ce6dfebcb096d6 in airflow's branch refs/heads/master from Arlo Purcell
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=ab63c26 ]

[AIRFLOW-4981][AIRFLOW-4788] Always use pendulum DateTimes in task in… (#5654)

* [AIRFLOW-4981][AIRFLOW-4788] Always use pendulum DateTimes in task instance context

In certain situations, like when using fixed cron schedules such as `0
12 * * *`, the `execution_date`, `prev_execution_date`, and
`next_execution_date` variables in macros were native python `datetime`
objects instead of, as stated in the docs, pendulum `DateTime` objects.

> prev_execution_date is not always pendulum.datetime class
> ---------------------------------------------------------
>
>                 Key: AIRFLOW-4788
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4788
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.10.3
>            Reporter: Daniel Standish
>            Priority: Major
>
> Despite documentation on macros page, previous execution dates are in general not pendulum type.
> For one, when reading from database, UtcDateTime returns native datetime type.
> Also dag.previous_schedule returns datetime type.
> So, in general, `prev_execution_date` and `ti.previous_ti.execution_date` may be non-pendulum. 
> (there are edge cases when the context var prev_* is pendulum e.g. when there is no DR or no schedule interval or manually triggered, but in general, no.)
> The problem is, this leads to errors and confusion when using these fields in templating, when you expect it to be pendulum but it isn't.
> There are a few things to consider:
>  # make UtcDateTime sqlalchemy type return pendulum
>  # make execution date a property of TaskInstance with appropriate getter returning pendulum.
>  # Change dag.previous_schedule to return pendulum
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)