Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
"us-west-1": "742091327244",
"us-west-2": "236514542706"
},
"py_versions": [
"310",
"38"
],
"repository": "sagemaker-base-python"
}
}
Expand Down
8 changes: 6 additions & 2 deletions sagemaker-core/src/sagemaker/core/image_uris.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,11 +972,14 @@ def get_base_python_image_uri(region, py_version="310") -> str:

Args:
region (str): The AWS region to use for image URI.
py_version (str): The python version to use for the image. Can be 310 or 38
Default to 310
py_version (str): The python version to use for the image. Can be 310 or 38.
Defaults to 310.

Returns:
str: The image URI string.

Raises:
ValueError: If the python version is unsupported.
"""

framework = "sagemaker-base-python"
Expand All @@ -988,6 +991,7 @@ def get_base_python_image_uri(region, py_version="310") -> str:
config = config_for_framework(framework)
version_config = config["versions"][_version_for_config(version, config)]

py_version = _validate_py_version_and_set_if_needed(py_version, version_config, framework)
registry = _registry_from_region(region, version_config["registries"])

repo = version_config["repository"] + "-" + py_version
Expand Down
9 changes: 9 additions & 0 deletions sagemaker-core/tests/unit/image_uris/test_base_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,12 @@ def test_get_base_python_image_uri(py_version, load_config):
repo=repo, account=REGISTRIES[region], region=region
)
assert expected == uri


@pytest.mark.parametrize("unsupported_py_version", ["311", "312", "313", "39", "invalid"])
def test_get_base_python_image_uri_unsupported_version(unsupported_py_version):
with pytest.raises(ValueError, match="Unsupported Python version"):
image_uris.get_base_python_image_uri(
region="us-west-2",
py_version=unsupported_py_version,
)
Loading