Skip to content

fix: fix bad initialization script error message #5152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
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
12 changes: 7 additions & 5 deletions src/sagemaker/workflow/notebook_job_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,27 @@ def _validate_inputs(self):
# input notebook is required
if not self.input_notebook or not os.path.isfile(self.input_notebook):
errors.append(
f"The required input notebook({self.input_notebook}) is not a valid " f"file."
f"The required input notebook ({self.input_notebook}) is not a valid file."
)

# init script is optional
if self.initialization_script and not os.path.isfile(self.initialization_script):
errors.append(f"The initialization script({self.input_notebook}) is not a valid file.")
errors.append(
f"The initialization script ({self.initialization_script}) is not a valid file."
)

if self.additional_dependencies:
for path in self.additional_dependencies:
if not os.path.exists(path):
errors.append(
f"The path({path}) specified in additional dependencies does not exist."
f"The path ({path}) specified in additional dependencies does not exist."
)
# image uri is required
if not self.image_uri or self._region_from_session not in self.image_uri:
errors.append(
f"The image uri(specified as {self.image_uri}) is required and "
f"The image uri (specified as {self.image_uri}) is required and "
f"should be hosted in same region of the session"
f"({self._region_from_session})."
f" ({self._region_from_session})."
)

if not self.kernel_name:
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/sagemaker/workflow/test_notebook_job_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ def test_invalid_inputs_required_fields_passed_as_none(self):
in str(context.exception)
)
self.assertTrue(
"The required input notebook(None) is not a valid file." in str(context.exception)
"The required input notebook (None) is not a valid file." in str(context.exception)
)
self.assertTrue(
"The image uri(specified as None) is required and should be hosted in "
"same region of the session(us-west-2)." in str(context.exception)
"The image uri (specified as None) is required and should be hosted in "
"same region of the session (us-west-2)." in str(context.exception)
)
self.assertTrue("The kernel name is required." in str(context.exception))

Expand All @@ -222,19 +222,19 @@ def test_invalid_paths_to_upload(self):
).arguments

self.assertTrue(
"The required input notebook(path/non-existing-file) is not a valid file."
"The required input notebook (path/non-existing-file) is not a valid file."
in str(context.exception)
)
self.assertTrue(
"The initialization script(path/non-existing-file) is not a valid file."
"The initialization script (non-existing-script) is not a valid file."
in str(context.exception)
)
self.assertTrue(
"The path(/tmp/non-existing-folder) specified in additional dependencies "
"The path (/tmp/non-existing-folder) specified in additional dependencies "
"does not exist." in str(context.exception)
)
self.assertTrue(
"The path(path2/non-existing-file) specified in additional dependencies "
"The path (path2/non-existing-file) specified in additional dependencies "
"does not exist." in str(context.exception)
)

Expand All @@ -251,9 +251,9 @@ def test_image_uri_is_not_in_the_expected_region(self):
).arguments

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

def test_invalid_notebook_job_name(self):
Expand Down