You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support context argument in batch and unbatch methods (#711)
* Support context argument in batch and unbatch methods
The batched loops called lit_api.batch and lit_api.unbatch directly, so user implementations declaring a context parameter failed with a TypeError. Route both calls through _inject_context, the same way decode_request, predict and encode_response are already handled, in both the regular and streaming batched loops. Document the optional context argument in the LitAPI.batch/unbatch docstrings and add regression tests covering both loops.
Fixes#617
* test: exercise a real batch in the batch/unbatch context test
The test set max_batch_size=2 but sent a single request, so every batch
had size 1 and the ordering between contexts and requests was never
checked. Send two concurrent requests with different inputs instead and
assert each one gets its own context value back.
Each context also records the batch size, so the test fails loudly if the
two requests ever stop sharing a batch rather than silently degrading.
* docs: show how to use context in batch/unbatch docstrings
Say which signature to write and note that the argument has to be named
context, since _inject_context matches on the parameter name and `**kwargs`
never receives it. Drops the RST markup for the plain prose and indented
examples used elsewhere in the file.
---------
Co-authored-by: Bhimraj Yadav <bhimrajyadav977@gmail.com>
0 commit comments