aws / aws/sagemaker-python-sdk
ModelPackage.get_all() fails with ParamValidationError for versioned packages in a model package group
- 主要语言
- Python
- 星标
- 2.3k
- 派生
- 1.3k
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 35
描述
**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
贡献指南
调研方向
从 sagemaker/core/resources.py 中的 ModelPackage.refresh() 开始,并检查 sagemaker/core/utils/utils.py 中的 ResourceIterator 路径。使用有版本的模型包组重现该故障,然后验证仅返回 ARN 时 ModelPackage.get_all() 能够成功迭代,并且请求满足 DescribeModelPackage 验证要求。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- aws, python
- 领域
- api, machine-learning
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 55/100