Skip to content

Commit 5c7923a

Browse files
dsikkabfineran
authored andcommitted
[server] Add model argument to server cli (#1584)
* update model path to be an argument; remove unused openai command pathway * add model path arg and option
1 parent d1f08ce commit 5c7923a

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

Diff for: src/deepsparse/server/cli.py

+14-18
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
),
8080
)
8181

82+
MODEL_ARG = click.argument("model", type=str, default=None, required=False)
8283
MODEL_OPTION = click.option(
8384
"--model_path",
8485
type=str,
@@ -152,6 +153,7 @@
152153
@PORT_OPTION
153154
@LOG_LEVEL_OPTION
154155
@HOT_RELOAD_OPTION
156+
@MODEL_ARG
155157
@MODEL_OPTION
156158
@BATCH_OPTION
157159
@CORES_OPTION
@@ -167,6 +169,7 @@ def main(
167169
log_level: str,
168170
hot_reload_config: bool,
169171
model_path: str,
172+
model: str,
170173
batch_size: int,
171174
num_cores: int,
172175
num_workers: int,
@@ -216,6 +219,17 @@ def main(
216219
...
217220
```
218221
"""
222+
# the server cli can take a model argument or --model_path option
223+
# if the --model_path option is provided, use that
224+
# otherwise if the argument is given and --model_path is not used, use the
225+
# argument instead
226+
if model and model_path == "default":
227+
model_path = model
228+
229+
if integration == INTEGRATION_OPENAI:
230+
if task is None or task != "text_generation":
231+
task = "text_generation"
232+
219233
if ctx.invoked_subcommand is not None:
220234
return
221235

@@ -254,24 +268,6 @@ def main(
254268
server.start_server(host, port, log_level, hot_reload_config=hot_reload_config)
255269

256270

257-
@main.command(
258-
context_settings=dict(
259-
token_normalize_func=lambda x: x.replace("-", "_"), show_default=True
260-
),
261-
)
262-
@click.argument("config-file", type=str)
263-
@HOST_OPTION
264-
@PORT_OPTION
265-
@LOG_LEVEL_OPTION
266-
@HOT_RELOAD_OPTION
267-
def openai(
268-
config_file: str, host: str, port: int, log_level: str, hot_reload_config: bool
269-
):
270-
271-
server = OpenAIServer(server_config=config_file)
272-
server.start_server(host, port, log_level, hot_reload_config=hot_reload_config)
273-
274-
275271
@main.command(
276272
context_settings=dict(
277273
token_normalize_func=lambda x: x.replace("-", "_"), show_default=True

0 commit comments

Comments
 (0)