mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add minimal fast_app for the reports app
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user