Skip to content

.predict_async(data) called on AsyncPredictor API fails if no name was provided to predictor #3210

Description

@joaopcm1996

Describe the bug
In the SageMaker SDK, if no name is given to an AsyncPredictor, and you call .predict_async(data) with data and not an input_path, the SDK errors out.

To reproduce
Deploy an async endpoint, wrap the resulting predictor with sagemaker.predictor_async.AsyncPredictor, and do not give it a name. Then call .predict_async on that AsyncPredictor, passing it actual data instead of an S3 input_path. As the SDK tries to use the async predictor's name to create a key to upload the input data, it fails because there is no name.

Error Logs

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_6717/4064040838.py in <cell line: 1>()
----> 1 predictor_async_wrapper.predict_async(data=images.numpy())

~/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages/sagemaker/predictor_async.py in predict_async(self, data, input_path, initial_args, inference_id)
    137             )
    138         if data is not None:
--> 139             input_path = self._upload_data_to_s3(data, input_path)
    140 
    141         self._input_path = input_path

~/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages/sagemaker/predictor_async.py in _upload_data_to_s3(self, data, input_path)
    162             bucket = self.sagemaker_session.default_bucket()
    163             key = "async-endpoint-inputs/{}/{}-{}".format(
--> 164                 name_from_base(self.name, short=True),
    165                 timestamp,
    166                 my_uuid,

~/anaconda3/envs/pytorch_p38/lib/python3.8/site-packages/sagemaker/utils.py in name_from_base(base, max_length, short)
     77     """
     78     timestamp = sagemaker_short_timestamp() if short else sagemaker_timestamp()
---> 79     trimmed_base = base[: max_length - len(timestamp) - 1]
     80     return "{}-{}".format(trimmed_base, timestamp)
     81 

TypeError: 'NoneType' object is not subscriptable

System information

  • SageMaker Python SDK version: 2.92.1
  • Framework : Pytorch
  • Custom Docker image: No

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions