Skip to content

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

Open
lucasjia-aws wants to merge 1 commit into
aws:master-v2from
lucasjia-aws:fix/3210-async-predictor-default-name-v2
Open

lucasjia-aws wants to merge 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

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.

1 participant