关注Airflow教程here .
Problem :Web服务器返回以下错误
Broken DAG: [/usr/local/airflow/dags/test_operator.py] cannot import name
MyFirstOperator
Notes: 目录结构如下所示:
airflow_home
├── airflow.cfg
├── airflow.db
├── dags
│ └── test_operators.py
├── plugins
│ └── my_operators.py
└── unittests.cfg
我试图在'test_operators.py'中导入插件,如下所示:
from airflow.operators import MyFirstOperator
代码与教程中的代码完全相同 .
4 回答
在关注these tutorials时遇到了同样的错误 .
然而,我的错是我使用了 space character ' ' in task_id ,
Airflow
不支持 .显然,错误并未指向实际问题 . 重新启动Airflow
scheduler
和webserver
然后在WebUI上显示正确的错误消息 .我必须更新文件
airflow.cfg
中的插件路径才能解决问题 .您的Airflow插件存储位置:
我重新启动了网络服务器,现在一切正常 .
以下是我认为可能发生的事情:
在开始使用教程示例之前,我尝试运行自己的插件和dag . 我修复的第一次运行时出现了一个小的语法错误,但是在修复后我开始收到'cannot import name'错误 .
我删除了插件和dag,并尝试使用教程中的那个来查看发生了什么 .
我的猜测是步骤1中的错误以某种方式影响了第2步 .
在文章中它确实如下:
而是使用:
也不要使用:
According to the airflow article on plugins, it should be:
如果这不起作用,请尝试:
如果这不起作用,请检查启动时的Web服务器日志以获取更多信息 .