-
Notifications
You must be signed in to change notification settings - Fork 0
fix: [Bug] Pipeline parameters (ParameterInteger, ParameterString) fail in ModelTrain (5504) #27
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -410,14 +410,22 @@ def __del__(self): | |
| self._temp_code_dir.cleanup() | ||
|
|
||
| def _validate_training_image_and_algorithm_name( | ||
| self, training_image: Optional[str], algorithm_name: Optional[str] | ||
| self, training_image, algorithm_name | ||
| ): | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type annotations on the method signature should be broadened to reflect that def _validate_training_image_and_algorithm_name(
self, training_image: str | PipelineVariable | None, algorithm_name: str | PipelineVariable | None
): |
||
| """Validate that only one of 'training_image' or 'algorithm_name' is provided.""" | ||
| if not training_image and not algorithm_name: | ||
| from sagemaker.core.helper.pipeline_variable import PipelineVariable | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move import to module level. Placing the import inside the method means it runs on every call. Unless there's a circular import issue, prefer a top-of-file import: from sagemaker.core.helper.pipeline_variable import PipelineVariableIf there is a circular dependency, please add a comment explaining why the local import is necessary. |
||
|
|
||
| has_training_image = training_image is not None and ( | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the truthiness check. The def _is_provided(value):
if value is None:
return False
if isinstance(value, PipelineVariable):
return True
return bool(value)
has_training_image = _is_provided(training_image)
has_algorithm_name = _is_provided(algorithm_name)This is easier to read and self-documenting. Consider adding a brief comment explaining why |
||
| isinstance(training_image, PipelineVariable) or bool(training_image) | ||
| ) | ||
| has_algorithm_name = algorithm_name is not None and ( | ||
| isinstance(algorithm_name, PipelineVariable) or bool(algorithm_name) | ||
| ) | ||
| if not has_training_image and not has_algorithm_name: | ||
| raise ValueError( | ||
| "Atleast one of 'training_image' or 'algorithm_name' must be provided.", | ||
| ) | ||
| if training_image and algorithm_name: | ||
| if has_training_image and has_algorithm_name: | ||
| raise ValueError( | ||
| "Only one of 'training_image' or 'algorithm_name' must be provided.", | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type annotations removed instead of broadened. Removing the
Optional[str]annotations silently drops type safety. Instead, broaden the type hints to acceptPipelineVariable:Also, the PR description says this method was updated to "skip
PipelineVariablevalues when deriving the base job name," but the diff shows no such logic was added. The body ofget_base_job_namelikely calls something likebase_name_from_image(training_image)or usesalgorithm_nameas a string — passing aPipelineVariablethere will still fail. Please add the guard logic to skipPipelineVariablevalues and fall back to a generic default name.