Can't import Airflow plugins

后端 未结 11 1315
傲寒
傲寒 2021-01-03 18:10

Following Airflow tutorial here.

Problem: The webserver returns the following error

Broken DAG: [/usr/local/airflow/dags/test_operat         


        
11条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 18:56

    In my case I managed to make a custom operator with the following steps:

    1. Airflow 10.3
    2. in DAG File from airflow.operators import MacrosPostgresOperator
    3. In ~/airflow/plugins folder I have a python file custom_operator.py and the code is pretty simple
    from airflow.plugins_manager import AirflowPlugin
    from airflow.operators.postgres_operator import PostgresOperator
    
     class MacrosPostgresOperator(PostgresOperator):
        template_fields = ('sql', 'parameters')
    
    class MacrosFirstPlugin(AirflowPlugin):
        name = "macros_first_plugin"
        operators = [MacrosPostgresOperator]
    

提交回复
热议问题