mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-08 23:18:11 +08:00
CLI improvements (#221)
* CLI improvements * Circumvent apparent bug with subparsers.required
This commit is contained in:
committed by
Charlotte Weaver
parent
187bbfdcf7
commit
8674ad1f7f
@@ -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()
|
||||||
+5
-1
@@ -73,12 +73,16 @@ def main():
|
|||||||
"--bind-all",
|
"--bind-all",
|
||||||
help="Bind to all interfaces (this makes the server accessible beyond this computer)",
|
help="Bind to all interfaces (this makes the server accessible beyond this computer)",
|
||||||
action="store_true")
|
action="store_true")
|
||||||
subparsers = parser.add_subparsers(dest="cellxgene_command")
|
subparsers = parser.add_subparsers(dest="engine")
|
||||||
|
subparsers.required = True
|
||||||
try:
|
try:
|
||||||
from .scanpy_engine.scanpy_engine import ScanpyEngine
|
from .scanpy_engine.scanpy_engine import ScanpyEngine
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
warnings.simplefilter('default', ImportWarning) # Enable ImportWarning
|
||||||
warnings.warn("Scanpy engine not available", ImportWarning)
|
warnings.warn("Scanpy engine not available", ImportWarning)
|
||||||
else:
|
else:
|
||||||
ScanpyEngine.add_to_parser(subparsers, run_scanpy)
|
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 = parser.parse_args()
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user