airflow-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaw, Damian P. " <>
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

Thanks for any input,

Please access the attached hyperlink for an important electronic communications disclaimer: 

View raw message