Fokko closed pull request #4406: [AIRFLOW-3599] Removed Dagbag from delete dag URL: https://github.com/apache/incubator-airflow/pull/4406
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/airflow/api/common/experimental/delete_dag.py b/airflow/api/common/experimental/delete_dag.py index d04355f940..fc211c016a 100644 --- a/airflow/api/common/experimental/delete_dag.py +++ b/airflow/api/common/experimental/delete_dag.py @@ -17,6 +17,8 @@ # specific language governing permissions and limitations # under the License. +import os + from sqlalchemy import or_ from airflow import models, settings @@ -39,10 +41,9 @@ def delete_dag(dag_id, keep_records_in_log=True): if dag is None: raise DagNotFound("Dag id {} not found".format(dag_id)) - dagbag = models.DagBag() - if dag_id in dagbag.dags: + if dag.fileloc and not os.path.exists(dag.fileloc): raise DagFileExists("Dag id {} is still in DagBag. " - "Remove the DAG file first.".format(dag_id)) + "Remove the DAG file first: {}".format(dag_id, dag.fileloc)) count = 0 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services