-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Describe the bug
Updating an endpoint using a new model with only serverless config will fail and will throw an error ValueError: Failed to parse instance type 'None': 'NoneType' object has no attribute 'startswith'
.
To reproduce
import sagemaker
from sagemaker.model import Model
from sagemaker.serverless import ServerlessInferenceConfig
session = sagemaker.Session()
role = "arn:aws:iam::.......:role/service-role/SageMaker-ExecutionRole-20250113T183044"
bucket = session.default_bucket()
container_def = {
"Image": "683313688378.dkr.ecr.us-east-1.amazonaws.com/sagemaker-xgboost:1.0-1-cpu-py3",
"ImageDigest": "sha256:000474cbf346e8d1d0e23470d4b75df44c9d59bec32d7ba976575db58a7a98b6",
"ModelDataUrl": "s3://sagemaker-project-p-0daofgwohsds/LW-MMM-p-0daofgwohsds/AbaloneTrain/pipelines-8mkady7z8jik-TrainAbaloneModel-T5io3oBe9u/output/model.tar.gz",
}
mp = Model(
image_uri=container_def["Image"],
model_data=container_def["ModelDataUrl"],
name="model-test-using-model-package-arn-new",
sagemaker_session=session,
role=role,
)
serverless_config = ServerlessInferenceConfig(provisioned_concurrency=3)
mp.create(
serverless_inference_config=serverless_config,
)
mp.deploy(
serverless_inference_config=serverless_config,
wait=False,
endpoint_name="model-test-using-model-package-arn-2025-08-29-15-44-31-579",
update_endpoint=True,
)
Expected behavior
Update endpoint with a endpoint config using only serverless_inference_config argument
Screenshots or logs
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/igalang/dev/lw_sagemaker/.venv/lib/python3.11/site-packages/sagemaker/utils.py:1496 in │
│ volume_size_supported │
│ │
│ 1493 │ │ # local mode does not support volume size │
│ 1494 │ │ # instance type given as pipeline parameter does not support volume size │
│ 1495 │ │ # do not change the if statement order below. │
│ ❱ 1496 │ │ if is_pipeline_variable(instance_type) or instance_type.startswith("local"): │
│ 1497 │ │ │ return False │
│ 1498 │ │ │
│ 1499 │ │ parts: list[str] = instance_type.split(".") │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'startswith'
During handling of the above exception, another exception occurred:
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:5 │
│ │
│ 2 mp.create( │
│ 3 │ serverless_inference_config=serverless_config, │
│ 4 ) │
│ ❱ 5 mp.deploy( │
│ 6 │ serverless_inference_config=serverless_config, │
│ 7 │ wait=False, │
│ 8 │ endpoint_name="model-test-using-model-package-arn-2025-08-29-15-44-31-579", │
│ │
│ /home/igalang/dev/lw_sagemaker/.venv/lib/python3.11/site-packages/sagemaker/model.py:1794 in │
│ deploy │
│ │
│ 1791 │ │ │ │ explainer_config_dict = explainer_config._to_request_dict() │
│ 1792 │ │ │ │
│ 1793 │ │ │ if update_endpoint: │
│ ❱ 1794 │ │ │ │ endpoint_config_name = self.sagemaker_session.create_endpoint_config( │
│ 1795 │ │ │ │ │ name=self.name, │
│ 1796 │ │ │ │ │ model_name=self.name, │
│ 1797 │ │ │ │ │ initial_instance_count=initial_instance_count, │
│ │
│ /home/igalang/dev/lw_sagemaker/.venv/lib/python3.11/site-packages/sagemaker/session.py:4662 in │
│ create_endpoint_config │
│ │
│ 4659 │ │ │ resolve_value_from_config( │
│ 4660 │ │ │ │ kms_key, ENDPOINT_CONFIG_KMS_KEY_ID_PATH, sagemaker_session=self │
│ 4661 │ │ │ ) │
│ ❱ 4662 │ │ │ if instance_supports_kms(instance_type) │
│ 4663 │ │ │ else kms_key │
│ 4664 │ │ ) │
│ 4665 │ │ if kms_key is not None: │
│ │
│ /home/igalang/dev/lw_sagemaker/.venv/lib/python3.11/site-packages/sagemaker/utils.py:1526 in │
│ instance_supports_kms │
│ │
│ 1523 │ Raises: │
│ 1524 │ │ ValueError: If the instance type is improperly formatted. │
│ 1525 │ """ │
│ ❱ 1526 │ return volume_size_supported(instance_type) │
│ 1527 │
│ 1528 │
│ 1529 def get_instance_type_family(instance_type: str) -> str: │
│ │
│ /home/igalang/dev/lw_sagemaker/.venv/lib/python3.11/site-packages/sagemaker/utils.py:1517 in │
│ volume_size_supported │
│ │
│ 1514 │ │ │ family.startswith(prefix) for prefix in unsupported_families │
│ 1515 │ │ ) │
│ 1516 │ except Exception as e: │
│ ❱ 1517 │ │ raise ValueError(f"Failed to parse instance type '{instance_type}': {str(e)}") │
│ 1518 │
│ 1519 │
│ 1520 def instance_supports_kms(instance_type: str) -> bool: │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Failed to parse instance type 'None': 'NoneType' object has no attribute 'startswith'
System information
A description of your system. Please provide:
- SageMaker Python SDK version: 2.247.1
- Python version: 3.11.13