首页 文章

气流打包Dag(Zip)无法识别

提问于
浏览
1

我试图用我的Dag在一个Zip文件中打包我的存储库,就像它声明here in the documentation一样 . 所以我遵循文档中的约定,即将dag保留在zip的根目录中,子目录被气流视为包 .

我的zip文件包含以下内容:

$ unzip -l $AIRFLOW_HOME/dags/test_with_zip.zip 
Archive:  /home/arjunc/Tutorials/airflow/dags/test_with_zip.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2018-03-29 17:46   helloworld/
      189  2018-03-29 17:22   helloworld/hello.py
        0  2018-03-29 17:18   helloworld/__init__.py
      461  2018-03-29 17:24   test_with_zip_dag.py
---------                     -------
      650                     4 files

其中 test_with_zip_dag.py 是根目录中具有Dag定义的文件,如下所示:

from datetime import datetime

from airflow import DAG
from airflow.operators.python_operator import PythonOperator

from helloworld.hello import HelloWorld


def run():
    return HelloWorld().run()


dag = DAG('test_with_zip', description='Test Dependencies With Zipping',
          schedule_interval='0 12 * * *',
          start_date=datetime(2017, 3, 20), catchup=False)

hello_operator = PythonOperator(task_id='hello_task', python_callable=run, dag=dag)

我把这个zip放在默认的dags目录$ AIRFLOW_HOME / dags中,但我的dag无法识别!

我究竟做错了什么?

更新

当我重新启动Web服务器时,任务 test_with_zip 已弹出,但它不可运行,因为调度程序似乎无法识别它 . 我得到以下错误(来自Web界面):

此DAG似乎仅在本地存在 . 主调度程序似乎并不知道它的存在 .

2 回答

相关问题