Skip to content

Commit d4cdd98

Browse files
authored
Merge branch 'main' into feature/damian/generate_until
2 parents b82b49b + 0ddeda2 commit d4cdd98

File tree

5 files changed

+16
-116
lines changed

5 files changed

+16
-116
lines changed

src/deepsparse/server/README.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ Usage: deepsparse.server [OPTIONS] COMMAND [ARGS]...
1818
1919
1. `deepsparse.server --config_file [OPTIONS] <config path>`
2020
21-
2. `deepsparse.server task [OPTIONS] <task>
21+
2. `deepsparse.server --task [OPTIONS] <task>
2222
2323
Examples for using the server:
2424
2525
`deepsparse.server --config_file server-config.yaml`
2626
27-
`deepsparse.server task question_answering --batch-size 2`
27+
`deepsparse.server --task question_answering --batch-size 2`
2828
29-
`deepsparse.server task question_answering --host "0.0.0.0"`
29+
`deepsparse.server --task question_answering --host "0.0.0.0"`
3030
3131
Example config.yaml for serving:
3232
@@ -63,10 +63,6 @@ Usage: deepsparse.server [OPTIONS] COMMAND [ARGS]...
6363
6464
Options:
6565
--help Show this message and exit.
66-
67-
Commands:
68-
config Run the server using configuration from a .yaml file.
69-
task Run the server using configuration with CLI options, which can...
7066
```
7167
---
7268
<h3>Note on the latest server release</h3>
@@ -104,7 +100,7 @@ Example CLI command for serving a single model for the **question answering** ta
104100

105101
```bash
106102
deepsparse.server \
107-
task question_answering \
103+
--task question_answering \
108104
--model_path "zoo:nlp/question_answering/bert-base/pytorch/huggingface/squad/12layer_pruned80_quant-none-vnni"
109105
```
110106

src/deepsparse/server/cli.py

+5-101
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
"""
16-
There are two sub-commands for the server:
17-
1. `deepsparse.server config [OPTIONS] <config path>`
18-
2. `deepsparse.server task [OPTIONS] <task>
19-
```
20-
"""
21-
2214
import os
23-
import warnings
2415
from tempfile import TemporaryDirectory
2516
from typing import Optional, Union
2617

@@ -223,6 +214,7 @@ def main(
223214
# if the --model_path option is provided, use that
224215
# otherwise if the argument is given and --model_path is not used, use the
225216
# argument instead
217+
226218
if model and model_path == "default":
227219
model_path = model
228220

@@ -236,6 +228,10 @@ def main(
236228
if task is None and config_file is None:
237229
raise ValueError("Must specify either --task or --config_file. Found neither")
238230

231+
if config_file is not None:
232+
server = _fetch_server(integration=integration, config=config_file)
233+
server.start_server(host, port, log_level, hot_reload_config=hot_reload_config)
234+
239235
if task is not None:
240236
cfg = ServerConfig(
241237
num_cores=num_cores,
@@ -263,98 +259,6 @@ def main(
263259
host, port, log_level, hot_reload_config=hot_reload_config
264260
)
265261

266-
if config_file is not None:
267-
server = _fetch_server(integration=integration, config=config_file)
268-
server.start_server(host, port, log_level, hot_reload_config=hot_reload_config)
269-
270-
271-
@main.command(
272-
context_settings=dict(
273-
token_normalize_func=lambda x: x.replace("-", "_"), show_default=True
274-
),
275-
)
276-
@click.argument("config-path", type=str)
277-
@HOST_OPTION
278-
@PORT_OPTION
279-
@LOG_LEVEL_OPTION
280-
@HOT_RELOAD_OPTION
281-
def config(
282-
config_path: str, host: str, port: int, log_level: str, hot_reload_config: bool
283-
):
284-
"[DEPRECATED] Run the server using configuration from a .yaml file."
285-
warnings.simplefilter("always", DeprecationWarning)
286-
warnings.warn(
287-
"Using the `config` sub command is deprecated. "
288-
"Use the `--config_file` argument instead.",
289-
category=DeprecationWarning,
290-
)
291-
292-
293-
@main.command(
294-
context_settings=dict(
295-
token_normalize_func=lambda x: x.replace("-", "_"), show_default=True
296-
),
297-
)
298-
@click.argument(
299-
"task",
300-
type=click.Choice(SupportedTasks.task_names(), case_sensitive=False),
301-
)
302-
@MODEL_OPTION
303-
@BATCH_OPTION
304-
@CORES_OPTION
305-
@WORKERS_OPTION
306-
@HOST_OPTION
307-
@PORT_OPTION
308-
@LOG_LEVEL_OPTION
309-
@HOT_RELOAD_OPTION
310-
@INTEGRATION_OPTION
311-
def task(
312-
task: str,
313-
model_path: str,
314-
batch_size: int,
315-
num_cores: int,
316-
num_workers: int,
317-
host: str,
318-
port: int,
319-
log_level: str,
320-
hot_reload_config: bool,
321-
integration: str,
322-
):
323-
"""
324-
[DEPRECATED] Run the server using configuration with CLI options,
325-
which can only serve a single model.
326-
"""
327-
328-
warnings.simplefilter("always", DeprecationWarning)
329-
warnings.warn(
330-
"Using the `task` sub command is deprecated. "
331-
"Use the `--task` argument instead.",
332-
category=DeprecationWarning,
333-
)
334-
335-
cfg = ServerConfig(
336-
num_cores=num_cores,
337-
num_workers=num_workers,
338-
integration=integration,
339-
endpoints=[
340-
EndpointConfig(
341-
task=task,
342-
name=f"{task}",
343-
model=model_path,
344-
batch_size=batch_size,
345-
)
346-
],
347-
loggers={},
348-
)
349-
350-
with TemporaryDirectory() as tmp_dir:
351-
config_path = os.path.join(tmp_dir, "server-config.yaml")
352-
with open(config_path, "w") as fp:
353-
yaml.dump(cfg.dict(), fp)
354-
355-
server = _fetch_server(integration=integration, config=config_path)
356-
server.start_server(host, port, log_level, hot_reload_config=hot_reload_config)
357-
358262

359263
def _fetch_server(integration: str, config: Union[ServerConfig, str]):
360264
if isinstance(config, str):

src/deepsparse/transformers/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ inference = qa_pipeline(question="What's my name?", context="My name is Snorlax"
118118
Spinning up:
119119
```bash
120120
deepsparse.server \
121-
task question-answering \
121+
--task question-answering \
122122
--model_path "zoo:nlp/question_answering/bert-base/pytorch/huggingface/squad/12layer_pruned80_quant-none-vnni"
123123
```
124124

@@ -162,7 +162,7 @@ inference = opt_pipeline("Who is the president of the United States?")
162162
Spinning up:
163163
```bash
164164
deepsparse.server \
165-
task text-generation \
165+
--task text-generation \
166166
--model_path zoo:opt-1.3b-opt_pretrain-pruned50_quantW8A8
167167
```
168168

@@ -210,7 +210,7 @@ inference = sa_pipeline("I hate it!")
210210
Spinning up:
211211
```bash
212212
deepsparse.server \
213-
task sentiment-analysis \
213+
--task sentiment-analysis \
214214
--model_path "zoo:nlp/sentiment_analysis/bert-base/pytorch/huggingface/sst2/pruned80_quant-none-vnni"
215215
```
216216

@@ -263,7 +263,7 @@ inference = tc_pipeline(
263263
Spinning up:
264264
```bash
265265
deepsparse.server \
266-
task text-classification \
266+
--task text-classification \
267267
--model_path "zoo:nlp/text_classification/distilbert-none/pytorch/huggingface/qqp/pruned80_quant-none-vnni"
268268
```
269269

@@ -316,7 +316,7 @@ inference = tc_pipeline("Drive from California to Texas!")
316316
Spinning up:
317317
```bash
318318
deepsparse.server \
319-
task token-classification \
319+
--task token-classification \
320320
--model_path "zoo:nlp/token_classification/bert-base/pytorch/huggingface/conll2003/pruned90-none"
321321
```
322322

src/deepsparse/yolact/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ If a `--model_filepath` arg isn't provided, then `zoo:cv/segmentation/yolact-dar
121121
Spinning up:
122122
```bash
123123
deepsparse.server \
124-
task yolact \
124+
--task yolact \
125125
--model_path "zoo:cv/segmentation/yolact-darknet53/pytorch/dbolya/coco/pruned82_quant-none"
126126
```
127127

src/deepsparse/yolo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ If a `--model_filepath` arg isn't provided, then `zoo:cv/detection/yolov5-s/pyto
120120
Spinning up:
121121
```bash
122122
deepsparse.server \
123-
task yolo \
123+
--task yolo \
124124
--model_path "zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned_quant-aggressive_94"
125125
```
126126

0 commit comments

Comments
 (0)