如何使用Python在Airflow DAG中导入外部脚本? [英] How to import external scripts in a Airflow DAG with Python?
本文介绍了如何使用Python在Airflow DAG中导入外部脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我具有以下结构:
然后尝试将脚本导入 inbound_layer
的某些文件中,如下所示:
And I try to import the script inside some files of the inbound_layer
like so:
import calc
但是我收到以下错误消息气流网:
However I get the following error message on Airflow web:
有什么想法吗?
推荐答案
我需要在 ren.py
的顶部插入以下脚本:
I needed insert the following script inside at the top of ren.py
:
import sys, os
from airflow.models import Variable
DAGBAGS_DIR = Variable.get('DAGBAGS_DIR')
sys.path.append(DAGBAGS_DIR + '/bi/inbound_layer/')
这样我就可以文件夹包。
This way I make available the current folder packages.
这篇关于如何使用Python在Airflow DAG中导入外部脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文