Skip to content

Commit c66a39e

Browse files
nmadanNamrata Madan
and
Namrata Madan
authored
fix: fix bad initialization script error message (#5152)
Co-authored-by: Namrata Madan <[email protected]>
1 parent e747b03 commit c66a39e

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/sagemaker/workflow/notebook_job_step.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -243,25 +243,27 @@ def _validate_inputs(self):
243243
# input notebook is required
244244
if not self.input_notebook or not os.path.isfile(self.input_notebook):
245245
errors.append(
246-
f"The required input notebook({self.input_notebook}) is not a valid " f"file."
246+
f"The required input notebook ({self.input_notebook}) is not a valid file."
247247
)
248248

249249
# init script is optional
250250
if self.initialization_script and not os.path.isfile(self.initialization_script):
251-
errors.append(f"The initialization script({self.input_notebook}) is not a valid file.")
251+
errors.append(
252+
f"The initialization script ({self.initialization_script}) is not a valid file."
253+
)
252254

253255
if self.additional_dependencies:
254256
for path in self.additional_dependencies:
255257
if not os.path.exists(path):
256258
errors.append(
257-
f"The path({path}) specified in additional dependencies does not exist."
259+
f"The path ({path}) specified in additional dependencies does not exist."
258260
)
259261
# image uri is required
260262
if not self.image_uri or self._region_from_session not in self.image_uri:
261263
errors.append(
262-
f"The image uri(specified as {self.image_uri}) is required and "
264+
f"The image uri (specified as {self.image_uri}) is required and "
263265
f"should be hosted in same region of the session"
264-
f"({self._region_from_session})."
266+
f" ({self._region_from_session})."
265267
)
266268

267269
if not self.kernel_name:

tests/unit/sagemaker/workflow/test_notebook_job_step.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ def test_invalid_inputs_required_fields_passed_as_none(self):
199199
in str(context.exception)
200200
)
201201
self.assertTrue(
202-
"The required input notebook(None) is not a valid file." in str(context.exception)
202+
"The required input notebook (None) is not a valid file." in str(context.exception)
203203
)
204204
self.assertTrue(
205-
"The image uri(specified as None) is required and should be hosted in "
206-
"same region of the session(us-west-2)." in str(context.exception)
205+
"The image uri (specified as None) is required and should be hosted in "
206+
"same region of the session (us-west-2)." in str(context.exception)
207207
)
208208
self.assertTrue("The kernel name is required." in str(context.exception))
209209

@@ -222,19 +222,19 @@ def test_invalid_paths_to_upload(self):
222222
).arguments
223223

224224
self.assertTrue(
225-
"The required input notebook(path/non-existing-file) is not a valid file."
225+
"The required input notebook (path/non-existing-file) is not a valid file."
226226
in str(context.exception)
227227
)
228228
self.assertTrue(
229-
"The initialization script(path/non-existing-file) is not a valid file."
229+
"The initialization script (non-existing-script) is not a valid file."
230230
in str(context.exception)
231231
)
232232
self.assertTrue(
233-
"The path(/tmp/non-existing-folder) specified in additional dependencies "
233+
"The path (/tmp/non-existing-folder) specified in additional dependencies "
234234
"does not exist." in str(context.exception)
235235
)
236236
self.assertTrue(
237-
"The path(path2/non-existing-file) specified in additional dependencies "
237+
"The path (path2/non-existing-file) specified in additional dependencies "
238238
"does not exist." in str(context.exception)
239239
)
240240

@@ -251,9 +251,9 @@ def test_image_uri_is_not_in_the_expected_region(self):
251251
).arguments
252252

253253
self.assertTrue(
254-
"The image uri(specified as 236514542706.dkr.ecr.us-east-9.amazonaws.com/"
254+
"The image uri (specified as 236514542706.dkr.ecr.us-east-9.amazonaws.com/"
255255
"sagemaker-data-science) is required and should be hosted in "
256-
"same region of the session(us-west-2)." in str(context.exception)
256+
"same region of the session (us-west-2)." in str(context.exception)
257257
)
258258

259259
def test_invalid_notebook_job_name(self):

0 commit comments

Comments
 (0)