diff --git a/server/__main__.py b/server/__main__.py new file mode 100644 index 00000000..f9e3c3dc --- /dev/null +++ b/server/__main__.py @@ -0,0 +1,12 @@ +# Work around bug https://github.com/pallets/werkzeug/issues/461 +if __package__ is None: + import sys + from pathlib import Path + PKG_PATH = Path(__file__).parent + sys.path.insert(0, str(PKG_PATH.parent)) + import server + __package__ = PKG_PATH.name + +# Main thing +from .app.app import main +main() diff --git a/server/app/app.py b/server/app/app.py index 720de183..e51f39d0 100644 --- a/server/app/app.py +++ b/server/app/app.py @@ -73,12 +73,16 @@ def main(): "--bind-all", help="Bind to all interfaces (this makes the server accessible beyond this computer)", action="store_true") - subparsers = parser.add_subparsers(dest="cellxgene_command") + subparsers = parser.add_subparsers(dest="engine") + subparsers.required = True try: from .scanpy_engine.scanpy_engine import ScanpyEngine except ImportError: + warnings.simplefilter('default', ImportWarning) # Enable ImportWarning warnings.warn("Scanpy engine not available", ImportWarning) else: ScanpyEngine.add_to_parser(subparsers, run_scanpy) + if len(subparsers.choices) == 0: + raise ImportError('Could not import any engines, see warnings above') args = parser.parse_args() args.func(args)