Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ assists users migrating to a new version.

## Airflow Master

### Modification to `ts_nodash` macro
`ts_nodash` previously contained TimeZone information alongwith execution date. For Example: `20150101T000000+0000`. This is not user-friendly for file or folder names which was a popular use case for `ts_nodash`. Hence this behavior has been changed and using `ts_nodash` will no longer contain TimeZone information, restoring the pre-1.10 behavior of this macro. And a new macro `ts_nodash_with_tz` has been added which can be used to get a string with execution date and timezone info without dashes.

Examples:
* `ts_nodash`: `20150101T000000`
* `ts_nodash_with_tz`: `20150101T000000+0000`

### New `dag_processor_manager_log_location` config option

The DAG parsing manager log now by default will be log into a file, where its location is
Expand Down
4 changes: 3 additions & 1 deletion airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,8 @@ def get_template_context(self, session=None):
prev_ds_nodash = prev_ds.replace('-', '')

ds_nodash = ds.replace('-', '')
ts_nodash = ts.replace('-', '').replace(':', '')
ts_nodash = self.execution_date.strftime('%Y%m%dT%H%M%S')
ts_nodash_with_tz = ts.replace('-', '').replace(':', '')
yesterday_ds_nodash = yesterday_ds.replace('-', '')
tomorrow_ds_nodash = tomorrow_ds.replace('-', '')

Expand Down Expand Up @@ -1939,6 +1940,7 @@ def __repr__(self):
'ds_nodash': ds_nodash,
'ts': ts,
'ts_nodash': ts_nodash,
'ts_nodash_with_tz': ts_nodash_with_tz,
'yesterday_ds': yesterday_ds,
'yesterday_ds_nodash': yesterday_ds_nodash,
'tomorrow_ds': tomorrow_ds,
Expand Down
13 changes: 7 additions & 6 deletions docs/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Sensors
.. _macros:

Macros
---------
------
Here's a list of variables and macros that can be used in templates


Expand All @@ -284,19 +284,20 @@ Variable Description
``{{ ds }}`` the execution date as ``YYYY-MM-DD``
``{{ ds_nodash }}`` the execution date as ``YYYYMMDD``
``{{ prev_ds }}`` the previous execution date as ``YYYY-MM-DD``
if ``{{ ds }}`` is ``2016-01-08`` and ``schedule_interval`` is ``@weekly``,
if ``{{ ds }}`` is ``2018-01-08`` and ``schedule_interval`` is ``@weekly``,
``{{ prev_ds }}`` will be ``2016-01-01``
``{{ prev_ds_nodash }}`` the previous execution date as ``YYYYMMDD`` if exists, else ``None`
``{{ next_ds }}`` the next execution date as ``YYYY-MM-DD``
if ``{{ ds }}`` is ``2016-01-01`` and ``schedule_interval`` is ``@weekly``,
``{{ next_ds }}`` will be ``2016-01-08``
if ``{{ ds }}`` is ``2018-01-01`` and ``schedule_interval`` is ``@weekly``,
``{{ next_ds }}`` will be ``2018-01-08``
``{{ next_ds_nodash }}`` the next execution date as ``YYYYMMDD`` if exists, else ``None`
``{{ yesterday_ds }}`` the day before the execution date as ``YYYY-MM-DD``
``{{ yesterday_ds_nodash }}`` the day before the execution date as ``YYYYMMDD``
``{{ tomorrow_ds }}`` the day after the execution date as ``YYYY-MM-DD``
``{{ tomorrow_ds_nodash }}`` the day after the execution date as ``YYYYMMDD``
``{{ ts }}`` same as ``execution_date.isoformat()``
``{{ ts_nodash }}`` same as ``ts`` without ``-`` and ``:``
``{{ ts }}`` same as ``execution_date.isoformat()``. Example: ``2018-01-01T00:00:00+00:00``
``{{ ts_nodash }}`` same as ``ts`` without ``-``, ``:`` and TimeZone info. Example: ``20180101T000000``
``{{ ts_nodash_with_tz }}`` same as ``ts`` without ``-`` and ``:``. Example: ``20180101T000000+0000``
``{{ 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)
Expand Down
3 changes: 2 additions & 1 deletion tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ def test_task_get_template(self):
self.assertEquals(context['prev_ds_nodash'], '20141231')

self.assertEquals(context['ts'], '2015-01-01T00:00:00+00:00')
self.assertEquals(context['ts_nodash'], '20150101T000000+0000')
self.assertEquals(context['ts_nodash'], '20150101T000000')
self.assertEquals(context['ts_nodash_with_tz'], '20150101T000000+0000')

self.assertEquals(context['yesterday_ds'], '2014-12-31')
self.assertEquals(context['yesterday_ds_nodash'], '20141231')
Expand Down