Skip to content

Commit

Permalink
[AIRFLOW-252] Raise Sqlite exceptions when deleting tasks instance in…
Browse files Browse the repository at this point in the history
… WebUI

If users who use SQLite as backend try to delete a task via browser, it fails with an exception.
Though this is a bug on Flask-Admin's side basically, this patch provides a workaround for it.
  • Loading branch information
sekikn committed Jun 20, 2016
1 parent 45b735b commit 79d3be5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from flask_admin import BaseView, expose, AdminIndexView
from flask_admin.contrib.sqla import ModelView
from flask_admin.actions import action
from flask_admin.tools import iterdecode
from flask_login import flash
from flask._compat import PY2

Expand Down Expand Up @@ -2097,6 +2098,17 @@ def set_task_instance_state(self, ids, target_state, session=None):
raise Exception("Ooops")
flash('Failed to set state', 'error')

def get_one(self, id):
"""
As a workaround for AIRFLOW-252, this method overrides Flask-Admin's ModelView.get_one().
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
"""
task_id, dag_id, execution_date = iterdecode(id)
execution_date = dateutil.parser.parse(execution_date)
return self.session.query(self.model).get((task_id, dag_id, execution_date))


class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
create_template = 'airflow/conn_create.html'
Expand Down

0 comments on commit 79d3be5

Please sign in to comment.