You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/24 07:18:38 UTC

[GitHub] [airflow] marklit commented on issue #14955: Custom macros not working on Airflow 2.0.1 Python 3.9

marklit commented on issue #14955:
URL: https://github.com/apache/airflow/issues/14955#issuecomment-805565049


   I've managed to find an ugly way to import macros in Airflow 2.0.1 on Python 3.9. It's not the original `from airflow.macros import x` method from Airflow 1.x but it is working.
   
   ```
   def get_macro(name):
       from airflow import plugins_manager
       plugins_manager.integrate_macros_plugins()
   
       for x in plugins_manager.plugins:
           if x.name == name:
               return x.macros[0]
   
       raise Exception('Unable to find macro "%s"' % name)
   
   _exec = get_macro('_exec')                                                                                        
   
   _exec('pwd')  # returns: '/home/ubuntu/airflow/dags\n'
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org