aws / aws/sagemaker-python-sdk
ModelPackage.get_all() fails with ParamValidationError for versioned packages in a model package group
- 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ả
**PySDK Version**
- [ ] PySDK V2 (2.x)
- [x] PySDK V3 (3.x)
**Describe the bug**
`ModelPackage.get_all()` fails with `ParamValidationError: Missing required parameter in input: "ModelPackageName"` when listing versioned model packages within a model package group. The `ResourceIterator` calls `refresh()` on each `ModelPackage` object it constructs from the list summary. The `refresh()` method uses `self.model_package_name` to call `DescribeModelPackage`, but for versioned model packages the `ListModelPackages` API does not return `ModelPackageName`; it only returns `ModelPackageArn`. Since `model_package_name` remains `Unassigned`, it gets serialized to `None` and dropped from the request, causing the missing parameter error.
**To reproduce**
Prerequisites: An existing model package group with at least one versioned model package.
```python
from sagemaker.core.resources import ModelPackage
# This will fail on the first iteration when refresh() is called
for pkg in ModelPackage.get_all(
model_package_group_name="",
sort_by="CreationTime",
sort_order="Descending",
):
print(pkg.model_package_arn)
```
**Expected behavior**
ModelPackage.get_all() should successfully iterate over all model packages in the group. The refresh() method should
fall back to using model_package_arn when model_package_name is not available, since DescribeModelPackage accepts either a name or an ARN for the ModelPackageName parameter.
**Screenshots or logs**
```
ParamValidationError: Parameter validation failed: Missing required parameter in input: "ModelPackageName"
File "sagemaker/core/utils/utils.py", line 469, in __next__
resource_object.refresh()
File "sagemaker/core/resources.py", line 25130, in refresh
response = client.describe_model_package(**operation_input_args)
```
**System information**
A description of your system. Please provide:
- **SageMaker Python SDK version**: 3.5
- **Framework name (eg. PyTorch) or algorithm (eg. KMeans)**: N/A
- **Framework version**: N/A
- **Python version**: 3.12
- **CPU or GPU**: CPU
- **Custom Docker image (Y/N)**: N
**Additional context**
N/A
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu tại sagemaker/core/resources.py ở ModelPackage.refresh() và kiểm tra đường đi của ResourceIterator trong sagemaker/core/utils/utils.py. Tái hiện lỗi với một nhóm gói mô hình có phiên bản, sau đó xác minh rằng ModelPackage.get_all() có thể lặp thành công khi chỉ một ARN được trả về và yêu cầu đáp ứng việc xác thực DescribeModelPackage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, python
- Lĩnh vực
- api, machine-learning
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 55/100