mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-09-22 07:18:11 +08:00
Compare commits
18
Commits
annotations
...
v0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df812f3203 | ||
|
|
804ea29f36 | ||
|
|
da99abdd9f | ||
|
|
bf221309d8 | ||
|
|
3c53a8a4e6 | ||
|
|
3ea5c29265 | ||
|
|
64d1799133 | ||
|
|
de8dfb0a39 | ||
|
|
50d71e5bda | ||
|
|
7c7fa5f12a | ||
|
|
eb4693f1fa | ||
|
|
84db11077a | ||
|
|
f8e619c53e | ||
|
|
9a130a8eb7 | ||
|
|
11bbc1aba8 | ||
|
|
186ccde277 | ||
|
|
2b65c095a6 | ||
|
|
bae42edd3f |
@@ -136,3 +136,6 @@ dmypy.json
|
|||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
# End of https://www.gitignore.io/api/python
|
# End of https://www.gitignore.io/api/python
|
||||||
|
|
||||||
|
*.patch
|
||||||
|
.vscode
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# 0.2.0
|
||||||
|
|
||||||
|
Incrementing minor version since the changes for 0.15 are breaking, and we may want to release bugfixes from 0.1.0 branch.
|
||||||
|
|
||||||
|
# 0.1.1
|
||||||
|
|
||||||
|
Added support for cellxgene 0.15
|
||||||
@@ -67,6 +67,8 @@ Optional environment variables:
|
|||||||
* `GATEWAY_PORT` - local port that the gateway should bind to, defaults to 5005
|
* `GATEWAY_PORT` - local port that the gateway should bind to, defaults to 5005
|
||||||
* `GATEWAY_EXTRA_SCRIPTS` - JSON array of script paths, will be embedded into each page and forwarded with `--scripts` to cellxgene server
|
* `GATEWAY_EXTRA_SCRIPTS` - JSON array of script paths, will be embedded into each page and forwarded with `--scripts` to cellxgene server
|
||||||
* `GATEWAY_ENABLE_UPLOAD` - Set to `true` or `1` to enable HTTP uploads. This is not recommended for a public server.
|
* `GATEWAY_ENABLE_UPLOAD` - Set to `true` or `1` to enable HTTP uploads. This is not recommended for a public server.
|
||||||
|
* `GATEWAY_ENABLE_ANNOTATIONS` - Set to `true` or to `1` to enable cellxgene annotations.
|
||||||
|
* `GATEWAY_ENABLE_BACKED_MODE` - Set to `true` or to `1` to load AnnData in file-backed mode. This saves memory and speeds up launch time but may reduce overall performance.
|
||||||
|
|
||||||
The defaults should be fine if you set up a venv and cellxgene_data folder as above.
|
The defaults should be fine if you set up a venv and cellxgene_data folder as above.
|
||||||
|
|
||||||
@@ -6,3 +6,5 @@
|
|||||||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||||
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||||
# the specific language governing permissions and limitations under the License.
|
# the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
|
__version__ = "0.2.0"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS")
|
|||||||
ttl = os.environ.get("GATEWAY_TTL")
|
ttl = os.environ.get("GATEWAY_TTL")
|
||||||
enable_upload = os.environ.get("GATEWAY_ENABLE_UPLOAD", "").lower() in ['true', '1']
|
enable_upload = os.environ.get("GATEWAY_ENABLE_UPLOAD", "").lower() in ['true', '1']
|
||||||
enable_annotations = os.environ.get("GATEWAY_ENABLE_ANNOTATIONS", "").lower() in ['true', '1']
|
enable_annotations = os.environ.get("GATEWAY_ENABLE_ANNOTATIONS", "").lower() in ['true', '1']
|
||||||
|
enable_backed_mode = os.environ.get("GATEWAY_ENABLE_BACKED_MODE", "").lower() in ['true', '1']
|
||||||
|
|
||||||
env_vars = {
|
env_vars = {
|
||||||
"CELLXGENE_LOCATION": cellxgene_location,
|
"CELLXGENE_LOCATION": cellxgene_location,
|
||||||
@@ -36,6 +37,7 @@ optional_env_vars = {
|
|||||||
"GATEWAY_TTL": ttl,
|
"GATEWAY_TTL": ttl,
|
||||||
"GATEWAY_ENABLE_UPLOAD": enable_upload,
|
"GATEWAY_ENABLE_UPLOAD": enable_upload,
|
||||||
"GATEWAY_ENABLE_ANNOTATIONS": enable_annotations,
|
"GATEWAY_ENABLE_ANNOTATIONS": enable_annotations,
|
||||||
|
"GATEWAY_ENABLE_BACKED_MODE": enable_backed_mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
def validate():
|
def validate():
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
# Copyright 2019 Novartis Institutes for BioMedical Research Inc. Licensed
|
||||||
|
# under the Apache License, Version 2.0 (the "License"); you may not use
|
||||||
|
# this file except in compliance with the License. You may obtain a copy
|
||||||
|
# of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless
|
||||||
|
# required by applicable law or agreed to in writing, software distributed
|
||||||
|
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||||
|
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||||
|
# the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from cellxgene_gateway import env
|
from cellxgene_gateway import env
|
||||||
from cellxgene_gateway.dir_util import make_h5ad, make_annotations, annotations_suffix
|
from cellxgene_gateway.dir_util import make_h5ad, make_annotations, annotations_suffix
|
||||||
@@ -8,7 +17,7 @@ def recurse_dir(path):
|
|||||||
"The given path does not exist.", status.HTTP_400_BAD_REQUEST
|
"The given path does not exist.", status.HTTP_400_BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
all_entries = os.listdir(path)
|
all_entries = sorted(os.listdir(path))
|
||||||
def is_h5ad(el):
|
def is_h5ad(el):
|
||||||
return el.endswith('.h5ad') and os.path.isfile(os.path.join(path, el))
|
return el.endswith('.h5ad') and os.path.isfile(os.path.join(path, el))
|
||||||
h5ad_entries = [x for x in all_entries if is_h5ad(x)]
|
h5ad_entries = [x for x in all_entries if is_h5ad(x)]
|
||||||
@@ -22,7 +31,7 @@ def recurse_dir(path):
|
|||||||
"name": x[:-13] if (len(x) > 13 and x[-13] in ['-','_']) else (
|
"name": x[:-13] if (len(x) > 13 and x[-13] in ['-','_']) else (
|
||||||
x[:-4] if x.endswith('.csv') else x),
|
x[:-4] if x.endswith('.csv') else x),
|
||||||
"path": os.path.join(full_path, x).replace(env.cellxgene_data, ""),
|
"path": os.path.join(full_path, x).replace(env.cellxgene_data, ""),
|
||||||
} for x in os.listdir(full_path) if x.endswith('.csv') and os.path.isfile(os.path.join(full_path, x))]
|
} for x in sorted(os.listdir(full_path)) if x.endswith('.csv') and os.path.isfile(os.path.join(full_path, x))]
|
||||||
return [{"name":'new', "class":'new', "path":full_path.replace(env.cellxgene_data, "")}] + entries
|
return [{"name":'new', "class":'new', "path":full_path.replace(env.cellxgene_data, "")}] + entries
|
||||||
|
|
||||||
def make_entry(el):
|
def make_entry(el):
|
||||||
@@ -48,7 +57,7 @@ def recurse_dir(path):
|
|||||||
"type": "neither",
|
"type": "neither",
|
||||||
}
|
}
|
||||||
|
|
||||||
return [make_entry(x) for x in os.listdir(path)]
|
return [make_entry(x) for x in all_entries]
|
||||||
|
|
||||||
|
|
||||||
def render_entries(entries):
|
def render_entries(entries):
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
# Copyright 2019 Novartis Institutes for BioMedical Research Inc. Licensed
|
||||||
|
# under the Apache License, Version 2.0 (the "License"); you may not use
|
||||||
|
# this file except in compliance with the License. You may obtain a copy
|
||||||
|
# of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless
|
||||||
|
# required by applicable law or agreed to in writing, software distributed
|
||||||
|
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||||
|
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||||
|
# the specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
def querystring():
|
def querystring():
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from flask import (
|
|||||||
url_for,
|
url_for,
|
||||||
)
|
)
|
||||||
from flask_api import status
|
from flask_api import status
|
||||||
from werkzeug import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
from cellxgene_gateway import env
|
from cellxgene_gateway import env
|
||||||
from cellxgene_gateway.backend_cache import BackendCache
|
from cellxgene_gateway.backend_cache import BackendCache
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class ProcessException(Exception):
|
class ProcessException(Exception):
|
||||||
def __init__(self, message, stdout, stderr, http_status, dataset):
|
def __init__(self, message, stdout, stderr, http_status, key):
|
||||||
Exception.__init__(self)
|
Exception.__init__(self)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.stdout = stdout
|
self.stdout = stdout
|
||||||
|
|||||||
@@ -11,30 +11,32 @@ import logging
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from flask_api import status
|
from flask_api import status
|
||||||
from cellxgene_gateway.env import enable_annotations
|
from cellxgene_gateway.env import enable_annotations, enable_backed_mode
|
||||||
from cellxgene_gateway.process_exception import ProcessException
|
from cellxgene_gateway.process_exception import ProcessException
|
||||||
from cellxgene_gateway.dir_util import make_annotations
|
from cellxgene_gateway.dir_util import make_annotations
|
||||||
from cellxgene_gateway.path_util import get_file_path, get_annotation_file_path
|
from cellxgene_gateway.path_util import get_file_path, get_annotation_file_path
|
||||||
|
|
||||||
|
|
||||||
class SubprocessBackend:
|
class SubprocessBackend:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_cmd(self, cellxgene_loc, file_path, port, scripts, annotation_file_path):
|
def create_cmd(self, cellxgene_loc, file_path, port, scripts, annotation_file_path):
|
||||||
if enable_annotations and not annotation_file_path is None:
|
if enable_annotations and not annotation_file_path is None:
|
||||||
annotation_args_prefix = " --experimental-annotations"
|
|
||||||
if annotation_file_path == "":
|
if annotation_file_path == "":
|
||||||
annotation_args = f"{annotation_args_prefix} --experimental-annotations-output-dir {make_annotations(file_path)}"
|
extra_args = f" --annotations-dir {make_annotations(file_path)}"
|
||||||
else:
|
else:
|
||||||
annotation_args = f"{annotation_args_prefix} --experimental-annotations-file {annotation_file_path}"
|
extra_args = f" --annotations-file {annotation_file_path}"
|
||||||
else:
|
else:
|
||||||
annotation_args = ""
|
extra_args = " --disable-annotations"
|
||||||
|
if enable_backed_mode:
|
||||||
|
extra_args += " --backed"
|
||||||
cmd = (
|
cmd = (
|
||||||
f"yes | {cellxgene_loc} launch {file_path}"
|
f"yes | {cellxgene_loc} launch {file_path}"
|
||||||
+ " --port "
|
+ " --port "
|
||||||
+ str(port)
|
+ str(port)
|
||||||
+ " --host 127.0.0.1"
|
+ " --host 127.0.0.1"
|
||||||
+ annotation_args
|
+ extra_args
|
||||||
)
|
)
|
||||||
|
|
||||||
for s in scripts:
|
for s in scripts:
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ dependencies:
|
|||||||
- psutil
|
- psutil
|
||||||
- pip:
|
- pip:
|
||||||
- flask-api
|
- flask-api
|
||||||
- cellxgene
|
- cellxgene>=0.15
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
cellxgene
|
cellxgene>=0.15
|
||||||
flask
|
flask
|
||||||
flask_api
|
flask_api
|
||||||
psutil
|
psutil
|
||||||
|
|||||||
@@ -1,6 +1,23 @@
|
|||||||
import os
|
import os
|
||||||
from setuptools import setup
|
import codecs
|
||||||
|
from setuptools import find_packages, setup
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info < (3,6):
|
||||||
|
sys.exit('Sorry, Python < 3.6 is not supported')
|
||||||
|
|
||||||
|
def read(rel_path):
|
||||||
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
|
||||||
|
return fp.read()
|
||||||
|
|
||||||
|
def get_version(rel_path):
|
||||||
|
for line in read(rel_path).splitlines():
|
||||||
|
if line.startswith('__version__'):
|
||||||
|
delim = '"' if '"' in line else "'"
|
||||||
|
return line.split(delim)[1]
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
def parse_requirements():
|
def parse_requirements():
|
||||||
reqs = []
|
reqs = []
|
||||||
@@ -9,6 +26,8 @@ def parse_requirements():
|
|||||||
reqs.append(l.strip("\n"))
|
reqs.append(l.strip("\n"))
|
||||||
return reqs
|
return reqs
|
||||||
|
|
||||||
|
with open("README.md", "r") as fh:
|
||||||
|
long_description = fh.read()
|
||||||
|
|
||||||
install_reqs = parse_requirements()
|
install_reqs = parse_requirements()
|
||||||
|
|
||||||
@@ -16,11 +35,13 @@ setup(
|
|||||||
# mandatory
|
# mandatory
|
||||||
name="cellxgene-gateway",
|
name="cellxgene-gateway",
|
||||||
# mandatory
|
# mandatory
|
||||||
version="0.1",
|
version=get_version("cellxgene_gateway/__init__.py"),
|
||||||
# mandatory
|
# mandatory
|
||||||
author="Niket Patel, Yohann Potier, Alok Saldanha",
|
author="Niket Patel, Yohann Potier, Alok Saldanha",
|
||||||
author_email="alok.saldanha@novartis.com",
|
author_email="alok.saldanha@novartis.com",
|
||||||
description=("Cellxgene Gateway"),
|
description=("Cellxgene Gateway"),
|
||||||
|
long_description=long_description,
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
keywords="visualization, genomics",
|
keywords="visualization, genomics",
|
||||||
url="http://github.com/Novartis/cellxgene-gateway",
|
url="http://github.com/Novartis/cellxgene-gateway",
|
||||||
@@ -31,10 +52,11 @@ setup(
|
|||||||
"static/nibr.ico",
|
"static/nibr.ico",
|
||||||
"templates/*.html"
|
"templates/*.html"
|
||||||
]},
|
]},
|
||||||
data_files=[('', ['Readme.md', 'LICENSE.txt'])],
|
data_files=[('', ['README.md', 'LICENSE'])],
|
||||||
install_requires=install_reqs,
|
install_requires=install_reqs,
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": ["cellxgene-gateway=cellxgene_gateway.gateway:main"]
|
"console_scripts": ["cellxgene-gateway=cellxgene_gateway.gateway:main"]
|
||||||
},
|
},
|
||||||
classifiers=["Topic :: Scientific/Engineering :: Visualization"],
|
classifiers=["Topic :: Scientific/Engineering :: Visualization"],
|
||||||
|
python_requires='>=3.6',
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user