aws / aws/sagemaker-python-sdk

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

Đang mở
#3,210 1 bình luận 4 reaction 1 người được giao Được @nargokul nhận Xem trên GitHub
component: async inference type: bug
Ngôn ngữ chính
Python
Star
2.3k
Fork
1.3k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
35

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.