aws / aws/sagemaker-python-sdk

ModelPackage.get_all() fails with ParamValidationError for versioned packages in a model package group

オープン
#5,606 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
2.3k
フォーク
1.3k
平均マージ
1日 22時間
マージ済み PR(30日)
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。