2017-04-04 67 views
1

我爲不同的python項目設置了不同的氣流檔案,即一個父級dags文件夾/vol/dags與基於不同python項目的DAG的子文件夾:/vol/dags/project1/project1.py, /vol/dags/project2/project2.py其中DAGS_FOLDER = /vol/dags如何在氣流中設置多個Dag目錄

project1.py例如從同一個目錄中的另一個python文件導入一個函數,即/vol/dags/project1/mycalculator.py。但是,當我開始氣流的Web服務器,我得到一個ImportError

/vol/dags/project1/$ airflow webserver -p 8080 

INFO - Filling up the DagBag from /vol/dags/ 
ERROR - Failed to import: /vol/dags/project1/project1.py 
Traceback (most recent call last): 
    File "/Users/xxx/anaconda/lib/python2.7/site-packages/airflow/models.py", line 247, in process_file 
    m = imp.load_source(mod_name, filepath) 
    File "/vol/dags/project1/project1.py", line 10, in <module> 
    from mycalculator import * 
ImportError: No module named mycalculator 

我試圖導入mycalculator.pyproject1.py這樣的:

from airflow import DAG 
from airflow.operators.bash_operator import BashOperator 
from airflow.operators import PythonOperator 
from datetime import datetime, timedelta 
from mycalculator import * 

dag = DAG(
    dag_id='project1', default_args=args, 
    schedule_interval="@once") 
+0

當你編譯蟒蛇你得到一個進口錯誤? – Dotan

+0

我有同樣的問題。但DAG實際上仍在運行,儘管Airflow將其標記爲「損壞」,並且在打開代碼查看器時Web服務器不會爆炸。 – jastang

回答