diff --git a/src/sagemaker/workflow/notebook_job_step.py b/src/sagemaker/workflow/notebook_job_step.py index ca0ecac15b..8db95a2fae 100644 --- a/src/sagemaker/workflow/notebook_job_step.py +++ b/src/sagemaker/workflow/notebook_job_step.py @@ -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: diff --git a/tests/unit/sagemaker/workflow/test_notebook_job_step.py b/tests/unit/sagemaker/workflow/test_notebook_job_step.py index 6a5bb20daa..aad6767953 100644 --- a/tests/unit/sagemaker/workflow/test_notebook_job_step.py +++ b/tests/unit/sagemaker/workflow/test_notebook_job_step.py @@ -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)) @@ -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) ) @@ -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):