DAG在Airflow UI上不可见

编程入门 行业动态 更新时间:2024-10-21 15:44:53
本文介绍了DAG在Airflow UI上不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我在dags文件夹中的dag文件.

This is my dag file in dags folder.

Code that goes along with the Airflow located at: airflow.readthedocs/en/latest/tutorial.html """ from airflow import DAG from airflow.operators.dummy_operator import DummyOperator from airflow.operators.python_operator import PythonOperator from datetime import datetime, timedelta from work_file import Test class Main(Test): def __init__(self): super(Test, self).__init__() def create_dag(self): default_args = { "owner": "airflow", "depends_on_past": False, "start_date": datetime(2015, 6, 1), "email": ["airflow@airflow"], "email_on_failure": False, "email_on_retry": False, "retries": 1, "retry_delay": timedelta(minutes=5), # 'queue': 'bash_queue', # 'pool': 'backfill', # 'priority_weight': 10, # 'end_date': datetime(2016, 1, 1), } dag = DAG("python_dag", default_args=default_args, schedule_interval='0 * * * *') dummy_task = DummyOperator(task_id='dummy_task', retries=3) python_task = PythonOperator(task_id='python_task', python_callable=self.my_func) dummy_task >> python_task if __name__ == "__main__": a = Main() a.create_dag()

这是我的另一个文件work_file.py,位于同一dags文件夹中.

This is my other file work_file.py which is in the same dags folder.

class Test: def __init__(self): pass def my_func(self): return "Hello"

目标:-目标是从我的dag文件中调用my_func.

Aim:-The Aim is to call the my_func from my dag file.

问题:-界面上似乎没有错误,但是我的dag python_dag不可见.

Problem:- There seems to be no error on the UI,but my dag python_dag is not visible.

我的服务器,调度程序也正在运行,我尝试重新启动它,但没有任何反应.

My server, scheduler is also running, I've tried restarting the same but nothing happened.

我也已导入文件(from work_file import Test)

提前谢谢!

推荐答案

DAG存在多个问题:

There are multiple problems with the DAG:

  • 未将操作员分配给任何DAG.将dag=dag添加到构造函数中.例如DummyOperator(..., dag=dag).
  • create_dag()不返回DAG.添加return dag.
  • DAG脚本未作为顶级代码执行.也就是说,模块__name__从不'__main__'.删除if __name__ == "__main__":.
  • DAG对象必须在模块的全局名称空间中.将create_dag()的返回值分配给变量:dag = a.create_dag().
  • The operators are not assigned to any DAG. Add dag=dag to the constructors. E.g., DummyOperator(..., dag=dag).
  • create_dag() does not return the DAG. Add return dag.
  • The DAG script is not executed as the top level code. That is, the modules __name__ is never '__main__'. Remove if __name__ == "__main__":.
  • The DAG objects must be in the global namespace of the module. Assign the return value of create_dag() to a variable: dag = a.create_dag().
  • 更多推荐

    DAG在Airflow UI上不可见

    本文发布于:2023-07-07 22:15:22,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1068516.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:上不   DAG   Airflow   UI

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!