How can I have a global custom macro use context implicitly?

Viewed 132

I want to add a custom global macro to Airflow, I found this answer that outlines how this can be done. But I'm wondering if I can get the context implicitly (just like the built-in macros) e.g:

def ds_ny(**context):
  """
  Custom macro that returns ds in NY timezone
  """
  return context.get("execution_date").in_timezone("America/New_York").format("%Y-%m-%d")  

Usage:

select * from table where some_date = '{{ macros.ds_ny }}'

Currently I have to pass a parameter to the macro for it to render {{ macros.ds_ny(execution_date) }}

0 Answers
Related