Skip to content

Commit 3528e48

Browse files
committed
chore: improve vulnerable/deprecated error message
1 parent ec0c76d commit 3528e48

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/sagemaker/jumpstart/exceptions.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
"Note that models may have different input/output signatures after a major version upgrade."
4040
)
4141

42+
_VULNERABLE_DEPRECATED_ERROR_RECOMMENDATION = (
43+
"We recommend that you specify a more recent "
44+
"model version or choose a different model. To access the latest models "
45+
"and model versions, be sure to upgrade to the latest version of the SageMaker Python SDK."
46+
)
47+
4248

4349
def get_wildcard_model_version_msg(
4450
model_id: str, wildcard_model_version: str, full_model_version: str
@@ -115,16 +121,15 @@ def __init__(
115121
self.message = (
116122
f"Version '{version}' of JumpStart model '{model_id}' " # type: ignore
117123
"has at least 1 vulnerable dependency in the inference script. "
118-
"Please try targeting a higher version of the model or using a "
119-
"different model. List of vulnerabilities: "
124+
f"{_VULNERABLE_DEPRECATED_ERROR_RECOMMENDATION} "
125+
"List of vulnerabilities: "
120126
f"{', '.join(vulnerabilities)}" # type: ignore
121127
)
122128
elif scope == JumpStartScriptScope.TRAINING:
123129
self.message = (
124130
f"Version '{version}' of JumpStart model '{model_id}' " # type: ignore
125131
"has at least 1 vulnerable dependency in the training script. "
126-
"Please try targeting a higher version of the model, upgrading "
127-
"SageMaker Python SDK version or using a different model. "
132+
f"{_VULNERABLE_DEPRECATED_ERROR_RECOMMENDATION} "
128133
"List of vulnerabilities: "
129134
f"{', '.join(vulnerabilities)}" # type: ignore
130135
)
@@ -160,8 +165,7 @@ def __init__(
160165
raise RuntimeError("Must specify `model_id` and `version` arguments.")
161166
self.message = (
162167
f"Version '{version}' of JumpStart model '{model_id}' is deprecated. "
163-
"Please try targeting a higher version of the model, upgrading "
164-
"SageMaker Python SDK version or using a different model."
168+
f"{_VULNERABLE_DEPRECATED_ERROR_RECOMMENDATION}"
165169
)
166170

167171
super().__init__(self.message)

tests/unit/sagemaker/jumpstart/test_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,10 @@ def make_vulnerable_inference_spec(*largs, **kwargs):
10521052
assert (
10531053
"Version '*' of JumpStart model 'pytorch-eqa-bert-base-cased' has at least 1 "
10541054
"vulnerable dependency in the inference script. "
1055-
"Please try targeting a higher version of the model or using a different model. "
1055+
"We recommend that you specify a more recent model version or "
1056+
"choose a different model. To access the "
1057+
"latest models and model versions, be sure to upgrade "
1058+
"to the latest version of the SageMaker Python SDK. "
10561059
"List of vulnerabilities: some, vulnerability"
10571060
) == str(e.value.message)
10581061

@@ -1074,8 +1077,10 @@ def make_vulnerable_training_spec(*largs, **kwargs):
10741077
assert (
10751078
"Version '*' of JumpStart model 'pytorch-eqa-bert-base-cased' has at least 1 "
10761079
"vulnerable dependency in the training script. "
1077-
"Please try targeting a higher version of the model, "
1078-
"upgrading SageMaker Python SDK version or using a different model. "
1080+
"We recommend that you specify a more recent model version or "
1081+
"choose a different model. To access the "
1082+
"latest models and model versions, be sure to upgrade "
1083+
"to the latest version of the SageMaker Python SDK. "
10791084
"List of vulnerabilities: some, vulnerability"
10801085
) == str(e.value.message)
10811086

0 commit comments

Comments
 (0)