Skip to content

Commit 76d5f4c

Browse files
committed
chore: remove unnecessary log, improve error message
1 parent f84d5ae commit 76d5f4c

File tree

2 files changed

+11
-45
lines changed

2 files changed

+11
-45
lines changed

src/sagemaker/jumpstart/artifacts/image_uris.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from sagemaker.jumpstart.constants import (
1919
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
2020
JUMPSTART_DEFAULT_REGION_NAME,
21-
JUMPSTART_LOGGER,
2221
)
2322
from sagemaker.jumpstart.enums import (
2423
JumpStartScriptScope,
@@ -128,13 +127,11 @@ def _retrieve_image_uri(
128127
return image_uri
129128
ecr_specs = model_specs.hosting_ecr_specs
130129
if ecr_specs is None:
131-
raise ValueError("No value for hosting ECR specs found!")
132-
JUMPSTART_LOGGER.warning(
133-
"Using fallback inference ECR specs for retrieving image URI "
134-
"for JumpStart model ID '%s': '%s'",
135-
model_id,
136-
str(ecr_specs),
137-
)
130+
raise ValueError(
131+
f"No hosting ECR specs found for JumpStart model ID '{model_id}' with "
132+
f"{instance_type} instance type in {region}. "
133+
"Please try another instance type or region."
134+
)
138135
elif image_scope == JumpStartScriptScope.TRAINING:
139136
training_instance_type_variants = model_specs.training_instance_type_variants
140137
if training_instance_type_variants:
@@ -145,13 +142,11 @@ def _retrieve_image_uri(
145142
return image_uri
146143
ecr_specs = model_specs.training_ecr_specs
147144
if ecr_specs is None:
148-
raise ValueError("No value for training ECR specs found!")
149-
JUMPSTART_LOGGER.warning(
150-
"Using fallback training ECR specs for retrieving image URI "
151-
"for JumpStart model ID '%s': '%s'",
152-
model_id,
153-
str(ecr_specs),
154-
)
145+
raise ValueError(
146+
f"No training ECR specs found for JumpStart model ID '{model_id}' with "
147+
f"{instance_type} instance type in {region}. "
148+
"Please try another instance type or region."
149+
)
155150
if framework is not None and framework != ecr_specs.framework:
156151
raise ValueError(
157152
f"Incorrect container framework '{framework}' for JumpStart model ID '{model_id}' "

tests/unit/sagemaker/image_uris/jumpstart/test_variants.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
from tests.unit.sagemaker.jumpstart.utils import get_special_model_spec
2222

2323

24-
@patch("sagemaker.jumpstart.artifacts.image_uris.JUMPSTART_LOGGER.warning")
2524
@patch("sagemaker.jumpstart.artifacts.image_uris.verify_model_region_and_return_specs")
2625
@patch("sagemaker.jumpstart.accessors.JumpStartModelsAccessor.get_model_specs")
2726
def test_jumpstart_variants_image_uri(
28-
patched_get_model_specs, patched_verify_model_region_and_return_specs, patched_warning_logger
27+
patched_get_model_specs, patched_verify_model_region_and_return_specs
2928
):
3029

3130
patched_verify_model_region_and_return_specs.side_effect = verify_model_region_and_return_specs
@@ -44,8 +43,6 @@ def test_jumpstart_variants_image_uri(
4443
)
4544
)
4645

47-
patched_warning_logger.assert_not_called()
48-
4946
assert "867930986793.dkr.us-west-2.amazonaws.com/cpu-blah" == image_uris.retrieve(
5047
framework=None,
5148
region="us-west-2",
@@ -55,10 +52,6 @@ def test_jumpstart_variants_image_uri(
5552
instance_type="ml.c2.xlarge",
5653
)
5754

58-
patched_warning_logger.assert_not_called()
59-
60-
patched_warning_logger.reset_mock()
61-
6255
assert (
6356
"763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-inference:1.5.0-cpu-py3"
6457
== image_uris.retrieve(
@@ -71,14 +64,6 @@ def test_jumpstart_variants_image_uri(
7164
)
7265
)
7366

74-
patched_warning_logger.assert_called_once_with(
75-
"Using fallback inference ECR specs for retrieving image URI for JumpStart model ID '%s': '%s'",
76-
"variant-model",
77-
"JumpStartECRSpecs: {'framework': 'pytorch', 'framework_version': '1.5.0', 'py_version': 'py3'}",
78-
)
79-
80-
patched_warning_logger.reset_mock()
81-
8267
with pytest.raises(ValueError):
8368
image_uris.retrieve(
8469
framework=None,
@@ -89,14 +74,6 @@ def test_jumpstart_variants_image_uri(
8974
instance_type="ml.c2.xlarge",
9075
)
9176

92-
patched_warning_logger.assert_called_once_with(
93-
"Using fallback inference ECR specs for retrieving image URI for JumpStart model ID '%s': '%s'",
94-
"variant-model",
95-
"JumpStartECRSpecs: {'framework': 'pytorch', 'framework_version': '1.5.0', 'py_version': 'py3'}",
96-
)
97-
98-
patched_warning_logger.reset_mock()
99-
10077
assert (
10178
"763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-training:1.5.0-gpu-py3"
10279
== image_uris.retrieve(
@@ -108,9 +85,3 @@ def test_jumpstart_variants_image_uri(
10885
instance_type="ml.g4dn.2xlarge",
10986
)
11087
)
111-
112-
patched_warning_logger.assert_called_once_with(
113-
"Using fallback training ECR specs for retrieving image URI for JumpStart model ID '%s': '%s'",
114-
"variant-model",
115-
"JumpStartECRSpecs: {'framework': 'pytorch', 'framework_version': '1.5.0', 'py_version': 'py3'}",
116-
)

0 commit comments

Comments
 (0)