You can do this via the "macros" section in a plugin:
https://airflow.apache.org/plugins.html#example

On Tue, May 28, 2019 at 12:42 PM Shaw, Damian P. <
[email protected]> wrote:

> Hi all,
>
>
>
> Is there a way to create template variables (e.g. ‘ds’, ‘ds_nodash’, etc.)
> that are available to every situation where Airflow renders templates? Or
> otherwise is there a best practice on providing these?
>
>
>
> My motivation is I am developing an Airflow environment for my business
> users. To make it easy for them I have created several custom date
> variables (they are set at the end of the tasks processing period in the
> timezone of the DAG)  that they can access so they don’t have to write
> their own date logic.
>
>
>
> My current implementation is to subclass all the operators and sensors I
> need and to override the render_template and execute method injecting the
> extra variables in to the context dictionary. This has 2 major drawbacks,
> it needs to be done for every Operator and Sensor we are using, and it is
> not available to logic outside Operators and Sensors such as setting email
> alert configuration:
> https://airflow.apache.org/concepts.html#email-configuration
>
>
>
> Thanks for any input,
>
> Damian
>
>
>
> ==============================================================================
> Please access the attached hyperlink for an important electronic
> communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>
> ==============================================================================
>

Reply via email to