You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by sa...@apache.org on 2016/07/19 06:43:18 UTC

[1/2] incubator-airflow git commit: [AIRFLOW-277] Multiple deletions does not work in Task Instances view if using SQLite backend

Repository: incubator-airflow
Updated Branches:
  refs/heads/master ab69637be -> 5d90d132a


[AIRFLOW-277] Multiple deletions does not work in Task Instances view if using SQLite backend

AIRFLOW-252 fixed the trash button in "Task Instances" view on Web UI,
but "With selected" > "Delete" menu does still not working for the same reason.
This patch fixes this problem by overriding Flask-Admin's method if the backend is SQLite.


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

Branch: refs/heads/master
Commit: a88ee53e88f84fd64744c8e3df27caae778e0eba
Parents: 3b84bcb
Author: Kengo Seki <se...@apache.org>
Authored: Mon Jun 27 03:33:46 2016 +0000
Committer: Kengo Seki <se...@apache.org>
Committed: Tue Jun 28 01:53:31 2016 +0000

----------------------------------------------------------------------
 airflow/www/views.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/a88ee53e/airflow/www/views.py
----------------------------------------------------------------------
diff --git a/airflow/www/views.py b/airflow/www/views.py
index 1fb3f91..998926a 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -38,6 +38,7 @@ from flask import (
 from flask_admin import BaseView, expose, AdminIndexView
 from flask_admin.contrib.sqla import ModelView
 from flask_admin.actions import action
+from flask_admin.babel import lazy_gettext
 from flask_admin.tools import iterdecode
 from flask_login import flash
 from flask._compat import PY2
@@ -2078,6 +2079,21 @@ class TaskInstanceModelView(ModelViewOnly):
     def action_set_retry(self, ids):
         self.set_task_instance_state(ids, State.UP_FOR_RETRY)
 
+    @action('delete',
+            lazy_gettext('Delete'),
+            lazy_gettext('Are you sure you want to delete selected records?'))
+    def action_delete(self, ids):
+        """
+        As a workaround for AIRFLOW-277, this method overrides Flask-Admin's ModelView.action_delete().
+
+        TODO: this method should be removed once the below bug is fixed on Flask-Admin side.
+        https://github.com/flask-admin/flask-admin/issues/1226
+        """
+        if 'sqlite' in conf.get('core', 'sql_alchemy_conn'):
+            self.delete_task_instances(ids)
+        else:
+            super(TaskInstanceModelView, self).action_delete(ids)
+
     @provide_session
     def set_task_instance_state(self, ids, target_state, session=None):
         try:
@@ -2098,6 +2114,24 @@ class TaskInstanceModelView(ModelViewOnly):
                 raise Exception("Ooops")
             flash('Failed to set state', 'error')
 
+    @provide_session
+    def delete_task_instances(self, ids, session=None):
+        try:
+            TI = models.TaskInstance
+            count = 0
+            for id in ids:
+                task_id, dag_id, execution_date = id.split(',')
+                execution_date = datetime.strptime(execution_date, '%Y-%m-%d %H:%M:%S')
+                count += session.query(TI).filter(TI.task_id == task_id,
+                                                  TI.dag_id == dag_id,
+                                                  TI.execution_date == execution_date).delete()
+            session.commit()
+            flash("{count} task instances were deleted".format(**locals()))
+        except Exception as ex:
+            if not self.handle_view_exception(ex):
+                raise Exception("Ooops")
+            flash('Failed to delete', 'error')
+
     def get_one(self, id):
         """
         As a workaround for AIRFLOW-252, this method overrides Flask-Admin's ModelView.get_one().


[2/2] incubator-airflow git commit: Merge branch '1631'

Posted by sa...@apache.org.
Merge branch '1631'


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

Branch: refs/heads/master
Commit: 5d90d132af4b5a455c6f3bb43817f0e46195cf72
Parents: ab69637 a88ee53
Author: Siddharth Anand <sa...@agari.com>
Authored: Mon Jul 18 23:33:47 2016 -0700
Committer: Siddharth Anand <sa...@agari.com>
Committed: Mon Jul 18 23:33:47 2016 -0700

----------------------------------------------------------------------
 airflow/www/views.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/5d90d132/airflow/www/views.py
----------------------------------------------------------------------