airflow-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaw, Damian P. " <damian.sha...@credit-suisse.com>
Subject Global Custom Template Variables? Or is there another best practise here?
Date Tue, 28 May 2019 16:42:16 GMT
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 
=============================================================================== 

Mime
View raw message