首页 > 解决方案 > 气流 DAG 文件夹不可见

问题描述

我刚刚在 ubuntu 中安装了 Airflow,我正在按照教程创建 DAG。成功安装气流后,我dags在气流主页中创建了文件夹,并创建了一个示例 DAG 文件为sample.py. 但我实际上没有看到 dags 文件夹

yash@DESKTOP-TUTMG4J:~/airflow$ ls -l
total 316
-rw-rw-rw- 1 yash yash      0 Jun 12 19:26 airflow-webserver.err
-rw-rw-rw- 1 yash yash    140 Jun 12 19:29 airflow-webserver.log
-rw-rw-rw- 1 yash yash    222 Jun 12 19:29 airflow-webserver.out
-rw-r--r-- 1 yash yash      5 Jun 13 14:53 airflow-webserver.pid
-rw-rw-rw- 1 yash yash  36462 Jun 12 17:02 airflow.cfg
-rw-r--r-- 1 yash yash 270336 Jun 13 14:54 airflow.db
drwxrwxrwx 1 yash yash    512 Jun 12 21:57 logs
-rw-rw-rw- 1 yash yash   2578 Jun 12 17:02 unittests.cfg
yash@DESKTOP-TUTMG4J:~/airflow$

但是当我开始airflow webserver它说Filling up the DagBag from /home/yash/airflow/dags

yash@DESKTOP-TUTMG4J:~/airflow$ airflow initdb
DB: sqlite:////home/yash/airflow/airflow.db
[2020-06-13 14:51:35,133] {db.py:378} INFO - Creating tables
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Done.
yash@DESKTOP-TUTMG4J:~/airflow$ airflow webserver
  ____________       _____________
 ____    |__( )_________  __/__  /________      __
____  /| |_  /__  ___/_  /_ __  /_  __ \_ | /| / /
___  ___ |  / _  /   _  __/ _  / / /_/ /_ |/ |/ /
 _/_/  |_/_/  /_/    /_/    /_/  \____/____/|__/
[2020-06-13 14:53:22,260] {__init__.py:51} INFO - Using executor SequentialExecutor
[2020-06-13 14:53:22,260] {dagbag.py:396} INFO - Filling up the DagBag from /home/yash/airflow/dags
Running the Gunicorn Server with:
Workers: 4 sync
Host: 0.0.0.0:8080
Timeout: 120
Logfiles: - -
=================================================================
[2020-06-13 14:53:23 +0530] [5308] [INFO] Starting gunicorn 19.4.0
[2020-06-13 14:53:23 +0530] [5308] [INFO] Listening at: http://0.0.0.0:8080 (5308)
[2020-06-13 14:53:23 +0530] [5308] [INFO] Using worker: sync
[2020-06-13 14:53:23 +0530] [5313] [INFO] Booting worker with pid: 5313
[2020-06-13 14:53:23 +0530] [5314] [INFO] Booting worker with pid: 5314
[2020-06-13 14:53:23 +0530] [5315] [INFO] Booting worker with pid: 5315
[2020-06-13 14:53:23 +0530] [5327] [INFO] Booting worker with pid: 5327
[2020-06-13 14:53:23,678] {__init__.py:51} INFO - Using executor SequentialExecutor
[2020-06-13 14:53:23,679] {dagbag.py:396} INFO - Filling up the DagBag from /home/yash/airflow/dags
[2020-06-13 14:53:23,836] {__init__.py:51} INFO - Using executor SequentialExecutor
[2020-06-13 14:53:23,837] {dagbag.py:396} INFO - Filling up the DagBag from /home/yash/airflow/dags
[2020-06-13 14:53:23,949] {__init__.py:51} INFO - Using executor SequentialExecutor

当然,我也没有在气流 UI 中看到我的 DAG。有人可以告诉我我做错了什么以及气流如何从文件夹中挑选我的 DAGS。

标签: ubuntuairflowairflow-scheduler

解决方案


看起来您实际上并没有dags在 Airflow 的主目录中创建目录。在您的情况下,气流的家是/home/yash/airflow/,显然dags那里没有目录。

Airflow 的日志消息Filling up the DagBag from /home/yash/airflow/dags可能有些误导。这实际上意味着 Airflows 正在该路径下寻找 DAG 脚本,但这并不意味着该路径存在。

创建目录:

mkdir /home/yash/airflow/dags

并尝试再次创建 DAG 脚本。


推荐阅读