You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/06/30 13:23:27 UTC

[airflow] branch v1-10-test updated: Show "Task Reschedule" table in Airflow Webserver (#9521)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new f6f6ca5  Show "Task Reschedule" table in Airflow Webserver (#9521)
f6f6ca5 is described below

commit f6f6ca548bb14cf86376b4c76c04bb1e8ab2b8c3
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Sat Jun 27 14:08:07 2020 +0100

    Show "Task Reschedule" table in Airflow Webserver (#9521)
    
    (cherry picked from commit 53c0f2d987bf3dbfb59da283287f4aa7b72524ab)
---
 airflow/www_rbac/app.py      |  3 +++
 airflow/www_rbac/views.py    | 35 +++++++++++++++++++++++++++++++++++
 tests/www_rbac/test_views.py | 12 ++++++++++++
 3 files changed, 50 insertions(+)

diff --git a/airflow/www_rbac/app.py b/airflow/www_rbac/app.py
index 8d59c85..efcf125 100644
--- a/airflow/www_rbac/app.py
+++ b/airflow/www_rbac/app.py
@@ -131,6 +131,9 @@ def create_app(config=None, session=None, testing=False, app_name="Airflow"):
             appbuilder.add_view(views.TaskInstanceModelView,
                                 "Task Instances",
                                 category="Browse")
+            appbuilder.add_view(views.TaskRescheduleModelView,
+                                "Task Reschedules",
+                                category="Browse")
             appbuilder.add_view(views.ConfigurationView,
                                 "Configurations",
                                 category="Admin",
diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index 326b635..67a7493 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -2642,6 +2642,41 @@ class LogModelView(AirflowModelView):
     }
 
 
+class TaskRescheduleModelView(AirflowModelView):
+    """View to show records from Task Reschedule table"""
+    route_base = '/taskreschedule'
+
+    datamodel = AirflowModelView.CustomSQLAInterface(models.TaskReschedule)
+
+    base_permissions = ['can_list']
+
+    list_columns = ['id', 'dag_id', 'task_id', 'execution_date', 'try_number',
+                    'start_date', 'end_date', 'duration', 'reschedule_date']
+
+    search_columns = ['dag_id', 'task_id', 'execution_date', 'start_date', 'end_date',
+                      'reschedule_date']
+
+    base_order = ('id', 'desc')
+
+    base_filters = [['dag_id', DagFilter, lambda: []]]
+
+    def duration_f(attr):
+        end_date = attr.get('end_date')
+        duration = attr.get('duration')
+        if end_date and duration:
+            return timedelta(seconds=duration)
+
+    formatters_columns = {
+        'dag_id': wwwutils.dag_link,
+        'task_id': wwwutils.task_instance_link,
+        'start_date': wwwutils.datetime_f('start_date'),
+        'end_date': wwwutils.datetime_f('end_date'),
+        'execution_date': wwwutils.datetime_f('execution_date'),
+        'reschedule_date': wwwutils.datetime_f('reschedule_date'),
+        'duration': duration_f,
+    }
+
+
 class TaskInstanceModelView(AirflowModelView):
     route_base = '/taskinstance'
 
diff --git a/tests/www_rbac/test_views.py b/tests/www_rbac/test_views.py
index 2a18c6a..33a8338 100644
--- a/tests/www_rbac/test_views.py
+++ b/tests/www_rbac/test_views.py
@@ -2020,6 +2020,18 @@ class TestTaskInstanceView(TestBase):
         pass
 
 
+class TestTaskRescheduleView(TestBase):
+    TI_ENDPOINT = '/taskreschedule/list/?_flt_0_execution_date={}'
+
+    def test_start_date_filter(self):
+        resp = self.client.get(self.TI_ENDPOINT.format(
+            self.percent_encode('2018-10-09 22:44:31')))
+        # We aren't checking the logic of the date filter itself (that is built
+        # in to FAB) but simply that our UTC conversion was run - i.e. it
+        # doesn't blow up!
+        self.check_content_in_response('List Task Reschedule', resp)
+
+
 class TestRenderedView(TestBase):
 
     def setUp(self):