Files
cellxgene/server/eb/app.py
bmccandless e4bf65c54a Improve hosted cellxgene (#1234)
* Improve hosted cellxgene

 - option to turn off the test index page, or supply a page for redirect.
   For EB, The default is to return 404.  For cli launch, the default is the test page.

 - option to select which matrix types are allowed for multi dataset servers.
   For EB, The default is CXG only.  For cli launch, the default is any matrix type.

 - Return early with an error response if diffexp is requested when not configured

 - Verified that reembedings and user annotations also return with an error response
   if used when not enabled.

TODO:  The new options cannot currently be set by the user.
I plan to add a configuration file where these and all other settings can be set.

 Fixes #1210 
 Fixes #1228  
 Fixes #1229
2020-03-18 16:21:03 -07:00

73 lines
2.0 KiB
Python

"""cellxgene AWS elastic beanstalk application"""
import sys
import os
import logging
if os.path.isdir("/opt/python/log"):
# This is the standard location where Amazon EC2 instances store the application logs.
logging.basicConfig(
filename="/opt/python/log/app.log",
level=logging.DEBUG,
format="%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
# echo the logs to stdout. Useful for local testing
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
SERVERDIR = os.path.dirname(os.path.realpath(__file__))
sys.path.append(SERVERDIR)
try:
from server.common.app_config import AppConfig
from server.app.app import Server
from server.data_common.matrix_loader import MatrixDataCacheManager
except Exception:
logging.exception("Exception importing server modules")
sys.exit(1)
try:
dataroot = os.getenv("CXG_DATAROOT")
if dataroot is None:
logging.error("CXG_DATAROOT environment variable must be set")
sys.exit(1)
app_config = AppConfig(
datapath=None,
dataroot=dataroot,
title="",
about=None,
scripts=[],
layout=[],
max_category_items=100,
diffexp_lfc_cutoff=0.01,
obs_names=None,
var_names=None,
anndata_backed=False,
disable_diffexp=True,
multi_dataset_index=None,
multi_dataset_allowed_matrix_type=["cxg"],
)
matrix_data_cache_manager = MatrixDataCacheManager()
annotations = None
server = Server(matrix_data_cache_manager, annotations, app_config)
debug = False
application = server.app
except Exception:
logging.exception("Caught exception during initialization")
sys.exit(1)
logging.info(f"starting server with CXG_DATAROOT={dataroot}")
if __name__ == "__main__":
try:
application.run(debug=debug, threaded=not debug, use_debugger=False)
except Exception:
logging.exception("Caught exception during server run")
sys.exit(1)