Skip to content

fix: Default AsyncPredictor upload prefix to endpoint name - #6337

Merged
lucasjia-aws merged 1 commit into
aws:master-v2from
lucasjia-aws:fix/3210-async-predictor-default-name-v2
Sep 29, 2026
Merged

lucasjia-aws merged 1 commit into
aws:master-v2from
lucasjia-aws:fix/3210-async-predictor-default-name-v2

Conversation

@lucasjia-aws

Copy link
Copy Markdown
Collaborator

Issue

Fixes #3210
Fixes #4774

V3 counterpart: #6336

Problem

sagemaker.predictor_async.AsyncPredictor(predictor) defaults name to None, but calling predict(data=...) or predict_async(data=...) without an input_path fails with TypeError: 'NoneType' object is not subscriptable. This was reported on 2.92.1 (#3210) and again on 2.224.2 (#4774).

Root cause

AsyncPredictor._upload_data_to_s3 builds the S3 key with name_from_base(self.name, short=True), and name_from_base slices its base argument without a None guard. The existing unit test test_async_predict_call_with_data only passed because it set predictor_async.name manually before calling predict_async.

Fix

  • In _upload_data_to_s3, use self.name or self.endpoint_name as the base for the S3 key prefix. An explicitly provided name is still used unchanged, and self.name is not modified.
  • Documented the name argument in the AsyncPredictor.__init__ docstring.

Testing

  • Added test_async_predict_call_with_data_and_no_name and test_async_predict_call_with_data_and_name_uses_name in tests/unit/test_predictor_async.py, using a real Predictor with a mocked session.
  • The no-name regression test fails on the current master-v2 and passes with this change; tests/unit/test_predictor_async.py passes 22/22.
  • flake8 passes on the changed files.

AsyncPredictor accepts name=None by default, but predict() and
predict_async() called name_from_base(self.name) when uploading input
data without an input_path, which raised
"TypeError: 'NoneType' object is not subscriptable".

Fall back to the wrapped predictor's endpoint name when no name is
given, and document the name argument. An explicitly provided name is
still used as the S3 key prefix.

Fixes aws#3210
Fixes aws#4774
@lucasjia-aws
lucasjia-aws merged commit 08b6fde into aws:master-v2 Sep 29, 2026
9 of 11 checks passed

@mohamedzeidan2021 mohamedzeidan2021 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Reviewed against the v2 tree on its own merits rather than as a parity check. Reproduced the issue's own snippet with a real Predictor: TypeError: 'NoneType' object is not subscriptable at utils.py:131 on master, correct S3 key and Accept after. 1 new test fails on reverted source; 22 passed, plus 62 across predictor/async_inference and 189 across the model tests.

Model.deploy passes a non-None name, so that path is untouched, and .name is read nowhere else in v2. The documented layout in doc/overview.rst is unchanged. The pre-existing integ test test_async_walkthrough passed against real AWS in this PR's CI, which is good no-regression evidence for the name-provided path (though nothing exercises name=None end to end).

Two non-blocking notes:

  • self.name or self.endpoint_name treats name="" as unset; if self.name is None would be exact.
  • tests/unit/test_predictor_async.py sets ENDPOINT and BUCKET_NAME both to "mxnet_endpoint", so the startswith("async-endpoint-inputs/{ENDPOINT}-") assertion can't distinguish "endpoint name was used" from "bucket name was used". It does still fail without the fix, so it earns its keep — it's just weaker than it reads. The v3 test gets this right with distinct values.

One sentence in doc/overview.rst noting the new default sub-prefix would close the loop. Note this overlaps files with #6334.

This branch was successfully deployed

1 active deployment
auto-approve — 6dba5853 Deployed Sep 25, 2026 by lucasjia-aws via wait-for-approval #236
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants