Airflow: how to delete a DAG?

前端 未结 16 1006
感动是毒
感动是毒 2020-11-28 23:45

I have started the Airflow webserver and scheduled some dags. I can see the dags on web GUI.

How can I delete a particular DAG from being run and shown in web GUI? I

16条回答
  •  伪装坚强ぢ
    2020-11-29 00:03

    I just wrote a script that deletes everything related to a particular dag, but this is only for MySQL. You can write a different connector method if you are using PostgreSQL. Originally the commands where posted by Lance on https://groups.google.com/forum/#!topic/airbnb_airflow/GVsNsUxPRC0 I just put it in script. Hope this helps. Format: python script.py dag_id

    import sys
    import MySQLdb
    
    dag_input = sys.argv[1]
    
    query = {'delete from xcom where dag_id = "' + dag_input + '"',
            'delete from task_instance where dag_id = "' + dag_input + '"',
            'delete from sla_miss where dag_id = "' + dag_input + '"',
            'delete from log where dag_id = "' + dag_input + '"',
            'delete from job where dag_id = "' + dag_input + '"',
            'delete from dag_run where dag_id = "' + dag_input + '"',
            'delete from dag where dag_id = "' + dag_input + '"' }
    
    def connect(query):
            db = MySQLdb.connect(host="hostname", user="username", passwd="password", db="database")
            cur = db.cursor()
            cur.execute(query)
            db.commit()
            db.close()
            return
    
    for value in query:
            print value
            connect(value)
    

提交回复
热议问题