aws / aws/sagemaker-python-sdk

`ModelBuilder.build()` fails when `image_uri` is a `ParameterString` (V2 -> V3 migration blocker)

Open
#5,760 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.3k
Forks
1.3k
Avg merge
2d 2h
Merged PRs (30d)
32

Description

**PySDK Version**
- [ ] PySDK V2 (2.x)
- [ x] PySDK V3 (3.x)

**Describe the bug**
When using `ModelBuilder` with a `ParameterString` for `image_uri` in a SageMaker pipeline, `model_builder.build()` raises a `TypeError`.

**To reproduce**
```
from sagemaker.core.workflow.parameters import ParameterString
from sagemaker.core.workflow.pipeline_context import PipelineSession
from sagemaker.serve.model_builder import ModelBuilder

model_builder = ModelBuilder(
image_uri=ParameterString(name="ServingImageUri"),
sagemaker_session=PipelineSession(),
)
model_builder.build()
```
```
TypeError: 'ParameterString' object is not subscriptable
File ".../sagemaker/serve/validations/check_image_uri.py", line 301, in is_1p_image_uri
image_uri_account = image_uri[0:12]
```

The `is_1p_image_uri()` function attempts to slice `image_uri` as a string, but `ParameterString` objects cannot be subscripted.

**Expected behavior**
`ModelBuilder` should fully support `ParameterString` parameters for pipeline execution.

**Additional context**
Related to #5524.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.