From e4bf65c54a278468f2460ce5064ecc42fb2f1a68 Mon Sep 17 00:00:00 2001 From: bmccandless Date: Wed, 18 Mar 2020 16:21:03 -0700 Subject: [PATCH] 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 --- server/app/app.py | 30 +++++++++++------ server/common/app_config.py | 12 ++++++- server/common/rest.py | 10 ++++-- server/data_common/matrix_loader.py | 50 +++++++++++++++++++++++------ server/eb/app.py | 4 ++- 5 files changed, 81 insertions(+), 25 deletions(-) diff --git a/server/app/app.py b/server/app/app.py index 09b8d9d5..f3eb05ea 100644 --- a/server/app/app.py +++ b/server/app/app.py @@ -1,7 +1,7 @@ import os import datetime -from flask import Flask, redirect, current_app, make_response, render_template +from flask import Flask, redirect, current_app, make_response, render_template, abort from flask import Blueprint, request, send_from_directory from flask_caching import Cache from flask_compress import Compress @@ -14,7 +14,7 @@ import server.common.rest as common_rest from server.common.errors import DatasetAccessError from server.common.utils import path_join, Float32JSONEncoder from server.common.data_locator import DataLocator -from server.data_common.matrix_loader import MatrixDataLoader, MatrixDataType +from server.data_common.matrix_loader import MatrixDataLoader from functools import wraps @@ -85,12 +85,8 @@ def static_redirect(dataset, therest): return redirect(f"/static/{therest}", code=301) -def dataroot_index(): - # FIXME with a splash screen that includes a listing of all the datasets. - # or perhaps a login screen if this is a hosted environment, - # or have a configuration option to redirect to a user specified page. - - # the following is just for demo purposes... +def dataroot_test_index(): + # the following index page is meant for testing/debugging purposes data = '' data += 'Hosted Cellxgene' data += '

Welcome to cellxgene

' @@ -101,9 +97,12 @@ def dataroot_index(): datasets = [] for fname in locator.ls(): location = path_join(config.dataroot, fname) - matrix_data_loader = MatrixDataLoader(location) - if matrix_data_loader.etype != MatrixDataType.UNKNOWN: + try: + MatrixDataLoader(location, app_config=config) datasets.append(fname) + except DatasetAccessError: + # skip over invalid datasets + pass data += '
Select one of these datasets...
' data += '