From aa29c91470a718e32ad3a632cd2730af6731d8de Mon Sep 17 00:00:00 2001 From: Charlotte Weaver Date: Fri, 9 Nov 2018 13:51:30 -0800 Subject: [PATCH] Prepare fixes (#416) * Error on overwrite=false but no output file * Add prepare requirements to requirements.txt * no saved output error -> warning * Catch clustering import error * lint fixes * Fix missing output message --- server/cli/launch.py | 2 +- server/cli/prepare.py | 11 ++++++++++- setup.py | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/server/cli/launch.py b/server/cli/launch.py index 7523e497..975f4132 100644 --- a/server/cli/launch.py +++ b/server/cli/launch.py @@ -74,7 +74,7 @@ def launch(data, layout, diffexp, title, verbose, debug, obs_names, var_names, app.config.update( DATASET_TITLE=title, CXG_API_BASE=api_base - ) + ) if not verbose: log = logging.getLogger("werkzeug") diff --git a/server/cli/prepare.py b/server/cli/prepare.py index 1b0d6063..9d21d5cb 100644 --- a/server/cli/prepare.py +++ b/server/cli/prepare.py @@ -47,6 +47,10 @@ def prepare(data, layout, recipe, output, plotting, sparse, overwrite, raise click.UsageError("Cannot use a recipe when forcing sparsity") output = expanduser(output) + + if not output: + click.echo("Warning: No file will be saved, to save the results of cellxgene prepare include " + "--output to save output to a new file") if isfile(output) and not overwrite: raise click.UsageError(f"Cannot overwrite existing file {output}, try using the flag --overwrite") @@ -112,7 +116,12 @@ def prepare(data, layout, recipe, output, plotting, sparse, overwrite, sc.pp.neighbors(adata) def run_louvain(adata): - sc.tl.louvain(adata) + try: + sc.tl.louvain(adata) + except ModuleNotFoundError: + click.echo("\nWarning: louvain module is not installed, no clusters will be calculated. " + "To fix this please install cellxgene with the optional feature louvain enabled: " + "`pip install cellxgene[louvain]`") def run_layout(adata): if len(unique(adata.obs["louvain"].values)) < 10: diff --git a/setup.py b/setup.py index 1d27ad06..ddd6b9a0 100644 --- a/setup.py +++ b/setup.py @@ -26,5 +26,8 @@ setup( entry_points={ "console_scripts": ["cellxgene = server.cli.cli:cli"] - } + }, + extras_require=dict( + louvain=['python-igraph', 'louvain>=0.6'], + ), )