如何向 Airflow 添加新的 DAG?

新手上路,请多包涵

I have defined a DAG in a file called tutorial_2.py (actually a copy of the tutorial.py provided in the airflow tutorial, except with the dag_id 更改为 tutorial_2 )。

When I look inside my default, unmodified airflow.cfg (located in ~/airflow ), I see that dags_folder is set to /home/alex/airflow/dags .

我做 cd /home/alex/airflow; mkdir dags; cd dags; cp [...]/tutorial_2.py tutorial_2.py 。现在我有一个 dags 文件夹匹配 airflow.cfg 中设置的路径,包含我之前创建的 tutorial_2.py 文件。

但是,当我运行 airflow list_dags 时,我只获得与默认教程 DAG 对应的名称。

我想让 tutorial_2 出现在我的 DAG 列表中,以便我可以开始与之交互。 python tutorial_2.pyairflow resetdb 都没有导致它出现在列表中。

我该如何补救?

原文由 Aleksey Bilogur 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 984
2 个回答

我认为这是因为您还没有导出 AIRFLOW_HOME 。尝试做: AIRFLOW_HOME="/home/alex/airflow/dags" airflow list_dags 。如果这不起作用,则执行两个步骤 export AIRFLOW_HOME="/home/alex/airflow/dags" airflow list_dags 我相信这应该可行。搏一搏?

原文由 Ace Haidrey 发布,翻译遵循 CC BY-SA 3.0 许可协议

在我的理解中, AIRFLOW_HOME 应该链接到存储 airflow.cfg 的目录。然后, airflow.cfg 可以应用并将dag目录设置为您放入其中的值。

重要的一点是: airflow.cfg 如果你的 AIRFLOW_HOME 没有设置就没用了

原文由 Pierre CORBEL 发布,翻译遵循 CC BY-SA 4.0 许可协议

推荐问题