fix: Default AsyncPredictor upload prefix to endpoint name - #6337
Open
lucasjia-aws wants to merge 1 commit into
Open
lucasjia-aws wants to merge 1 commit into
lucasjia-aws wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #3210
Fixes #4774
V3 counterpart: #6336
Problem
sagemaker.predictor_async.AsyncPredictor(predictor)defaultsnametoNone, but callingpredict(data=...)orpredict_async(data=...)without aninput_pathfails withTypeError: '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_s3builds the S3 key withname_from_base(self.name, short=True), andname_from_baseslices itsbaseargument without a None guard. The existing unit testtest_async_predict_call_with_dataonly passed because it setpredictor_async.namemanually before callingpredict_async.Fix
_upload_data_to_s3, useself.name or self.endpoint_nameas the base for the S3 key prefix. An explicitly providednameis still used unchanged, andself.nameis not modified.nameargument in theAsyncPredictor.__init__docstring.Testing
test_async_predict_call_with_data_and_no_nameandtest_async_predict_call_with_data_and_name_uses_nameintests/unit/test_predictor_async.py, using a realPredictorwith a mocked session.master-v2and passes with this change;tests/unit/test_predictor_async.pypasses 22/22.flake8passes on the changed files.