From 72b0e92c57629a21201bc2680f456c7806efeaf6 Mon Sep 17 00:00:00 2001 From: Dipika Sikka Date: Tue, 6 Feb 2024 14:25:25 +0000 Subject: [PATCH 1/2] update model path to be an argument; remove unused openai command pathway --- src/deepsparse/server/cli.py | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/deepsparse/server/cli.py b/src/deepsparse/server/cli.py index 5eacc748a0..78f36ca5f6 100644 --- a/src/deepsparse/server/cli.py +++ b/src/deepsparse/server/cli.py @@ -79,16 +79,7 @@ ), ) -MODEL_OPTION = click.option( - "--model_path", - type=str, - default="default", - help=( - "The path to a model.onnx file, a model folder containing the model.onnx " - "and supporting files, or a SparseZoo model stub. " - "If not specified, the default model for the task is used." - ), -) +MODEL_OPTION = click.argument("model_path", type=str, default="default") BATCH_OPTION = click.option( "--batch_size", @@ -216,6 +207,10 @@ def main( ... ``` """ + if integration == INTEGRATION_OPENAI: + if task is None or task != "text_generation": + task = "text_generation" + if ctx.invoked_subcommand is not None: return @@ -254,24 +249,6 @@ def main( server.start_server(host, port, log_level, hot_reload_config=hot_reload_config) -@main.command( - context_settings=dict( - token_normalize_func=lambda x: x.replace("-", "_"), show_default=True - ), -) -@click.argument("config-file", type=str) -@HOST_OPTION -@PORT_OPTION -@LOG_LEVEL_OPTION -@HOT_RELOAD_OPTION -def openai( - config_file: str, host: str, port: int, log_level: str, hot_reload_config: bool -): - - server = OpenAIServer(server_config=config_file) - server.start_server(host, port, log_level, hot_reload_config=hot_reload_config) - - @main.command( context_settings=dict( token_normalize_func=lambda x: x.replace("-", "_"), show_default=True From 41bb5a3f4ede30bb582ab47e2739e6c621e565eb Mon Sep 17 00:00:00 2001 From: Dipika Sikka Date: Wed, 7 Feb 2024 18:26:36 +0000 Subject: [PATCH 2/2] add model path arg and option --- src/deepsparse/server/cli.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/deepsparse/server/cli.py b/src/deepsparse/server/cli.py index 78f36ca5f6..acd7b6897c 100644 --- a/src/deepsparse/server/cli.py +++ b/src/deepsparse/server/cli.py @@ -79,7 +79,17 @@ ), ) -MODEL_OPTION = click.argument("model_path", type=str, default="default") +MODEL_ARG = click.argument("model", type=str, default=None, required=False) +MODEL_OPTION = click.option( + "--model_path", + type=str, + default="default", + help=( + "The path to a model.onnx file, a model folder containing the model.onnx " + "and supporting files, or a SparseZoo model stub. " + "If not specified, the default model for the task is used." + ), +) BATCH_OPTION = click.option( "--batch_size", @@ -143,6 +153,7 @@ @PORT_OPTION @LOG_LEVEL_OPTION @HOT_RELOAD_OPTION +@MODEL_ARG @MODEL_OPTION @BATCH_OPTION @CORES_OPTION @@ -158,6 +169,7 @@ def main( log_level: str, hot_reload_config: bool, model_path: str, + model: str, batch_size: int, num_cores: int, num_workers: int, @@ -207,6 +219,13 @@ def main( ... ``` """ + # the server cli can take a model argument or --model_path option + # if the --model_path option is provided, use that + # otherwise if the argument is given and --model_path is not used, use the + # argument instead + if model and model_path == "default": + model_path = model + if integration == INTEGRATION_OPENAI: if task is None or task != "text_generation": task = "text_generation"