"vscode:/vscode.git/clone" did not exist on "a1ee97e640921c03b5c48be2b8ecb0a9bd442493"
test_srt_backend.py 1.47 KB
Newer Older
1
import json
Lianmin Zheng's avatar
Lianmin Zheng committed
2
3
import unittest

Liangsheng Yin's avatar
Liangsheng Yin committed
4
import sglang as sgl
Lianmin Zheng's avatar
Lianmin Zheng committed
5
6
from sglang.test.test_programs import (
    test_decode_int,
7
    test_decode_json_regex,
Lianmin Zheng's avatar
Lianmin Zheng committed
8
9
10
11
12
13
14
15
16
    test_expert_answer,
    test_few_shot_qa,
    test_mt_bench,
    test_parallel_decoding,
    test_regex,
    test_select,
    test_stream,
    test_tool_use,
)
17
from sglang.test.test_utils import MODEL_NAME_FOR_TEST
Lianmin Zheng's avatar
Lianmin Zheng committed
18
19
20
21
22


class TestSRTBackend(unittest.TestCase):
    backend = None

23
24
    @classmethod
    def setUpClass(cls):
25
        cls.backend = sgl.Runtime(model_path=MODEL_NAME_FOR_TEST)
26
        sgl.set_default_backend(cls.backend)
Lianmin Zheng's avatar
Lianmin Zheng committed
27

28
29
30
    @classmethod
    def tearDownClass(cls):
        cls.backend.shutdown()
Lianmin Zheng's avatar
Lianmin Zheng committed
31
32
33
34
35
36
37
38
39
40
41
42
43

    def test_few_shot_qa(self):
        test_few_shot_qa()

    def test_mt_bench(self):
        test_mt_bench()

    def test_select(self):
        test_select(check_answer=False)

    def test_decode_int(self):
        test_decode_int()

44
45
46
    def test_decode_json_regex(self):
        test_decode_json_regex()

Lianmin Zheng's avatar
Lianmin Zheng committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    def test_expert_answer(self):
        test_expert_answer()

    def test_tool_use(self):
        test_tool_use()

    def test_parallel_decoding(self):
        test_parallel_decoding()

    def test_stream(self):
        test_stream()

    def test_regex(self):
        test_regex()


if __name__ == "__main__":
    unittest.main(warnings="ignore")

    # from sglang.global_config import global_config

    # global_config.verbosity = 2
    # t = TestSRTBackend()
70
71
72
    # t.setUpClass()
    # t.test_few_shot_qa()
    # t.tearDownClass()