mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 14:18:11 +08:00
Added cli command for run
This commit is contained in:
+16
-23
@@ -16,24 +16,12 @@ Compress(app)
|
|||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
CXG_DIR = os.environ.get("CXG_DIRECTORY", default="example-dataset/")
|
|
||||||
SECRET_KEY = os.environ.get("CXG_SECRET_KEY", default="SparkleAndShine")
|
SECRET_KEY = os.environ.get("CXG_SECRET_KEY", default="SparkleAndShine")
|
||||||
ENGINE = os.environ.get("CXG_ENGINE", default="scanpy")
|
|
||||||
TITLE = os.environ.get("DATASET_TITLE", default="PBMC 3K")
|
|
||||||
# TODO remove the 2 when this is prod
|
|
||||||
CXG_API_BASE = os.environ.get("CXG_API_BASE2", default="http://0.0.0.0:5005/api/")
|
|
||||||
|
|
||||||
app.config.update(
|
app.config.update(
|
||||||
SECRET_KEY=SECRET_KEY,
|
SECRET_KEY=SECRET_KEY,
|
||||||
CXG_API_BASE=CXG_API_BASE,
|
|
||||||
ENGINE=ENGINE,
|
|
||||||
DATA=CXG_DIR,
|
|
||||||
DATASET_TITLE=TITLE
|
|
||||||
)
|
)
|
||||||
|
|
||||||
app.config["PROFILE"] = True
|
|
||||||
# app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[15])
|
|
||||||
|
|
||||||
# Application Data
|
# Application Data
|
||||||
data = None
|
data = None
|
||||||
|
|
||||||
@@ -54,26 +42,31 @@ app.add_url_rule("/", endpoint="index")
|
|||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
global data
|
global data
|
||||||
|
title = args.title
|
||||||
|
if not title:
|
||||||
|
title = os.path.basename(os.path.normpath(args.data_directory))
|
||||||
|
api_base = f"http://0.0.0.0:{args.port}/api/"
|
||||||
app.config.update(
|
app.config.update(
|
||||||
ENGINE=args.engine,
|
DATASET_TITLE=title,
|
||||||
DATA=args.data_directory
|
CXG_API_BASE=api_base
|
||||||
)
|
)
|
||||||
if app.config["ENGINE"] == "scanpy":
|
if args.engine == "scanpy":
|
||||||
from .scanpy_engine.scanpy_engine import ScanpyEngine
|
from .scanpy_engine.scanpy_engine import ScanpyEngine
|
||||||
data = ScanpyEngine(app.config["DATA"], schema="data_schema.json")
|
data = ScanpyEngine(args.data_directory, schema="data_schema.json")
|
||||||
|
app.run(host="0.0.0.0", debug=True, port=args.port)
|
||||||
app.run(host="0.0.0.0", debug=True, port=5005)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="AAAAA")
|
parser = argparse.ArgumentParser(description="Cellxgene is a tool for exploring single cell expression.")
|
||||||
subparsers = parser.add_subparsers(dest="cellxgene_command")
|
subparsers = parser.add_subparsers(dest="cellxgene_command")
|
||||||
run_subparser = subparsers.add_parser('run', help="run cellxgene")
|
run_subparser = subparsers.add_parser("run", help="run cellxgene")
|
||||||
run_subparser.add_argument('engine', metavar='engine', help='Format that the backend uses for data')
|
run_subparser.add_argument("--title", "-t", help="Title to display (default = data directory name")
|
||||||
run_subparser.add_argument('data_directory', metavar='dir',
|
run_subparser.add_argument("--port", help="Port to run server on.", type=int, default=5005)
|
||||||
help='Directory containing data and schema')
|
run_subparser.add_argument("engine", help="The underlying structure of the data")
|
||||||
|
run_subparser.add_argument("data_directory", metavar="dir", help="Directory containing data and schema")
|
||||||
run_subparser.set_defaults(func=run)
|
run_subparser.set_defaults(func=run)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
||||||
# app.run(host="0.0.0.0", debug=True, port=5005)
|
# app.run(host="0.0.0.0", debug=True, port=5005)
|
||||||
|
|||||||
Reference in New Issue
Block a user