pierrejeambrun commented on code in PR #44464:
URL: https://github.com/apache/airflow/pull/44464#discussion_r1871476799


##########
airflow/api_fastapi/core_api/app.py:
##########
@@ -98,6 +100,41 @@ def init_plugins(app: FastAPI) -> None:
         app.mount(url_prefix, subapp)
 
 
+def init_flask_plugins(app: FastAPI) -> None:
+    """Integrate Flask plugins (plugins from Airflow 2)."""
+    from airflow import plugins_manager
+
+    plugins_manager.initialize_flask_plugins()
+
+    # If no Airflow 2.x plugin is in the environment, no need to go further
+    if (
+        not plugins_manager.flask_blueprints
+        and not plugins_manager.flask_appbuilder_views
+        and not plugins_manager.flask_appbuilder_menu_links
+    ):
+        return
+
+    from fastapi.middleware.wsgi import WSGIMiddleware
+
+    try:
+        from airflow.providers.fab.www.app import create_app
+    except ImportError:
+        raise AirflowException(
+            "Some Airflow 2 plugins have been detected in your environment. "
+            "To run them with Airflow 3, you must install fab provider in your 
Airflow environment."
+        )
+
+    warnings.warn(
+        "You have a plugin that is using a FAB view or Flask Blueprint, which 
was used for the Airflow 2 UI,"
+        "and is now deprecated. Please update your plugin to be compatible 
with the Airflow 3 UI.",
+        DeprecationWarning,
+        stacklevel=2,
+    )
+
+    flask_app = create_app()
+    app.mount("/pluginsv2", WSGIMiddleware(flask_app))

Review Comment:
   Nice! I didn't know that we could mount a flask app in fastapi that easily.
   
   Really takes a big pain off!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to