Conversation
…o list Using Sou (aws#5518)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix TypeError when
SourceCode.requirementsis None in Pipeline TrainingStepProblem
When using a
TrainingStepin a Pipeline whereSourceCode.requirementsis not set (defaults toNone), callingpipeline.upsert()raises aTypeError: can only concatenate list (not 'NoneType') to list. This occurs during the code hash computation inget_code_hash()→get_training_code_hash().Root Cause
The
get_code_hash()function readssource_code.requirementswhich can beNoneand passes it directly toget_training_code_hash()as thedependenciesparameter. Whileget_training_code_hash()already hasif dependencies:guards to prevent concatenation withNone, theget_code_hash()function did not normalize falsy values (like empty strings) before passing them through.Fix
get_code_hash(): Changedrequirements = source_code.requirementstorequirements = source_code.requirements or Noneto handle bothNoneand empty string edge cases.get_training_code_hash()function already correctly checksif dependencies:before attempting list concatenation, which handles theNonecase.Tests Added
test_get_training_code_hash_with_none_dependencies_source_dir- Verifies no TypeError when dependencies isNonewith source_dirtest_get_training_code_hash_with_none_dependencies_entry_point_only- Verifies no TypeError when dependencies isNonewith entry_point onlytest_get_training_code_hash_with_default_dependencies- Verifies the default parameter value works correctlytest_get_code_hash_training_step_with_no_requirements- End-to-end test with mock TrainingStep andNonerequirementstest_get_code_hash_training_step_with_empty_string_requirements- End-to-end test with mock TrainingStep and empty string requirementsRelated Issue
Fixes aws#5518
Changes Made
The bug occurs when
SourceCode.requirementsis not set (defaults toNone) and aTrainingStepis used in a Pipeline. Duringpipeline.upsert()→definition()→get_code_hash(step), the code readssource_code.requirements(which isNone) and passes it toget_training_code_hash()as thedependenciesparameter. In the version the user is running (3.3.1), the function attempts[source_dir] + dependencieswheredependenciesisNone, causingTypeError: can only concatenate list (not 'NoneType') to list. The current repo code already hasif dependencies:guards inget_training_code_hash, but the fix needs to be verified as complete and properly tested. Additionally, theget_code_hashfunction inutilities.pyshould defensively handleNonerequirements before passing toget_training_code_hashto prevent this class of error.AI-Generated PR
This PR was automatically generated by the PySDK Issue Agent.
Merge Checklist
prefix: descriptionformat