Repository navigation
fix(router): accept per-call hooks in Router.predict_batch - #917
sathariels wants to merge 2 commits into
Conversation
Router.predict_batch rejected hooks= even though predict and the docs accept it. Compose per-call hooks after the installed ones, with the same None and empty-list handling, and mirror that on the TypeScript batch path. Co-authored-by: Nithilan Kumaran <sathariels@users.noreply.github.com>
The strict docs build warns when an Args entry has no type. Give hooks the HookArg annotation predict's composition already uses, on route_batch, predict_batch, and RemoteRouter.predict_batch. Co-authored-by: Nithilan Kumaran <sathariels@users.noreply.github.com>
|
Closing as a duplicate, and this was the closest call of the batch. I merged @Swatantra-66's #912 and the deciding factor was API surface, not quality. Your comment about composing before routing is the thing I checked hardest, because if it were a real behavioural difference it would have decided this the other way. I probed both heads with a malformed per-call hook on Identical, and both raise before any checkpoint loads, so the property you were protecting holds on both. What I would still like from your PR, and it is the best writing in either: the comment explaining |
What
Router.predict_batchacceptshooks=and composes them the same wayRouter.predictdoes: installed hooks first, then the per-call list.Noneand[]add nothing. The list runs once per request, includingon_route.The TypeScript
Router.predictBatch/predictManypath had the same gap and now takes the same per-call list.RemoteRouter.predict_batchtakeshooks=to keep the shared signature, and refuses a non-Nonevalue because a callable can't be sent tolaya-serve.Why
predictand the hooks docs already accept per-call hooks, butpredict_batch(..., hooks=[...])raisedTypeError: unexpected keyword argument 'hooks'and only dispatchedself.hooks. A hook could not be attached to one batch.How it was verified
tests/test_router.py: 703 passed.scripts/test_suites.py: all 79 suites passed.laya-ts: 629 tests passed,tsc --noEmitclean.Checklist
mainFixes #909