aws / aws/sagemaker-python-sdk

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

Aperta
#5,606 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
2.3k
Fork
1.3k
Merge medio
1g 22h
PR unite (30g)
35

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in sagemaker/core/resources.py da ModelPackage.refresh() e analizza il percorso di ResourceIterator in sagemaker/core/utils/utils.py. Riproduci il problema con un gruppo di pacchetti modello versionato, quindi verifica che ModelPackage.get_all() possa iterare correttamente quando viene restituito solo un ARN e che la richiesta soddisfi la convalida di DescribeModelPackage.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, python
Ambito
api, machine-learning
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.