Remove flask-admin based Plugins (#11515)
This commit is contained in:
Родитель
2509d13096
Коммит
3163912293
67
UPDATING.md
67
UPDATING.md
|
@ -25,6 +25,7 @@ assists users migrating to a new version.
|
|||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
**Table of contents**
|
||||
|
||||
- [Airflow Master](#airflow-master)
|
||||
- [Airflow 2.0.0a1](#airflow-200a1)
|
||||
- [Airflow 1.10.13](#airflow-11013)
|
||||
- [Airflow 1.10.12](#airflow-11012)
|
||||
|
@ -47,6 +48,72 @@ assists users migrating to a new version.
|
|||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Airflow Master
|
||||
|
||||
If you are using Airflow Plugins and were passing `admin_views` & `menu_links` which were used in the
|
||||
non-RBAC UI (`flask-admin` based UI), upto it to use `flask_appbuilder_views` and `flask_appbuilder_menu_links`.
|
||||
|
||||
|
||||
**Old**:
|
||||
|
||||
```python
|
||||
from airflow.plugins_manager import AirflowPlugin
|
||||
|
||||
from flask_admin import BaseView, expose
|
||||
from flask_admin.base import MenuLink
|
||||
|
||||
|
||||
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")
|
||||
|
||||
ml = MenuLink(
|
||||
category='Test Plugin',
|
||||
name='Test Menu Link',
|
||||
url='https://airflow.apache.org/')
|
||||
|
||||
|
||||
class AirflowTestPlugin(AirflowPlugin):
|
||||
admin_views = [v]
|
||||
menu_links = [ml]
|
||||
```
|
||||
|
||||
**Change it to**:
|
||||
|
||||
```python
|
||||
from airflow.plugins_manager import AirflowPlugin
|
||||
from flask_appbuilder import expose, BaseView as AppBuilderBaseView
|
||||
|
||||
|
||||
class TestAppBuilderBaseView(AppBuilderBaseView):
|
||||
default_view = "test"
|
||||
|
||||
@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",
|
||||
"view": v_appbuilder_view}
|
||||
|
||||
# Creating a flask appbuilder Menu Item
|
||||
appbuilder_mitem = {"name": "Google",
|
||||
"category": "Search",
|
||||
"category_icon": "fa-th",
|
||||
"href": "https://www.google.com"}
|
||||
|
||||
|
||||
# Defining the plugin class
|
||||
class AirflowTestPlugin(AirflowPlugin):
|
||||
name = "test_plugin"
|
||||
appbuilder_views = [v_appbuilder_package]
|
||||
appbuilder_menu_items = [appbuilder_mitem]
|
||||
```
|
||||
|
||||
## Airflow 2.0.0a1
|
||||
|
||||
The 2.0 release of the Airflow is a significant upgrade, and includes substantial major changes,
|
||||
|
|
|
@ -30,9 +30,7 @@ PLUGINS_MANAGER_ATTRIBUTES_TO_DUMP = [
|
|||
"hooks_modules",
|
||||
"macros_modules",
|
||||
"executors_modules",
|
||||
"admin_views",
|
||||
"flask_blueprints",
|
||||
"menu_links",
|
||||
"flask_appbuilder_views",
|
||||
"flask_appbuilder_menu_links",
|
||||
"global_operator_extra_links",
|
||||
|
@ -46,9 +44,7 @@ PLUGINS_ATTRIBUTES_TO_DUMP = [
|
|||
"hooks",
|
||||
"executors",
|
||||
"macros",
|
||||
"admin_views",
|
||||
"flask_blueprints",
|
||||
"menu_links",
|
||||
"appbuilder_views",
|
||||
"appbuilder_menu_items",
|
||||
"global_operator_extra_links",
|
||||
|
|
|
@ -234,17 +234,12 @@ def initialize_web_ui_plugins():
|
|||
"""Collect extension points for WEB UI"""
|
||||
# pylint: disable=global-statement
|
||||
global plugins
|
||||
|
||||
global admin_views
|
||||
global flask_blueprints
|
||||
global menu_links
|
||||
global flask_appbuilder_views
|
||||
global flask_appbuilder_menu_links
|
||||
# pylint: enable=global-statement
|
||||
|
||||
if admin_views is not None and \
|
||||
flask_blueprints is not None and \
|
||||
menu_links is not None and \
|
||||
if flask_blueprints is not None and \
|
||||
flask_appbuilder_views is not None and \
|
||||
flask_appbuilder_menu_links is not None:
|
||||
return
|
||||
|
@ -256,15 +251,11 @@ def initialize_web_ui_plugins():
|
|||
|
||||
log.debug("Initialize Web UI plugin")
|
||||
|
||||
admin_views = []
|
||||
flask_blueprints = []
|
||||
menu_links = []
|
||||
flask_appbuilder_views = []
|
||||
flask_appbuilder_menu_links = []
|
||||
|
||||
for plugin in plugins:
|
||||
admin_views.extend(plugin.admin_views)
|
||||
menu_links.extend(plugin.menu_links)
|
||||
flask_appbuilder_views.extend(plugin.appbuilder_views)
|
||||
flask_appbuilder_menu_links.extend(plugin.appbuilder_menu_items)
|
||||
flask_blueprints.extend([{
|
||||
|
@ -272,7 +263,8 @@ def initialize_web_ui_plugins():
|
|||
'blueprint': bp
|
||||
} for bp in plugin.flask_blueprints])
|
||||
|
||||
if (admin_views and not flask_appbuilder_views) or (menu_links and not flask_appbuilder_menu_links):
|
||||
if (plugin.admin_views and not plugin.appbuilder_views) or (
|
||||
plugin.menu_links and not plugin.appbuilder_menu_items):
|
||||
log.warning(
|
||||
"Plugin \'%s\' may not be compatible with the current Airflow version. "
|
||||
"Please contact the author of the plugin.",
|
||||
|
|
Загрузка…
Ссылка в новой задаче