Skip to content

Commit fc44983

Browse files
Merge branch 'master' into feature-store-lakeformation
2 parents f9c5803 + b6d86f6 commit fc44983

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
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: 3 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,7 +473,7 @@ 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

v3-examples/ml-ops-examples/v3-mlflow-train-inference-e2e-example.ipynb

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,24 @@
333333
"from mlflow import MlflowClient\n",
334334
"\n",
335335
"client = MlflowClient()\n",
336-
"registered_model = client.get_registered_model(name=MLFLOW_REGISTERED_MODEL_NAME)\n",
337336
"\n",
338-
"latest_version = registered_model.latest_versions[0]\n",
337+
"# MLflow 3.x removed RegisteredModel.latest_versions - use search_model_versions instead\n",
338+
"latest_version = client.search_model_versions(\n",
339+
" filter_string=f\"name='{MLFLOW_REGISTERED_MODEL_NAME}'\",\n",
340+
" order_by=[\"version_number DESC\"],\n",
341+
" max_results=1\n",
342+
")[0]\n",
343+
"\n",
339344
"model_version = latest_version.version\n",
340345
"model_source = latest_version.source\n",
341346
"\n",
342-
"# Get S3 URL of model files (for info only)\n",
343-
"artifact_uri = client.get_model_version_download_uri(MLFLOW_REGISTERED_MODEL_NAME, model_version)\n",
344-
"\n",
345347
"# MLflow model registry path to use with ModelBuilder\n",
346348
"mlflow_model_path = f\"models:/{MLFLOW_REGISTERED_MODEL_NAME}/{model_version}\"\n",
347349
"\n",
348350
"print(f\"Registered Model: {MLFLOW_REGISTERED_MODEL_NAME}\")\n",
349351
"print(f\"Latest Version: {model_version}\")\n",
350-
"print(f\"Source: {model_source}\")\n",
351-
"print(f\"Model artifacts location: {artifact_uri}\")"
352+
"print(f\"Source (model artifacts location): {model_source}\")\n",
353+
"print(f\"MLflow model path for deployment: {mlflow_model_path}\")"
352354
]
353355
},
354356
{
@@ -481,19 +483,16 @@
481483
"metadata": {},
482484
"outputs": [],
483485
"source": [
484-
"import boto3\n",
485-
"\n",
486486
"# Test with JSON input\n",
487487
"test_data = [[0.1, 0.2, 0.3, 0.4]]\n",
488488
"\n",
489-
"runtime_client = boto3.client('sagemaker-runtime')\n",
490-
"response = runtime_client.invoke_endpoint(\n",
491-
" EndpointName=core_endpoint.endpoint_name,\n",
492-
" Body=json.dumps(test_data),\n",
493-
" ContentType='application/json'\n",
489+
"result = core_endpoint.invoke(\n",
490+
" body=json.dumps(test_data),\n",
491+
" content_type=\"application/json\"\n",
494492
")\n",
495493
"\n",
496-
"prediction = json.loads(response['Body'].read().decode('utf-8'))\n",
494+
"# Decode and display the result\n",
495+
"prediction = json.loads(result.body.read().decode('utf-8'))\n",
497496
"print(f\"Input: {test_data}\")\n",
498497
"print(f\"Prediction: {prediction}\")"
499498
]

0 commit comments

Comments
 (0)