Skip to content

Commit 004ffba

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

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ def get_processing_code_hash(code: str, source_dir: str, dependencies: List[str]
210210
str: A hash string representing the unique code artifact(s) for the step
211211
"""
212212

213+
dependencies = dependencies or []
214+
213215
# FrameworkProcessor
214216
if source_dir:
215217
source_dir_url = urlparse(source_dir)

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,35 @@ def test_get_processing_code_hash_s3_uri(self):
250250
assert result is None
251251

252252
def test_get_processing_code_hash_with_dependencies(self):
253+
254+
def test_get_processing_code_hash_with_none_dependencies(self):
255+
"""Test get_processing_code_hash with None dependencies does not raise TypeError"""
256+
with tempfile.TemporaryDirectory() as temp_dir:
257+
code_file = Path(temp_dir, "script.py")
258+
code_file.write_text("print('hello')")
259+
260+
# Should not raise TypeError when dependencies is None
261+
result = get_processing_code_hash(
262+
code=str(code_file), source_dir=temp_dir, dependencies=None
263+
)
264+
265+
assert result is not None
266+
assert len(result) == 64
267+
268+
def test_get_processing_code_hash_code_only_with_none_dependencies(self):
269+
"""Test get_processing_code_hash with code only and None dependencies"""
270+
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
271+
f.write("print('hello')")
272+
temp_file = f.name
273+
274+
try:
275+
result = get_processing_code_hash(code=temp_file, source_dir=None, dependencies=None)
276+
277+
assert result is not None
278+
assert len(result) == 64
279+
finally:
280+
os.unlink(temp_file)
281+
253282
"""Test get_processing_code_hash with dependencies"""
254283
with tempfile.TemporaryDirectory() as temp_dir:
255284
code_file = Path(temp_dir, "script.py")
@@ -317,6 +346,37 @@ def test_get_training_code_hash_s3_uri(self):
317346
assert result is None
318347

319348
def test_get_training_code_hash_pipeline_variable(self):
349+
350+
def test_get_training_code_hash_with_none_dependencies_source_dir(self):
351+
"""Test get_training_code_hash with None dependencies and source_dir"""
352+
with tempfile.TemporaryDirectory() as temp_dir:
353+
entry_file = Path(temp_dir, "train.py")
354+
entry_file.write_text("print('training')")
355+
356+
# Should not raise TypeError when dependencies is None
357+
result = get_training_code_hash(
358+
entry_point=str(entry_file), source_dir=temp_dir, dependencies=None
359+
)
360+
361+
assert result is not None
362+
assert len(result) == 64
363+
364+
def test_get_training_code_hash_with_none_dependencies_entry_point_only(self):
365+
"""Test get_training_code_hash with None dependencies and entry_point only"""
366+
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
367+
f.write("print('training')")
368+
temp_file = f.name
369+
370+
try:
371+
result = get_training_code_hash(
372+
entry_point=temp_file, source_dir=None, dependencies=None
373+
)
374+
375+
assert result is not None
376+
assert len(result) == 64
377+
finally:
378+
os.unlink(temp_file)
379+
320380
"""Test get_training_code_hash with pipeline variable returns None"""
321381
with patch("sagemaker.core.workflow.is_pipeline_variable", return_value=True):
322382
result = get_training_code_hash(

0 commit comments

Comments
 (0)