aws / aws/sagemaker-python-sdk

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

Abierto
#3,210 1 comentario 4 reacciones 1 asignado Reclamado por @nargokul Ver en GitHub
component: async inference type: bug
Lenguaje dominante
Python
Estrellas
2.3k
Forks
1.3k
Merge medio
1 d 22 h
PR fusionados (30 d)
35

Descripción

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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.