Taragolis commented on code in PR #34487:
URL: https://github.com/apache/airflow/pull/34487#discussion_r1330574355


##########
airflow/models/dag.py:
##########
@@ -3381,6 +3381,24 @@ def deactivate_deleted_dags(cls, alive_dag_filelocs: 
list[str], session=NEW_SESS
             else:
                 continue
 
+    @classmethod
+    @provide_session
+    def deactivate_dags_deleted_filepath(cls, deleted_filepath: str, session: 
Session = NEW_SESSION):
+        """
+        Set ``is_active=False`` on DAGs for which the DAG file has been 
removed.
+
+        :param deleted_filepath: path of the deleted file
+        :param session: ORM Session
+        """
+        log.debug("Deactivating DAGs found in %s.", deleted_filepath)
+
+        if deleted_filepath.endswith(".zip"):
+            fileloc_filter = cls.fileloc.startswith(deleted_filepath)
+        else:
+            fileloc_filter = cls.fileloc == deleted_filepath
+
+        session.query(cls).filter(fileloc_filter).update({"is_active": False}, 
synchronize_session="fetch")

Review Comment:
   Nitpick: We should avoid to use Legacy Query API



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to