问题描述
我是 Airflow
的新手.我正在学习教程并编写了以下代码.
I am new to Airflow
. I am following a tutorial and written following code.
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from datetime import datetime, timedelta
from models.correctness_prediction import CorrectnessPrediction
default_args = {
'owner': 'abc',
'depends_on_past': False,
'start_date': datetime.now(),
'email': ['[email protected]'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5)
}
def correctness_prediction(arg):
CorrectnessPrediction.train()
dag = DAG('daily_processing', default_args=default_args)
task_1 = PythonOperator(
task_id='print_the_context',
provide_context=True,
python_callable=correctness_prediction,
dag=dag)
在运行脚本时,它不会显示任何错误,但是当我在 Web-UI
中检查 dags
时,它不会显示在 Menu->DAG
On running the script, it doesn't show any errors but when I check for dags
in Web-UI
it doesn't show under Menu->DAGs
但是我可以在菜单->浏览->工作
我也看不到 $AIRFLOW_HOME/dags 中的任何内容.难道只能这样吗?有人能解释一下原因吗?
I also cannot see anything in $AIRFLOW_HOME/dags. Is it supposed to be like this only? Can someone explain why?
推荐答案
您在作业页面上看到的 ScheduleJob
是 Scheduler 的一个条目.那不是正在安排的 dag.
The ScheduleJob
that you see on the jobs page is an entry for the Scheduler. Thats not the dag being scheduled.
奇怪的是你的 $AIRFLOW_HOME/dags 是空的.所有 dag 必须位于 $AIRFLOW_HOME/dags 目录中(特别是在 airflow.cfg
文件中配置的 dags 目录中).看起来您没有将实际的 dag 存储在正确的目录(dags 目录)中.
Its weird that your $AIRFLOW_HOME/dags is empty. All dags must live within the $AIRFLOW_HOME/dags directory (specifically in the dags directory configured in your airflow.cfg
file). Looks like you are not storing the actual dag in the right directory (the dags directory).
或者,有时您还需要重新启动网络服务器才能显示 dag(尽管这似乎不是这里的问题).
Alternatively, sometimes you also need to restart the webserver for the dag to show up (though that doesn't seem to be the issue here).
这篇关于DAG 在 Web-UI 中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!