Python Docker上的气流-路径问题
使用气流,我尝试简单的DAG工作 我编写了自定义运算符和其他文件,希望将它们导入DAG逻辑所在的主文件中 下面是文件夹的结构:Python Docker上的气流-路径问题,python,docker,airflow,airflow-operator,Python,Docker,Airflow,Airflow Operator,使用气流,我尝试简单的DAG工作 我编写了自定义运算符和其他文件,希望将它们导入DAG逻辑所在的主文件中 下面是文件夹的结构: ├── airflow.cfg ├── dags │ ├── __init__.py │ ├── dag.py │ └── sql_statements.sql ├── docker-compose.yaml ├── environment.yml └── plugins ├── __init__.py └── operators
├── airflow.cfg
├── dags
│ ├── __init__.py
│ ├── dag.py
│ └── sql_statements.sql
├── docker-compose.yaml
├── environment.yml
└── plugins
├── __init__.py
└── operators
├── __init__.py
├── facts_calculator.py
├── has_rows.py
└── s3_to_redshift.py
我在compose文件
中正确设置了卷,因为我可以在登录到容器的终端时看到它们
我在线学习了一些教程,在那里我添加了一些\uuuu init\uuuu.py
2个非空的\uuuuu init\uuuu
进入
:/plugins/operators
:/plugins
没有名为operators的模块,或者在operator的中没有未解析的引用operators)
因为一切都无法在Web服务器上启动
你知道怎么设置吗?我哪里错了?你在用图像吗
如果是,则需要在docker compose文件(本地或芹菜)中取消注释#-./plugins:/usr/local/afflow/plugins
行(可能有多行)。其余的设置对我来说很好。尝试在operators
文件夹中只使用一个空的\uuuu init\uuuuuuuuuy.py
,然后在插件中导入。或者,不要从操作符导入。直接从文件模块导入。您所说的在插件内部导入是什么意思。您希望我如何直接从模块导入?换句话说,从操作符导入*
在插件中的\uuu init\uuuuuuuuuupy
中。并定义运算符,如operators=[.]
。Python有恼人的导入逻辑,所以这可能是问题所在。你能添加错误吗?
from operators.facts_calculator import FactsCalculatorOperator
from operators.has_rows import HasRowsOperator
from operators.s3_to_redshift import S3ToRedshiftOperator
__all__ = [
'FactsCalculatorOperator',
'HasRowsOperator',
'S3ToRedshiftOperator'
]
from airflow.plugins_manager import AirflowPlugin
import operators
# Defining the plugin class
class CustomPlugin(AirflowPlugin):
name = "custom_plugin"
# A list of class(es) derived from BaseOperator
operators = [
operators.FactsCalculatorOperator,
operators.HasRowsOperator,
operators.S3ToRedshiftOperator
]
# A list of class(es) derived from BaseHook
hooks = []
# A list of class(es) derived from BaseExecutor
executors = []
# A list of references to inject into the macros namespace
macros = []
# A list of objects created from a class derived
# from flask_admin.BaseView
admin_views = []
# A list of Blueprint object created from flask.Blueprint
flask_blueprints = []
# A list of menu links (flask_admin.base.MenuLink)
menu_links = []