Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1D72E200C0B for ; Sun, 29 Jan 2017 12:42:59 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1C120160B4F; Sun, 29 Jan 2017 11:42:59 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 653B8160B36 for ; Sun, 29 Jan 2017 12:42:58 +0100 (CET) Received: (qmail 11700 invoked by uid 500); 29 Jan 2017 11:42:57 -0000 Mailing-List: contact commits-help@airflow.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.incubator.apache.org Delivered-To: mailing list commits@airflow.incubator.apache.org Received: (qmail 11691 invoked by uid 99); 29 Jan 2017 11:42:57 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Jan 2017 11:42:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 06C25C036B for ; Sun, 29 Jan 2017 11:42:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.719 X-Spam-Level: X-Spam-Status: No, score=-5.719 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id EAya4Mozh6Oc for ; Sun, 29 Jan 2017 11:42:56 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 3E2045FAE6 for ; Sun, 29 Jan 2017 11:42:55 +0000 (UTC) Received: (qmail 11677 invoked by uid 99); 29 Jan 2017 11:42:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Jan 2017 11:42:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5FE6ADFCC2; Sun, 29 Jan 2017 11:42:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bolke@apache.org To: commits@airflow.incubator.apache.org Message-Id: <45cea58ec4724f979f0f499507dfeb8e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-airflow git commit: [AIRFLOW-815] Add prev/next execution dates to template variables Date: Sun, 29 Jan 2017 11:42:54 +0000 (UTC) archived-at: Sun, 29 Jan 2017 11:42:59 -0000 Repository: incubator-airflow Updated Branches: refs/heads/v1-8-test e7f6212ca -> 180ef35c0 [AIRFLOW-815] Add prev/next execution dates to template variables This patch adds the previous/next execution dates to the default variables available in a template. Closes #2033 from danielvdende/add-execution-dates (cherry picked from commit a67e4390d2217dd0fdc3429e943cdc6c552fac73) Signed-off-by: Bolke de Bruin Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/180ef35c Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/180ef35c Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/180ef35c Branch: refs/heads/v1-8-test Commit: 180ef35c090928f491a1d09c104e3bec4b427302 Parents: e7f6212 Author: Daniel van der Ende Authored: Sun Jan 29 12:41:36 2017 +0100 Committer: Bolke de Bruin Committed: Sun Jan 29 12:42:47 2017 +0100 ---------------------------------------------------------------------- airflow/models.py | 5 +++++ docs/code.rst | 2 ++ 2 files changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/180ef35c/airflow/models.py ---------------------------------------------------------------------- diff --git a/airflow/models.py b/airflow/models.py index b9015eb..b9af58e 100755 --- a/airflow/models.py +++ b/airflow/models.py @@ -1474,6 +1474,9 @@ class TaskInstance(Base): yesterday_ds = (self.execution_date - timedelta(1)).isoformat()[:10] tomorrow_ds = (self.execution_date + timedelta(1)).isoformat()[:10] + prev_execution_date = task.dag.previous_schedule(self.execution_date) + next_execution_date = task.dag.following_schedule(self.execution_date) + ds_nodash = ds.replace('-', '') ts_nodash = ts.replace('-', '').replace(':', '') yesterday_ds_nodash = yesterday_ds.replace('-', '') @@ -1543,6 +1546,8 @@ class TaskInstance(Base): 'dag_run': dag_run, 'run_id': run_id, 'execution_date': self.execution_date, + 'prev_execution_date': prev_execution_date, + 'next_execution_date': next_execution_date, 'latest_date': ds, 'macros': macros, 'params': params, http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/180ef35c/docs/code.rst ---------------------------------------------------------------------- diff --git a/docs/code.rst b/docs/code.rst index 0e1993e..fabe6db 100644 --- a/docs/code.rst +++ b/docs/code.rst @@ -127,6 +127,8 @@ Variable Description ``{{ ts }}`` same as ``execution_date.isoformat()`` ``{{ ts_nodash }}`` same as ``ts`` without ``-`` and ``:`` ``{{ execution_date }}`` the execution_date, (datetime.datetime) +``{{ prev_execution_date }}`` the previous execution date (if available) (datetime.datetime) +``{{ next_execution_date }}`` the next execution date (datetime.datetime) ``{{ dag }}`` the DAG object ``{{ task }}`` the Task object ``{{ macros }}`` a reference to the macros package, described below