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
For those who are still finding answers. On Airflow version 1.8, its very difficult to delete a DAG, you can refer to answers above. But since 1.9 has been released, you just have to
remove the dag on the dags folder and restart webserver
just delete it from mysql, works fine for me. delete them from below tables:
dag
dag_constructor
(might be more tables in future release) then restart webserver and worker.
Edit 8/27/18 - Airflow 1.10 is now released on PyPI!
https://pypi.org/project/apache-airflow/1.10.0/
We have this feature now in Airflow ≥ 1.10!
The PR #2199 (Jira: AIRFLOW-1002) adding DAG removal to Airflow has now been merged which allows fully deleting a DAG's entries from all of the related tables.
The core delete_dag(...) code is now part of the experimental API, and there are entrypoints available via the CLI and also via the REST API.
CLI:
airflow delete_dag my_dag_id
REST API (running webserver locally):
curl -X "DELETE" http://127.0.0.1:8080/api/experimental/dags/my_dag_id
Warning regarding the REST API: Ensure that your Airflow cluster uses authentication in production.
To upgrade, run either:
export SLUGIFY_USES_TEXT_UNIDECODE=yes
or:
export AIRFLOW_GPL_UNIDECODE=yes
Then:
pip install -U apache-airflow
Remember to check UPDATING.md first for the full details!
Airflow 1.10.1 has been released. This release adds the ability to delete a DAG from the web UI after you have deleted the corresponding DAG from the file system.
See this ticket for more details:
[AIRFLOW-2657] Add ability to delete DAG from web ui
Please note that this doesn't actually delete the DAG from the file system, you will need to do this manually first otherwise the DAG will get reloaded.
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)
First --> Delete the DAG file from $AIRFLOW_HOME/dags folder. Note: Depending on whether you have used subdirectories, you may have to dig through the subdirectories to find the DAG file and delete it.
Second --> Delete the DAG from the Webserver UI using the delete button (x in circle)