我有以下结构:
我尝试在inbound_layer
的一些文件中导入脚本,如下所示:
import calc
然而,我在Airflow web上收到以下错误信息:
有什么想法吗?
发布于 2019-05-15 03:25:31
我需要在ren.py
的顶部插入以下脚本:
import sys, os
from airflow.models import Variable
DAGBAGS_DIR = Variable.get('DAGBAGS_DIR')
sys.path.append(DAGBAGS_DIR + '/bi/inbound_layer/')
这样,我就可以使用当前的文件夹包。
发布于 2021-04-01 23:27:29
Airflow默认情况下会将Airflow主目录中的dags/, plugins/, and config/
目录添加到PYTHONPATH
,因此您可以例如在dags
文件夹下创建文件夹commons
,在那里创建文件(scriptFileName
)。假设脚本中有一些您想要导入到DAG
中的类(GetJobDoneClass
),您可以这样做:
from common.scriptFileName import GetJobDoneClass
https://stackoverflow.com/questions/56134683
复制相似问题