MCPcopy
hub / github.com/Lightning-AI/LitServe / test_default_batch_unbatch_stream

Function test_default_batch_unbatch_stream

tests/unit/test_litapi.py:89–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87
88
89def test_default_batch_unbatch_stream():
90 api = TestStreamAPIBatched(max_batch_size=4)
91 api.request_timeout = 30
92 api.stream = True
93 api.pre_setup(spec=None)
94 inputs = [1, 2, 3, 4]
95 expected_output = [[0, 0, 0, 0], [1, 2, 3, 4], [2, 4, 6, 8], [3, 6, 9, 12]]
96 output = api.batch(inputs)
97 output = api.predict(output)
98 for out in api.unbatch(output):
99 expected = expected_output.pop(0)
100 assert np.all(out == expected), f"Default unbatch should not change input {out} != {expected}"
101
102
103def test_custom_batch_unbatch():

Callers

nothing calls this directly

Calls 5

predictMethod · 0.95
pre_setupMethod · 0.45
batchMethod · 0.45
unbatchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…