Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] Add model argument to server cli #1584

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions src/deepsparse/server/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
),
)

MODEL_ARG = click.argument("model", type=str, default=None, required=False)
MODEL_OPTION = click.option(
"--model_path",
type=str,
Expand Down Expand Up @@ -152,6 +153,7 @@
@PORT_OPTION
@LOG_LEVEL_OPTION
@HOT_RELOAD_OPTION
@MODEL_ARG
@MODEL_OPTION
@BATCH_OPTION
@CORES_OPTION
Expand All @@ -167,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,
Expand Down Expand Up @@ -216,6 +219,17 @@ 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"

if ctx.invoked_subcommand is not None:
return

Expand Down Expand Up @@ -254,24 +268,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
Expand Down
Loading