From 8a733270d725d3a184ebf0dfa070425ffe134df3 Mon Sep 17 00:00:00 2001 From: bmccandless Date: Mon, 16 Mar 2020 09:47:01 -0700 Subject: [PATCH] fixes for hosted cellxgene (#1227) * Fix for favicon with --dataroot * fix static assets in hosted cxg The web proxy at aws eb was not finding the static assets. The solution here is very simple: just copy the directory containing the static assets to the top level of the artifact.zip. This is not really the ideal solution. According to the AWS docs you can make a mapping to the correct location in an an ebextentions config file. I tried this and many combinations but was not able to get this to work following that pattern. Since we control the construction of the zip file, the solution here isn't bad, but it could probably be made better. --- client/index_template.html | 1 + server/app/app.py | 27 +++++++++---------- .../wsgi_app_group_global.config | 2 +- server/eb/Makefile | 4 ++- server/eb/README.md | 2 +- setup.cfg | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/client/index_template.html b/client/index_template.html index a4fe5425..075448a5 100644 --- a/client/index_template.html +++ b/client/index_template.html @@ -19,6 +19,7 @@ box-sizing: border-box; } + diff --git a/server/app/app.py b/server/app/app.py index d082fb90..09b8d9d5 100644 --- a/server/app/app.py +++ b/server/app/app.py @@ -85,17 +85,16 @@ def static_redirect(dataset, therest): return redirect(f"/static/{therest}", code=301) -def favicon_redirect(dataset): - """ redirect favicon to static dir """ - return redirect("/static/favicon.png", 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 - data = "

Welcome to cellxgene

" + # 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... + data = '' + data += 'Hosted Cellxgene' + data += '

Welcome to cellxgene

' + try: config = current_app.app_config locator = DataLocator(config.dataroot) @@ -106,15 +105,16 @@ def dataroot_index(): if matrix_data_loader.etype != MatrixDataType.UNKNOWN: datasets.append(fname) - data += "
Select one of these datasets...
" - data += "' + except Exception as e: + data += f'
Unable to locate datasets from {config.dataroot}: {str(e)}' + data += '' return make_response(data) @@ -219,7 +219,6 @@ class Server: self.app.register_blueprint(resources.blueprint) self.app.add_url_rule("//", "dataset_index", dataset_index) self.app.add_url_rule("//static/", "static_redirect", static_redirect) - self.app.add_url_rule("//favicon.png", "favicon_redirect", favicon_redirect) self.app.matrix_data_cache_manager = matrix_data_cache_manager self.app.annotations = annotations diff --git a/server/eb/.ebextensions/wsgi_app_group_global.config b/server/eb/.ebextensions/wsgi_app_group_global.config index 0befb288..cf2ecc61 100644 --- a/server/eb/.ebextensions/wsgi_app_group_global.config +++ b/server/eb/.ebextensions/wsgi_app_group_global.config @@ -1,4 +1,4 @@ -# Configue WSGI so that it will work with numpy, scanpy, etc, which all use the +# Configure WSGI so that it will work with numpy, scanpy, etc, which all use the # Python SWIG, and therefore will deadlock on start. For more information, see # https://modwsgi.readthedocs.io/en/develop/user-guides/application-issues.html#python-simplified-gil-state-api files: diff --git a/server/eb/Makefile b/server/eb/Makefile index 8cb17c0d..edef6797 100644 --- a/server/eb/Makefile +++ b/server/eb/Makefile @@ -20,7 +20,9 @@ build: clean cp app.py artifact.dir/application.py; \ cp ../requirements.txt artifact.dir; \ cp -r .ebextensions artifact.dir; \ - (cd artifact.dir; zip -r ../artifact.zip . --exclude server/test/\* server/eb/\* ); \ + (cd artifact.dir; \ + cp -r server/common/web/static static; \ + zip -r ../artifact.zip . --exclude server/test/\* server/eb/\* ; ); \ if ! grep artifact.zip .elasticbeanstalk/config.yml ; then \ mkdir -p .elasticbeanstalk ; cat config_deploy.yaml >> .elasticbeanstalk/config.yml ; fi diff --git a/server/eb/README.md b/server/eb/README.md index 5c05e6e4..bf751280 100644 --- a/server/eb/README.md +++ b/server/eb/README.md @@ -70,5 +70,5 @@ There are many more options to these commands that may be important or necessary 7. Open the application in a browser ``` - eb open + eb open $EB_ENV ``` diff --git a/setup.cfg b/setup.cfg index b6e433fb..b240487d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,4 @@ [flake8] max-line-length = 120 ignore = E203, W503 -exclude = server/data_common/fbs/NetEncoding/,.git,__pycache__,venv,server/venv,old,build,dist,server/data_common/fbs/NetEncoding +exclude = server/data_common/fbs/NetEncoding/,.git,__pycache__,venv,server/venv,old,build,dist,server/eb/artifact.dir/