aws / aws/sagemaker-python-sdk

sagemaker.local bug when inputs are binary files

Đang mở
#4,996 1 bình luận 0 reaction 1 người được giao Được @erickb336 nhận Xem trên GitHub
component: pysdk-team contributions welcome type: bug type: question
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**
Hello, I think I encountered a bug in sagemaker.local. I'm trying to test a batch transform with images as input, but I get the following error even before I reach the input_fn of my custom inference script

```
│ 345 │ │ for element in self.splitter.split(file):
│ ❱ 346 │ │ │ if _payload_size_within_limit(buffer + element, size):
│ 347 │ │ │ │ buffer += element
│ 348 │ │ │ else:
│ 349 │ │ │ │ tmp = buffer
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: can only concatenate str (not "bytes") to str
```
I am not using a splitter (splitter type is None), as it's not necessary on images.

I believe the problem is in line 343 of MultRecordStrategy class https://github.com/aws/sagemaker-python-sdk/blob/ae3cc1c44244d79ed6187fd26889449672c55af3/src/sagemaker/local/data.py#L326-L352

We can see that the `buffer` variable is assumed to be a string, which means it's assumed that the `file` variable would not refer to a binary object, which should be possible.

**To reproduce**
Just run local batch transform with a single image as input. The model doesn't really matter I think, it will fail before any prediction or interaction between data and the model is made.

**Expected behavior**
I would expect the buffer to be sensitive to weather the file is a string like json or csv, or a binary type like png.

**Screenshots or logs**
See above.

**System information**
A description of your system. Please provide:
- **SageMaker Python SDK version**: 2.237.0
- **Framework name (eg. PyTorch) or algorithm (eg. KMeans)**: Pytorch, custom inference and model
- **Framework version**: 2.5.1
- **Python version**: 3.11
- **CPU or GPU**: Both
- **Custom Docker image (Y/N)**: Y, extending the pytorch-inference:2.5.1-gpu-py311-cu124-ubuntu22.04-sagemaker image

**Additional context**
Add any other context about the problem here.

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.