aws / aws/sagemaker-python-sdk

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

未关闭
#3,210 1 条评论 4 个 reaction 已指派 1 人 已被 @nargokul 认领 在 GitHub 查看
component: async inference type: bug
主要语言
Python
星标
2.3k
派生
1.3k
平均合并
1 天 22 小时
30 天内合并 PR
35

描述

**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 ()
----> 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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。