MCPcopy
hub / github.com/modelscope/ms-swift / _test_client

Function _test_client

tests/deploy/test_dataset.py:1–21  ·  view source on GitHub ↗
(port=8000)

Source from the content-addressed store, hash-verified

1def _test_client(port=8000):
2 import time
3
4 from swift.dataset import load_dataset
5 from swift.infer_engine import InferClient, InferRequest, RequestConfig
6 dataset = load_dataset(['AI-ModelScope/alpaca-gpt4-data-zh#1000'], num_proc=4)
7 infer_client = InferClient(port=port)
8 while True:
9 try:
10 infer_client.models
11 break
12 except Exception:
13 time.sleep(1)
14 pass
15 infer_requests = []
16 for data in dataset[0]:
17 infer_requests.append(InferRequest(**data))
18 request_config = RequestConfig(seed=42, max_tokens=256, temperature=0.8)
19
20 resp = infer_client.infer(infer_requests, request_config=request_config, use_tqdm=False)
21 print(len(resp))
22
23
24def _test(infer_backend):

Callers 2

_testFunction · 0.70
test_vllm_originFunction · 0.70

Calls 7

inferMethod · 0.95
load_datasetFunction · 0.90
InferClientClass · 0.90
InferRequestClass · 0.90
RequestConfigClass · 0.90
appendMethod · 0.80
sleepMethod · 0.45

Tested by

no test coverage detected