Skip to content

Commit 2247f9d

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

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def get_processing_dependencies(dependency_args: List[List[str]]) -> List[str]:
197197

198198

199199
def get_processing_code_hash(code: str, source_dir: str, dependencies: List[str]) -> str:
200+
dependencies = dependencies or []
200201
"""Get the hash of a processing step's code artifact(s).
201202
202203
Args:

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,53 @@ 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_does_not_raise(self):
255+
"""Test get_processing_code_hash with None dependencies does not raise TypeError"""
256+
result = get_processing_code_hash(
257+
code=None, source_dir=None, dependencies=None
258+
)
259+
assert result is None
260+
261+
def test_get_processing_code_hash_with_none_dependencies_and_source_dir(self):
262+
"""Test get_processing_code_hash with None dependencies and source_dir"""
263+
with tempfile.TemporaryDirectory() as temp_dir:
264+
code_file = Path(temp_dir, "script.py")
265+
code_file.write_text("print('hello')")
266+
267+
result = get_processing_code_hash(
268+
code=str(code_file), source_dir=temp_dir, dependencies=None
269+
)
270+
271+
assert result is not None
272+
assert len(result) == 64
273+
274+
def test_get_processing_code_hash_with_none_dependencies_and_code_only(self):
275+
"""Test get_processing_code_hash with None dependencies and code only"""
276+
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
277+
f.write("print('hello')")
278+
temp_file = f.name
279+
280+
try:
281+
result = get_processing_code_hash(code=temp_file, source_dir=None, dependencies=None)
282+
283+
assert result is not None
284+
assert len(result) == 64
285+
finally:
286+
os.unlink(temp_file)
287+
288+
def test_get_processing_code_hash_with_none_dependencies_and_source_dir_and_code(self):
289+
"""Test get_processing_code_hash with None dependencies, source_dir and code"""
290+
with tempfile.TemporaryDirectory() as temp_dir:
291+
code_file = Path(temp_dir, "script.py")
292+
code_file.write_text("print('hello')")
293+
294+
result = get_processing_code_hash(
295+
code=str(code_file), source_dir=temp_dir, dependencies=None
296+
)
297+
298+
assert result is not None
299+
assert len(result) == 64
253300
"""Test get_processing_code_hash with dependencies"""
254301
with tempfile.TemporaryDirectory() as temp_dir:
255302
code_file = Path(temp_dir, "script.py")
@@ -317,6 +364,35 @@ def test_get_training_code_hash_s3_uri(self):
317364
assert result is None
318365

319366
def test_get_training_code_hash_pipeline_variable(self):
367+
368+
def test_get_training_code_hash_with_none_dependencies_and_source_dir(self):
369+
"""Test get_training_code_hash with None dependencies and source_dir"""
370+
with tempfile.TemporaryDirectory() as temp_dir:
371+
entry_file = Path(temp_dir, "train.py")
372+
entry_file.write_text("print('training')")
373+
374+
result = get_training_code_hash(
375+
entry_point=str(entry_file), source_dir=temp_dir, dependencies=None
376+
)
377+
378+
assert result is not None
379+
assert len(result) == 64
380+
381+
def test_get_training_code_hash_with_none_dependencies_and_entry_point_only(self):
382+
"""Test get_training_code_hash with None dependencies and entry_point only"""
383+
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
384+
f.write("print('training')")
385+
temp_file = f.name
386+
387+
try:
388+
result = get_training_code_hash(
389+
entry_point=temp_file, source_dir=None, dependencies=None
390+
)
391+
392+
assert result is not None
393+
assert len(result) == 64
394+
finally:
395+
os.unlink(temp_file)
320396
"""Test get_training_code_hash with pipeline variable returns None"""
321397
with patch("sagemaker.core.workflow.is_pipeline_variable", return_value=True):
322398
result = get_training_code_hash(

0 commit comments

Comments
 (0)