diff --git a/lib/galaxy/webapps/reports/app.py b/lib/galaxy/webapps/reports/app.py index 59c7425d1a4..71fcfcbbf88 100644 --- a/lib/galaxy/webapps/reports/app.py +++ b/lib/galaxy/webapps/reports/app.py @@ -4,17 +4,21 @@ import time import galaxy.model from galaxy.config import configure_logging +from galaxy.model.base import SharedModelMapping from galaxy.security import idencoding +from galaxy.structured_app import BasicApp from galaxy.web_stack import application_stack_instance from . import config log = logging.getLogger(__name__) -class UniverseApplication: +class UniverseApplication(BasicApp): """Encapsulates the state of a Universe application""" def __init__(self, **kwargs): + super().__init__() + self[BasicApp] = self log.debug("python path is: %s", ", ".join(sys.path)) self.name = "reports" # Read config file and check for errors @@ -38,6 +42,10 @@ class UniverseApplication: self.targets_mysql = 'mysql' in self.config.database_connection # Security helper self.security = idencoding.IdEncodingHelper(id_secret=self.config.id_secret) + + self._register_singleton(idencoding.IdEncodingHelper, self.security) + self._register_singleton(SharedModelMapping, self.model) + # used for cachebusting -- refactor this into a *SINGLE* UniverseApplication base. self.server_starttime = int(time.time()) diff --git a/lib/galaxy/webapps/reports/fast_app.py b/lib/galaxy/webapps/reports/fast_app.py new file mode 100644 index 00000000000..04137b0a326 --- /dev/null +++ b/lib/galaxy/webapps/reports/fast_app.py @@ -0,0 +1,9 @@ +from fastapi import FastAPI +from fastapi.middleware.wsgi import WSGIMiddleware + + +def initialize_fast_app(gx_webapp): + app = FastAPI() + wsgi_handler = WSGIMiddleware(gx_webapp) + app.mount('/', wsgi_handler) + return app diff --git a/lib/galaxy/webapps/reports/fast_factory.py b/lib/galaxy/webapps/reports/fast_factory.py new file mode 100644 index 00000000000..639a4140439 --- /dev/null +++ b/lib/galaxy/webapps/reports/fast_factory.py @@ -0,0 +1,27 @@ +import os + +from galaxy.util.properties import find_config_file +from galaxy.web_stack import get_app_kwds +from galaxy.webapps.reports.buildapp import app_factory +from .fast_app import initialize_fast_app + +APP_NAME = "reports" + + +def factory(): + kwds = get_app_kwds(APP_NAME, APP_NAME) + config_file = kwds.get("config_file") + if not config_file and os.environ.get('GALAXY_REPORTS_CONFIG'): + config_file = os.path.abspath(os.environ["GALAXY_REPORTS_CONFIG"]) + else: + config_file = find_config_file([APP_NAME]) + + config_section = APP_NAME + + if 'config_file' not in kwds: + kwds['config_file'] = config_file + if 'config_section' not in kwds: + kwds['config_section'] = config_section + global_conf = {} + gx_webapp = app_factory(global_conf=global_conf, load_app_kwds=kwds, wsgi_preflight=False) + return initialize_fast_app(gx_webapp)