fix: Keep AsyncPredictor serializers in sync with wrapped predictor - #6335
lucasjia-aws wants to merge 1 commit into
Conversation
Port the V2 fix for aws#3100 to sagemaker-serve. AsyncPredictor copied the wrapped predictor's serializer and deserializer at construction, so overriding AsyncPredictor.deserializer did not affect the Accept header or result decoding, which read from the wrapped predictor. Make serializer and deserializer properties that delegate to the wrapped predictor. Fixes aws#3100
|
Claude finished @lucasjia-aws's task in 59s —— View job Review: Keep AsyncPredictor serializers in sync with wrapped predictor
I reviewed the diff against Correctness ✅The bug was that
So overriding Notes (non-blocking)
Tests ✅
Using a Nothing else stands out — no security, performance, or backward-incompatibility concerns beyond the intentional sync semantics above. LGTM.
|
Issue
Fixes #3100 (V3 side). V2 counterpart: #6334
Description
sagemaker.serve.predictor_async.AsyncPredictorcarries the same defect as the V2 class: the serializer and deserializer are copied from the wrapped predictor in__init__, the upload uses the outer copy, and theAcceptheader and S3 result decoding use the wrapped predictor's deserializer. OverridingAsyncPredictor.deserializertherefore has no effect on the response.Note that in V3 the recommended async path is
ModelBuilder.deploy(...), which returns asagemaker.core.resources.Endpoint, invoked viaEndpoint.invoke_async(content_type=..., accept=...). That path passes content types per call and is not affected by this issue. This change keeps the portedAsyncPredictorconsistent with the V2 fix.Changes
sagemaker-serve/src/sagemaker/serve/predictor_async.pywithserializer/deserializerproperties that read from and write to the wrapped predictor.__init__.Testing
TestAsyncPredictorSerializerOverridesinsagemaker-serve/tests/unit/test_predictor_async.pycovering the deserializer override (Accept header and result decoding), the serializer override (S3 upload body and ContentType), and values set on the wrapped predictor.sagemaker-serve/tests/unit/test_predictor_async.pyandtests/unit/async_inference/: 28 passed.