Skip to content

Commit 97579f3

Browse files
committed
fix: Pipeline TypeError: can only concatenate list (not "NoneType") to list Using Sou (aws#5518)
1 parent 6a1ba54 commit 97579f3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

sagemaker-core/src/sagemaker/core/workflow/utilities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ def get_code_hash(step: Entity) -> str:
149149
Returns:
150150
str: A hash string representing the unique code artifact(s) for the step
151151
"""
152+
153+
dependencies = dependencies or []
152154
from sagemaker.mlops.workflow.steps import ProcessingStep, TrainingStep
153155

154156
if isinstance(step, ProcessingStep) and step.step_args:

sagemaker-core/tests/unit/workflow/test_utilities.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,48 @@ def test_get_processing_code_hash_with_dependencies(self):
264264

265265
assert result is not None
266266

267+
def test_get_processing_code_hash_with_none_dependencies(self):
268+
"""Test get_processing_code_hash with None dependencies does not raise TypeError"""
269+
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
270+
f.write("print('hello')")
271+
temp_file = f.name
272+
273+
try:
274+
result = get_processing_code_hash(code=temp_file, source_dir=None, dependencies=None)
275+
276+
assert result is not None
277+
assert len(result) == 64
278+
finally:
279+
os.unlink(temp_file)
280+
281+
def test_get_processing_code_hash_with_source_dir_and_none_dependencies(self):
282+
"""Test get_processing_code_hash with source_dir and None dependencies"""
283+
with tempfile.TemporaryDirectory() as temp_dir:
284+
code_file = Path(temp_dir, "script.py")
285+
code_file.write_text("print('hello')")
286+
287+
result = get_processing_code_hash(
288+
code=str(code_file), source_dir=temp_dir, dependencies=None
289+
)
290+
291+
assert result is not None
292+
assert len(result) == 64
293+
294+
def test_get_processing_code_hash_with_code_only_and_none_dependencies(self):
295+
"""Test get_processing_code_hash with code only and None dependencies"""
296+
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
297+
f.write("print('hello')")
298+
temp_file = f.name
299+
300+
try:
301+
# Ensure no TypeError when dependencies is None
302+
result = get_processing_code_hash(code=temp_file, source_dir=None, dependencies=None)
303+
304+
assert result is not None
305+
assert len(result) == 64
306+
finally:
307+
os.unlink(temp_file)
308+
267309
def test_get_training_code_hash_with_source_dir(self):
268310
"""Test get_training_code_hash with source_dir"""
269311
with tempfile.TemporaryDirectory() as temp_dir:

0 commit comments

Comments
 (0)