#81 Combined GATEWAY_ENABLE_ANNOTATIONS and GATEWAY_ENABLE_GENE_SETS flags

This commit is contained in:
Alok Saldanha
2023-07-06 08:45:05 -06:00
parent 5a650334df
commit 2754bc1ef1
7 changed files with 8 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
# 0.3.11
* #81 added support for gene sets via GATEWAY_ENABLE_GENE_SETS
* #81 added support for gene sets
# 0.3.10

View File

@@ -75,8 +75,7 @@ Optional environment variables:
* `GATEWAY_PORT` - local port that the gateway should bind to, defaults to 5005
* `GATEWAY_EXPIRE_SECONDS` - time in seconds that a cellxgene process will remain idle before being terminated. Defaults to 3600 (one hour)
* `GATEWAY_EXTRA_SCRIPTS` - JSON array of script paths, will be embedded into each page and forwarded with `--scripts` to cellxgene server
* `GATEWAY_ENABLE_ANNOTATIONS` - Set to `true` or to `1` to enable cellxgene annotations.
* `GATEWAY_ENABLE_GENE_SETS` - Set to `true` or to `1` to enable cellxgene gene sets. Also enables `GATEWAY_ENABLE_ANNOTATIONS`.
* `GATEWAY_ENABLE_ANNOTATIONS` - Set to `true` or to `1` to enable cellxgene annotations and gene sets.
* `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.
* `GATEWAY_LOG_LEVEL` - default is `INFO`. set to `DEBUG` to increase logging and to `WARNING` to decrease logging.
* `S3_ENABLE_LISTINGS_CACHE` - Set to `true` or to `1` to cache listings of S3 folders for performance. If the cache becomes stale, set `filecrawl.html?refresh=true` query parameter to refresh the cache.

View File

@@ -58,7 +58,6 @@ class CacheEntry:
@classmethod
def for_key(cls, key, port):
return cls(
None,
key,

View File

@@ -26,16 +26,10 @@ extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS")
expire_seconds = int(
os.environ.get("GATEWAY_EXPIRE_SECONDS", os.environ.get("GATEWAY_TTL", "3600"))
)
enable_gene_sets = os.environ.get("GATEWAY_ENABLE_GENE_SETS", "").lower() in [
"true",
"1",
]
enable_annotations = os.environ.get("GATEWAY_ENABLE_ANNOTATIONS", "").lower() in [
"true",
"1",
]
# Enable annotations if gene sets are enabled:
enable_annotations = enable_annotations or enable_gene_sets
enable_backed_mode = os.environ.get("GATEWAY_ENABLE_BACKED_MODE", "").lower() in [
"true",
"1",
@@ -60,7 +54,6 @@ optional_env_vars = {
"GATEWAY_EXTRA_SCRIPTS": extra_scripts,
"GATEWAY_EXPIRE_SECONDS": expire_seconds,
"GATEWAY_ENABLE_ANNOTATIONS": enable_annotations,
"GATEWAY_ENABLE_GENE_SETS": enable_gene_sets,
"GATEWAY_ENABLE_BACKED_MODE": enable_backed_mode,
"GATEWAY_LOG_LEVEL": log_level,
"CELLXGENE_ARGS": cellxgene_args,

View File

@@ -80,7 +80,6 @@ cache = BackendCache()
@app.errorhandler(CellxgeneException)
def handle_invalid_usage(error):
message = f"{error.http_status} Error : {error.message}"
return (
@@ -95,7 +94,6 @@ def handle_invalid_usage(error):
@app.errorhandler(ProcessException)
def handle_invalid_process(error):
message = []
message.append(error.message)

View File

@@ -35,8 +35,11 @@ class FileItemSource(ItemSource):
def name(self):
return self._name or f"Files:{self.base_path}"
def is_gene_set(self, path:str) -> bool:
return ('_gene_sets' in path or '-gene-sets' in path) and path.endswith(self.annotation_file_suffix)
def is_gene_set(self, path: str) -> bool:
return ("_gene_sets" in path or "-gene-sets" in path) and path.endswith(
self.annotation_file_suffix
)
def is_h5ad_file(self, path: str) -> bool:
return path.endswith(self.h5ad_suffix) and os.path.isfile(path)

View File

@@ -18,7 +18,6 @@ from cellxgene_gateway.env import (
cellxgene_args,
enable_annotations,
enable_backed_mode,
enable_gene_sets,
)
from cellxgene_gateway.process_exception import ProcessException
@@ -35,17 +34,10 @@ class SubprocessBackend:
extra_args = f" --annotations-dir {make_annotations(file_path)}"
else:
extra_args = f" --annotations-file {annotation_file_path}"
else:
extra_args = " --disable-annotations"
if enable_gene_sets and not annotation_file_path is None:
if annotation_file_path == "":
raise Exception(
"GATEWAY_ENABLE_GENE_SETS is true but --annotation_file_path not set"
)
else:
gene_sets_file_path = annotation_file_path[:-4] + "_gene_sets.csv"
extra_args += f" --gene-sets-file {gene_sets_file_path}"
else:
extra_args = " --disable-annotations"
extra_args += " --disable-gene-sets-save"
if enable_backed_mode:
extra_args += " --backed"