Repository: incubator-airflow
Updated Branches:
  refs/heads/master e9babff4e -> aa17b5baf


[AIRFLOW-2614] Speed up trigger_dag API call when lots of DAGs in system

Rather than loading all dags in the DagBag, find the path to the
specific DAG from the ORM and load only that one.

Closes #3590 from mishikaSingh/master


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/aa17b5ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/aa17b5ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/aa17b5ba

Branch: refs/heads/master
Commit: aa17b5baf886f7e23b3a9bcf8fef45759193f1b6
Parents: e9babff
Author: Mishika Singh <misi...@mishikas-mbp.corp.adobe.com>
Authored: Wed Jul 11 10:56:40 2018 +0100
Committer: Ash Berlin-Taylor <ash_git...@firemirror.com>
Committed: Wed Jul 11 10:56:46 2018 +0100

----------------------------------------------------------------------
 airflow/api/common/experimental/trigger_dag.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/aa17b5ba/airflow/api/common/experimental/trigger_dag.py
----------------------------------------------------------------------
diff --git a/airflow/api/common/experimental/trigger_dag.py 
b/airflow/api/common/experimental/trigger_dag.py
index 86be6aa..d7353f6 100644
--- a/airflow/api/common/experimental/trigger_dag.py
+++ b/airflow/api/common/experimental/trigger_dag.py
@@ -20,7 +20,7 @@
 import json
 
 from airflow.exceptions import DagRunAlreadyExists, DagNotFound
-from airflow.models import DagRun, DagBag
+from airflow.models import DagRun, DagBag, DagModel
 from airflow.utils import timezone
 from airflow.utils.state import State
 
@@ -86,7 +86,10 @@ def trigger_dag(
         execution_date=None,
         replace_microseconds=True,
 ):
-    dagbag = DagBag()
+    dag_model = DagModel.get_current(dag_id)
+    if dag_model is None:
+        raise DagNotFound("Dag id {} not found in DagModel".format(dag_id))
+    dagbag = DagBag(dag_folder=dag_model.fileloc)
     dag_run = DagRun()
     triggers = _trigger_dag(
         dag_id=dag_id,

Reply via email to