You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ar...@apache.org on 2018/05/09 15:47:13 UTC

incubator-airflow git commit: [AIRFLOW-2086][AIRFLOW-2393] Customize default dagrun number in tree view

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 2728138f1 -> 2a55ffe0c


[AIRFLOW-2086][AIRFLOW-2393] Customize default dagrun number in tree view

Closes #3279 from feng-tao/reduce-tree-view

This introduces a new configuration variable to set the default
number of dag runs displayed in the tree view. For large DAGs, this
could cause timeouts in the webserver.


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

Branch: refs/heads/master
Commit: 2a55ffe0cd2c04fde2eecdbeff2fa727067069e1
Parents: 2728138
Author: Tao feng <tf...@lyft.com>
Authored: Wed May 9 08:45:06 2018 -0700
Committer: Arthur Wiedmer <ar...@apache.org>
Committed: Wed May 9 08:45:17 2018 -0700

----------------------------------------------------------------------
 UPDATING.md                                  |  3 +++
 airflow/config_templates/default_airflow.cfg |  3 +++
 airflow/www/templates/airflow/dag.html       |  2 +-
 airflow/www/templates/airflow/dags.html      |  2 +-
 airflow/www/templates/airflow/list_dags.html |  2 +-
 airflow/www/views.py                         | 19 ++++++++++++-------
 airflow/www_rbac/templates/airflow/dag.html  |  2 +-
 airflow/www_rbac/templates/airflow/dags.html |  2 +-
 airflow/www_rbac/views.py                    | 14 +++++++++-----
 9 files changed, 32 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/UPDATING.md
----------------------------------------------------------------------
diff --git a/UPDATING.md b/UPDATING.md
index defd95b..c9e1395 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -5,6 +5,9 @@ assists users migrating to a new version.
 
 ## Airflow Master
 
+### Add a configuration variable(default_dag_run_display_number) to control numbers of dag run for display
+Add a configuration variable(default_dag_run_display_number) under webserver section to control num of dag run to show in UI.
+
 ### Default executor for SubDagOperator is changed to SequentialExecutor
 
 ### New Webserver UI with Role-Based Access Control

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/config_templates/default_airflow.cfg
----------------------------------------------------------------------
diff --git a/airflow/config_templates/default_airflow.cfg b/airflow/config_templates/default_airflow.cfg
index b91961e..33b99ff 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -280,6 +280,9 @@ rbac = False
 # Define the color of navigation bar
 navbar_color = #007A87
 
+# Default dagrun to show in UI
+default_dag_run_display_number = 25
+
 
 [email]
 email_backend = airflow.utils.email.send_email_smtp

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www/templates/airflow/dag.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/airflow/dag.html b/airflow/www/templates/airflow/dag.html
index ed84f27..18242d3 100644
--- a/airflow/www/templates/airflow/dag.html
+++ b/airflow/www/templates/airflow/dag.html
@@ -57,7 +57,7 @@
       <li><a href="{{ url_for("airflow.graph", dag_id=dag.dag_id, root=root, execution_date=execution_date) }}">
           <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span>
         Graph View</a></li>
-      <li><a href="{{ url_for("airflow.tree", dag_id=dag.dag_id, num_runs=25, root=root) }}">
+      <li><a href="{{ url_for("airflow.tree", dag_id=dag.dag_id, num_runs=num_runs, root=root) }}">
           <span class="glyphicon glyphicon-tree-deciduous" aria-hidden="true"></span>
         Tree View
       </a></li>

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www/templates/airflow/dags.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/airflow/dags.html b/airflow/www/templates/airflow/dags.html
index d22bfb3..2397890 100644
--- a/airflow/www/templates/airflow/dags.html
+++ b/airflow/www/templates/airflow/dags.html
@@ -145,7 +145,7 @@
                 </a>
 
                 <!-- Tree -->
-                <a href="{{ url_for('airflow.tree', dag_id=dag.dag_id, num_runs=25) }}">
+                <a href="{{ url_for('airflow.tree', dag_id=dag.dag_id, num_runs=num_runs) }}">
                     <span class="glyphicon glyphicon-tree-deciduous" aria-hidden="true" data-original-title="Tree View"></span>
                 </a>
 

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www/templates/airflow/list_dags.html
----------------------------------------------------------------------
diff --git a/airflow/www/templates/airflow/list_dags.html b/airflow/www/templates/airflow/list_dags.html
index e8533d7..c7f2497 100644
--- a/airflow/www/templates/airflow/list_dags.html
+++ b/airflow/www/templates/airflow/list_dags.html
@@ -147,7 +147,7 @@
                 <svg height="10" width="10" id='dag-{{ row.dag_id }}' style="display: block;"></svg>
             </td>
             <td>
-              <a href="{{ url_for("airflow.tree", dag_id=row.dag_id, num_runs=25) }}" title="Tree View">
+              <a href="{{ url_for("airflow.tree", dag_id=row.dag_id, num_runs=num_runs) }}" title="Tree View">
                   <span class="glyphicon glyphicon-tree-deciduous" aria-hidden="true"></span>
               </a>
               <a href="{{ url_for("airflow.graph", dag_id=row.dag_id) }}" title="Graph View">

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 6e2f1fc..c36d55f 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -7,9 +7,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -1227,6 +1227,7 @@ class Airflow(BaseView):
     @wwwutils.action_logging
     @provide_session
     def tree(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         blur = conf.getboolean('webserver', 'demo_mode')
         dag = dagbag.get_dag(dag_id)
@@ -1239,7 +1240,7 @@ class Airflow(BaseView):
 
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = timezone.parse(base_date)
@@ -1348,7 +1349,7 @@ class Airflow(BaseView):
             ),
             root=root,
             form=form,
-            dag=dag, data=data, blur=blur)
+            dag=dag, data=data, blur=blur, num_runs=num_runs)
 
     @expose('/graph')
     @login_required
@@ -1468,11 +1469,12 @@ class Airflow(BaseView):
     @wwwutils.action_logging
     @provide_session
     def duration(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = pendulum.parse(base_date)
@@ -1575,11 +1577,12 @@ class Airflow(BaseView):
     @wwwutils.action_logging
     @provide_session
     def tries(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = pendulum.parse(base_date)
@@ -1638,11 +1641,12 @@ class Airflow(BaseView):
     @wwwutils.action_logging
     @provide_session
     def landing_times(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = pendulum.parse(base_date)
@@ -1759,6 +1763,7 @@ class Airflow(BaseView):
     @wwwutils.action_logging
     @provide_session
     def gantt(self, session=None):
+
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         demo_mode = conf.getboolean('webserver', 'demo_mode')

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www_rbac/templates/airflow/dag.html
----------------------------------------------------------------------
diff --git a/airflow/www_rbac/templates/airflow/dag.html b/airflow/www_rbac/templates/airflow/dag.html
index 02c2fdd..35308be 100644
--- a/airflow/www_rbac/templates/airflow/dag.html
+++ b/airflow/www_rbac/templates/airflow/dag.html
@@ -56,7 +56,7 @@
       <li><a href="{{ url_for("Airflow.graph", dag_id=dag.dag_id, root=root) }}">
           <span class="glyphicon glyphicon-certificate" aria-hidden="true"></span>
         Graph View</a></li>
-      <li><a href="{{ url_for("Airflow.tree", dag_id=dag.dag_id, num_runs=25, root=root) }}">
+      <li><a href="{{ url_for("Airflow.tree", dag_id=dag.dag_id, num_runs=num_runs, root=root) }}">
           <span class="glyphicon glyphicon-tree-deciduous" aria-hidden="true"></span>
         Tree View
       </a></li>

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www_rbac/templates/airflow/dags.html
----------------------------------------------------------------------
diff --git a/airflow/www_rbac/templates/airflow/dags.html b/airflow/www_rbac/templates/airflow/dags.html
index fc8418d..a712e5a 100644
--- a/airflow/www_rbac/templates/airflow/dags.html
+++ b/airflow/www_rbac/templates/airflow/dags.html
@@ -146,7 +146,7 @@
                 </a>
 
                 <!-- Tree -->
-                <a href="{{ url_for('Airflow.tree', dag_id=dag.dag_id, num_runs=25) }}">
+                <a href="{{ url_for('Airflow.tree', dag_id=dag.dag_id, num_runs=num_runs) }}">
                     <span class="glyphicon glyphicon-tree-deciduous" aria-hidden="true" data-original-title="Tree View"></span>
                 </a>
 

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/2a55ffe0/airflow/www_rbac/views.py
----------------------------------------------------------------------
diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index 7c20a65..e774462 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -860,6 +860,7 @@ class Airflow(AirflowBaseView):
     @action_logging
     @provide_session
     def tree(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         blur = conf.getboolean('webserver', 'demo_mode')
         dag = dagbag.get_dag(dag_id)
@@ -872,7 +873,7 @@ class Airflow(AirflowBaseView):
 
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = timezone.parse(base_date)
@@ -980,7 +981,7 @@ class Airflow(AirflowBaseView):
             ),
             root=root,
             form=form,
-            dag=dag, data=data, blur=blur)
+            dag=dag, data=data, blur=blur, num_runs=num_runs)
 
     @expose('/graph')
     @has_access
@@ -1101,11 +1102,12 @@ class Airflow(AirflowBaseView):
     @action_logging
     @provide_session
     def duration(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = pendulum.parse(base_date)
@@ -1204,11 +1206,12 @@ class Airflow(AirflowBaseView):
     @action_logging
     @provide_session
     def tries(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = pendulum.parse(base_date)
@@ -1267,11 +1270,12 @@ class Airflow(AirflowBaseView):
     @action_logging
     @provide_session
     def landing_times(self, session=None):
+        default_dag_run = conf.getint('webserver', 'default_dag_run_display_number')
         dag_id = request.args.get('dag_id')
         dag = dagbag.get_dag(dag_id)
         base_date = request.args.get('base_date')
         num_runs = request.args.get('num_runs')
-        num_runs = int(num_runs) if num_runs else 25
+        num_runs = int(num_runs) if num_runs else default_dag_run
 
         if base_date:
             base_date = pendulum.parse(base_date)