Skip to content

Commit 3f2ccd9

Browse files
committed
fix: Invalid import (5637)
1 parent ee420cc commit 3f2ccd9

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

sagemaker-mlops/src/sagemaker/mlops/workflow/steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def _find_dependencies_in_step_arguments(
205205
else:
206206
dependencies.add(self._get_step_name_from_str(referenced_step, step_map))
207207

208-
from sagemaker.core.workflow.function_step import DelayedReturn
208+
from sagemaker.mlops.workflow.function_step import DelayedReturn
209209

210210
# TODO: we can remove the if-elif once move the validators to JsonGet constructor
211211
if isinstance(pipeline_variable, JsonGet):

sagemaker-mlops/tests/unit/workflow/test_steps.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def test_step_find_dependencies_in_step_arguments_with_json_get():
409409
obj = {"key": json_get}
410410

411411
with patch('sagemaker.mlops.workflow.steps.TYPE_CHECKING', False):
412-
with patch.dict('sys.modules', {'sagemaker.core.workflow.function_step': Mock()}):
412+
with patch.dict('sys.modules', {'sagemaker.mlops.workflow.function_step': Mock()}):
413413
dependencies = Step._find_dependencies_in_step_arguments(step2, obj, {"step1": step1})
414414
assert "step1" in dependencies
415415

@@ -445,7 +445,7 @@ def test_step_find_dependencies_in_step_arguments_with_delayed_return():
445445
mock_module = Mock()
446446
mock_module.DelayedReturn = delayed_return_class
447447

448-
with patch.dict('sys.modules', {'sagemaker.core.workflow.function_step': mock_module}):
448+
with patch.dict('sys.modules', {'sagemaker.mlops.workflow.function_step': mock_module}):
449449
dependencies = Step._find_dependencies_in_step_arguments(step2, obj, {"step1": step1})
450450
assert "step1" in dependencies
451451

@@ -473,11 +473,18 @@ def test_step_find_dependencies_in_step_arguments_with_string_reference():
473473
mock_module = Mock()
474474
mock_module.DelayedReturn = delayed_return_class
475475

476-
with patch.dict('sys.modules', {'sagemaker.core.workflow.function_step': mock_module}):
476+
with patch.dict('sys.modules', {'sagemaker.mlops.workflow.function_step': mock_module}):
477477
dependencies = Step._find_dependencies_in_step_arguments(step2, obj, step_map)
478478
assert "step1" in dependencies
479479

480480

481+
def test_delayed_return_import_from_correct_module():
482+
"""Verify that DelayedReturn can be imported from sagemaker.mlops.workflow.function_step."""
483+
from sagemaker.mlops.workflow.function_step import DelayedReturn
484+
assert DelayedReturn is not None
485+
assert hasattr(DelayedReturn, '_to_json_get')
486+
487+
481488
def test_tuning_step_requires_step_args():
482489
from sagemaker.mlops.workflow.steps import TuningStep
483490

0 commit comments

Comments
 (0)