potiuk commented on code in PR #50960:
URL: https://github.com/apache/airflow/pull/50960#discussion_r2128350961
##########
providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/utils.py:
##########
@@ -41,26 +41,45 @@
@cache
def _return_appbuilder(app: Flask) -> AirflowAppBuilder:
"""Return an appbuilder instance for the given app."""
+ # Enable customizations in webserver_config.py to be applied via
Flask.current_app.
+ webserver_config = conf.get_mandatory_value("fab", "config_file")
+ app.config.from_pyfile(webserver_config, silent=True)
+ app.config["SQLALCHEMY_DATABASE_URI"] = conf.get("database",
"SQL_ALCHEMY_CONN")
+ url = make_url(app.config["SQLALCHEMY_DATABASE_URI"])
+ if url.drivername == "sqlite" and url.database and not isabs(url.database):
+ raise AirflowConfigException(
+ f"Cannot use relative path: `{conf.get('database',
'SQL_ALCHEMY_CONN')}` to connect to sqlite. "
+ "Please use absolute path such as `sqlite:////tmp/airflow.db`."
+ )
+ app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
init_appbuilder(app, enable_plugins=False)
init_plugins(app)
init_airflow_session_interface(app)
return app.appbuilder # type: ignore[attr-defined]
+current_appbuilder: AirflowAppBuilder | None = None
Review Comment:
This allows nesting `get_appliction_builder()` -> when it called second time
in the stack, it will return the already retrieved app builder and will not
create new app context.
--
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]