Is there any way to make a user-defined macro in Airflow which is itself computed from other macros?
from airflow impo
user_defined_macros
are not processed as templates by default. If you want to keep a template in a user_defined_macro
(or if you use a template in a params
variable), you can always re-run the templating function manually:
class DoubleTemplatedBashOperator(BashOperator):
def pre_execute(self, context):
context['ti'].render_templates()
And this will work for templates that don't also reference other parameters or UDMs. This way, you can have "two-deep" templates.
Or put your UDM directly in the BashOperator
's command instead (the easiest solution):
BashOperator(
task_id='bash_op',
bash_command='echo "{{ dag.following_schedule(execution_date) }}"',
dag=dag,
)