[AIRFLOW-3926] Remove references to Flask-Admin (#4759)
Remove all remaining references to Flask-Admin and remove it as a dependency. This should be the final step in the deprecation of Flask-Admin in favor of Flask-AppBuilder.
This commit is contained in:
Родитель
f3dfc9495b
Коммит
31cd02f803
|
@ -35,7 +35,6 @@ import sys
|
|||
# flake8: noqa: F401
|
||||
from airflow import settings, configuration as conf
|
||||
from airflow.models import DAG
|
||||
from flask_admin import BaseView
|
||||
from importlib import import_module
|
||||
from airflow.exceptions import AirflowException
|
||||
|
||||
|
@ -72,10 +71,6 @@ def load_login():
|
|||
raise AirflowException("Failed to import authentication backend")
|
||||
|
||||
|
||||
class AirflowViewPlugin(BaseView):
|
||||
pass
|
||||
|
||||
|
||||
class AirflowMacroPlugin(object):
|
||||
def __init__(self, namespace):
|
||||
self.namespace = namespace
|
||||
|
|
|
@ -43,7 +43,7 @@ TABLE_SELECTOR_LIMIT = 2000
|
|||
pd.set_option('display.max_colwidth', -1)
|
||||
|
||||
|
||||
# Creating a flask admin BaseView
|
||||
# Creating a Flask-AppBuilder BaseView
|
||||
class MetastoreBrowserView(BaseView):
|
||||
|
||||
default_view = 'index'
|
||||
|
|
|
@ -2411,18 +2411,6 @@ class TaskInstanceModelView(AirflowModelView):
|
|||
self.update_redirect()
|
||||
return redirect(self.get_redirect())
|
||||
|
||||
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) # noqa
|
||||
execution_date = pendulum.parse(execution_date)
|
||||
return self.session.query(self.model).get((task_id, dag_id, execution_date))
|
||||
|
||||
|
||||
class DagModelView(AirflowModelView):
|
||||
route_base = '/dagmodel'
|
||||
|
|
|
@ -86,13 +86,8 @@ looks like:
|
|||
executors = []
|
||||
# A list of references to inject into the macros namespace
|
||||
macros = []
|
||||
# A list of objects created from a class derived
|
||||
# from flask_admin.BaseView
|
||||
admin_views = []
|
||||
# A list of Blueprint object created from flask.Blueprint. For use with the flask_admin based GUI
|
||||
# A list of Blueprint object created from flask.Blueprint. For use with the flask_appbuilder based GUI
|
||||
flask_blueprints = []
|
||||
# A list of menu links (flask_admin.base.MenuLink). For use with the flask_admin based GUI
|
||||
menu_links = []
|
||||
# A list of dictionaries containing FlaskAppBuilder BaseView object and some metadata. See example below
|
||||
appbuilder_views = []
|
||||
# A list of dictionaries containing FlaskAppBuilder BaseView object and some metadata. See example below
|
||||
|
@ -142,9 +137,7 @@ definitions in Airflow.
|
|||
from airflow.plugins_manager import AirflowPlugin
|
||||
|
||||
from flask import Blueprint
|
||||
from flask_admin import BaseView, expose
|
||||
from flask_admin.base import MenuLink
|
||||
from flask_appbuilder import BaseView as AppBuilderBaseView
|
||||
from flask_appbuilder import expose, BaseView as AppBuilderBaseView
|
||||
|
||||
# Importing base classes that we need to derive
|
||||
from airflow.hooks.base_hook import BaseHook
|
||||
|
@ -172,14 +165,6 @@ definitions in Airflow.
|
|||
def plugin_macro():
|
||||
pass
|
||||
|
||||
# Creating a flask admin BaseView
|
||||
class TestView(BaseView):
|
||||
@expose('/')
|
||||
def test(self):
|
||||
# in this example, put your test_plugin/test.html template at airflow/plugins/templates/test_plugin/test.html
|
||||
return self.render("test_plugin/test.html", content="Hello galaxy!")
|
||||
v = TestView(category="Test Plugin", name="Test View")
|
||||
|
||||
# Creating a flask blueprint to integrate the templates and static folder
|
||||
bp = Blueprint(
|
||||
"test_plugin", __name__,
|
||||
|
@ -187,11 +172,6 @@ definitions in Airflow.
|
|||
static_folder='static',
|
||||
static_url_path='/static/test_plugin')
|
||||
|
||||
ml = MenuLink(
|
||||
category='Test Plugin',
|
||||
name='Test Menu Link',
|
||||
url='https://airflow.apache.org/')
|
||||
|
||||
# Creating a flask appbuilder BaseView
|
||||
class TestAppBuilderBaseView(AppBuilderBaseView):
|
||||
default_view = "test"
|
||||
|
@ -199,6 +179,7 @@ definitions in Airflow.
|
|||
@expose("/")
|
||||
def test(self):
|
||||
return self.render("test_plugin/test.html", content="Hello galaxy!")
|
||||
|
||||
v_appbuilder_view = TestAppBuilderBaseView()
|
||||
v_appbuilder_package = {"name": "Test View",
|
||||
"category": "Test Plugin",
|
||||
|
@ -218,9 +199,7 @@ definitions in Airflow.
|
|||
hooks = [PluginHook]
|
||||
executors = [PluginExecutor]
|
||||
macros = [plugin_macro]
|
||||
admin_views = [v]
|
||||
flask_blueprints = [bp]
|
||||
menu_links = [ml]
|
||||
appbuilder_views = [v_appbuilder_package]
|
||||
appbuilder_menu_items = [appbuilder_mitem]
|
||||
|
||||
|
|
1
setup.py
1
setup.py
|
@ -295,7 +295,6 @@ def do_setup():
|
|||
'enum34~=1.1.6;python_version<"3.4"',
|
||||
'flask>=1.0, <2.0',
|
||||
'flask-appbuilder==1.12.3',
|
||||
'flask-admin==1.5.3',
|
||||
'flask-caching>=1.3.3, <1.4.0',
|
||||
'flask-login>=0.3, <0.5',
|
||||
'flask-swagger==0.2.13',
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
from airflow.plugins_manager import AirflowPlugin
|
||||
|
||||
from flask import Blueprint
|
||||
from flask_admin import BaseView, expose
|
||||
from flask_admin.base import MenuLink
|
||||
from flask_appbuilder import BaseView as AppBuilderBaseView
|
||||
from flask_appbuilder import expose, BaseView as AppBuilderBaseView
|
||||
|
||||
# Importing base classes that we need to derive
|
||||
from airflow.hooks.base_hook import BaseHook
|
||||
|
@ -57,18 +55,6 @@ def plugin_macro():
|
|||
pass
|
||||
|
||||
|
||||
# Creating a flask admin BaseView
|
||||
class PluginTestView(BaseView):
|
||||
@expose('/')
|
||||
def test(self):
|
||||
# in this example, put your test_plugin/test.html
|
||||
# template at airflow/plugins/templates/test_plugin/test.html
|
||||
return self.render("test_plugin/test.html", content="Hello galaxy!")
|
||||
|
||||
|
||||
v = PluginTestView(category="Test Plugin", name="Test View")
|
||||
|
||||
|
||||
# Creating a flask appbuilder BaseView
|
||||
class PluginTestAppBuilderBaseView(AppBuilderBaseView):
|
||||
default_view = "test"
|
||||
|
@ -98,12 +84,6 @@ bp = Blueprint(
|
|||
static_url_path='/static/test_plugin')
|
||||
|
||||
|
||||
ml = MenuLink(
|
||||
category='Test Plugin',
|
||||
name="Test Menu Link",
|
||||
url="https://airflow.apache.org/")
|
||||
|
||||
|
||||
# Defining the plugin class
|
||||
class AirflowTestPlugin(AirflowPlugin):
|
||||
name = "test_plugin"
|
||||
|
@ -112,9 +92,7 @@ class AirflowTestPlugin(AirflowPlugin):
|
|||
hooks = [PluginHook]
|
||||
executors = [PluginExecutor]
|
||||
macros = [plugin_macro]
|
||||
admin_views = [v]
|
||||
flask_blueprints = [bp]
|
||||
menu_links = [ml]
|
||||
appbuilder_views = [v_appbuilder_package]
|
||||
appbuilder_menu_items = [appbuilder_mitem]
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче