无法导入Airflow插件 [英] Can't import Airflow plugins
问题描述
后续气流教程此处。
问题:网络服务器返回以下错误
Problem: The webserver returns the following error
Broken DAG: [/usr/local/airflow/dags/test_operator.py] cannot import name
MyFirstOperator
注意:
目录结构如下:
Notes: The directory structure looks like this:
airflow_home
├── airflow.cfg
├── airflow.db
├── dags
│ └── test_operators.py
├── plugins
│ └── my_operators.py
└── unittests.cfg
我试图像这样在'test_operators.py'中导入插件:
I am attempting to import the plugin in 'test_operators.py' like this:
from airflow.operators import MyFirstOperator
代码与教程中的代码相同。
The code is all the same as what is found in the tutorial.
推荐答案
我使用气流
如果要导入的是自定义运算符,则可以将其上载到airflow plugins文件夹中,然后在DAG中将导入指定为:
I use airflow 1.10. If it's a custom operator that you want to import, you can upload it to the airflow plugins folder, and then in the DAG specify the import as :
来自 [文件名] 导入 [类名]
其中:
filename是您的插件文件的名称
classname是您的类的名称。
where : filename is the name of your plugin file classname is the name of your class.
例如:
如果文件名是 my_first_plugin ,而类名是 MyFirstOperator
,则导入将是:
For example : If the name of your file is my_first_plugin and name of the class is MyFirstOperator then, the import would be :
从 my_first_plugin 导入 MyFirstOperator
为我工作,因为我使用的是气流1.10
Worked for me as I am using airflow 1.10
谢谢!希望这对您有帮助!
Thanks ! Hope this helps !!
这篇关于无法导入Airflow插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!