Skip to content

Commit 5aca797

Browse files
Merge branch 'master' into dacorvo-fix-hf-vllm-image-uri
2 parents 1708115 + 7a61bb6 commit 5aca797

File tree

5 files changed

+90
-3
lines changed

5 files changed

+90
-3
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,36 @@
5858
--source_dir "${var_source_dir}"
5959
"""
6060

61+
# Static list of regions where Experiments (Eureka) is Generally Available.
62+
# Note: Experiments is not expanding to new regions, so this list is static.
63+
EUREKA_GA_REGIONS = frozenset([
64+
"us-east-1", # iad (N. Virginia)
65+
"us-east-2", # cmh (Ohio)
66+
"us-west-1", # sfo (N. California)
67+
"us-west-2", # pdx (Oregon)
68+
"ca-central-1", # yul (Montreal)
69+
"eu-west-1", # dub (Dublin)
70+
"eu-west-2", # lhr (London)
71+
"eu-west-3", # cdg (Paris)
72+
"eu-central-1", # fra (Frankfurt)
73+
"eu-north-1", # arn (Stockholm)
74+
"eu-south-1", # mxp (Milan)
75+
"eu-south-2", # zaz (Spain)
76+
"ap-northeast-1", # nrt (Tokyo)
77+
"ap-northeast-2", # icn (Seoul)
78+
"ap-northeast-3", # kix (Osaka)
79+
"ap-southeast-1", # sin (Singapore)
80+
"ap-southeast-2", # syd (Sydney)
81+
"ap-southeast-3", # cgk (Jakarta)
82+
"ap-south-1", # bom (Mumbai)
83+
"ap-east-1", # hkg (Hong Kong)
84+
"sa-east-1", # gru (São Paulo)
85+
"af-south-1", # cpt (Cape Town)
86+
"me-south-1", # bah (Bahrain)
87+
"il-central-1", # tlv (Tel Aviv)
88+
"cn-north-1", # bjs (Beijing)
89+
"cn-northwest-1", # zhy (Ningxia)
90+
])
6191

6292
class _RepackModelStep(TrainingStep):
6393
"""Repacks model artifacts with custom inference entry points.

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
RESOURCE_NOT_FOUND_EXCEPTION,
5050
EXECUTION_TIME_PIPELINE_PARAMETER_FORMAT,
5151
)
52+
from sagemaker.mlops.workflow._utils import EUREKA_GA_REGIONS
5253
from sagemaker.mlops.workflow.lambda_step import LambdaOutput, LambdaStep
5354
from sagemaker.core.shapes.shapes import MlflowConfig
5455
from sagemaker.core.helper.pipeline_variable import (
@@ -116,6 +117,8 @@ def __init__(
116117
the same name already exists. By default, pipeline name is used as
117118
experiment name and execution id is used as the trial name.
118119
If set to None, no experiment or trial will be created automatically.
120+
Note: The default experiment config is only applied in regions where
121+
Experiments (Eureka) is Generally Available.
119122
mlflow_config (Optional[MlflowConfig]): If set, the pipeline will be configured
120123
with MLflow tracking for experiment tracking and model versioning.
121124
steps (Sequence[Union[Step, StepOutput]]): The list of the
@@ -133,7 +136,6 @@ def __init__(
133136
"""
134137
self.name = name
135138
self.parameters = parameters if parameters else []
136-
self.pipeline_experiment_config = pipeline_experiment_config
137139
self.mlflow_config = mlflow_config
138140
self.steps = steps if steps else []
139141
self.sagemaker_session = sagemaker_session if sagemaker_session else Session()
@@ -146,6 +148,13 @@ def __init__(
146148
self._event_bridge_scheduler_helper = EventBridgeSchedulerHelper(
147149
self.sagemaker_session.boto_session.client("scheduler"),
148150
)
151+
self.pipeline_experiment_config = pipeline_experiment_config
152+
153+
# Apply default experiment config only in Eureka GA regions
154+
if pipeline_experiment_config is _DEFAULT_EXPERIMENT_CFG:
155+
region = self.sagemaker_session.boto_region_name
156+
if region not in EUREKA_GA_REGIONS:
157+
self.pipeline_experiment_config = None
149158

150159
@property
151160
def latest_pipeline_version_id(self):

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def mock_session():
3333
session.sagemaker_client = Mock()
3434
session.boto_session = Mock()
3535
session.boto_session.client = Mock(return_value=Mock())
36+
session.boto_region_name = "us-east-1"
3637
session.local_mode = False
3738
session.sagemaker_config = {}
3839
session._append_sagemaker_config_tags = Mock(return_value=[])
@@ -59,8 +60,12 @@ class TestPipelineInit:
5960
def test_init_minimal(self):
6061
"""Test Pipeline initialization with minimal parameters."""
6162
with patch('sagemaker.mlops.workflow.pipeline.Session') as mock_session_class:
62-
mock_session_class.return_value = Mock()
63-
63+
mock_session = Mock()
64+
mock_session.boto_region_name = "us-east-1"
65+
mock_session.boto_session = Mock()
66+
mock_session.boto_session.client = Mock(return_value=Mock())
67+
mock_session_class.return_value = mock_session
68+
6469
pipeline = Pipeline(name="test-pipeline")
6570

6671
assert pipeline.name == "test-pipeline"

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
"""Unit tests for workflow pipeline_experiment_config."""
1414
from __future__ import absolute_import
1515

16+
from unittest.mock import Mock
17+
1618
from sagemaker.mlops.workflow.pipeline_experiment_config import (
1719
PipelineExperimentConfig, PipelineExperimentConfigProperties
1820
)
21+
from sagemaker.mlops.workflow.pipeline import Pipeline, _DEFAULT_EXPERIMENT_CFG
1922
from sagemaker.core.workflow.execution_variables import ExecutionVariables
2023

2124

@@ -41,3 +44,42 @@ def test_pipeline_experiment_config_with_execution_variables():
4144
def test_pipeline_experiment_config_properties():
4245
assert PipelineExperimentConfigProperties.EXPERIMENT_NAME.name == "ExperimentName"
4346
assert PipelineExperimentConfigProperties.TRIAL_NAME.name == "TrialName"
47+
48+
49+
def _create_mock_session(region: str) -> Mock:
50+
"""Helper to create a mock SageMaker session with specified region."""
51+
mock_session = Mock()
52+
mock_session.boto_region_name = region
53+
mock_session.boto_session = Mock()
54+
mock_session.boto_session.client = Mock(return_value=Mock())
55+
mock_session.local_mode = False
56+
return mock_session
57+
58+
59+
def test_default_config_applied_in_ga_region():
60+
"""Default config applied when nothing provided in GA region."""
61+
mock_session = _create_mock_session("us-east-1")
62+
pipeline = Pipeline(name="test-pipeline", sagemaker_session=mock_session)
63+
assert pipeline.pipeline_experiment_config == _DEFAULT_EXPERIMENT_CFG
64+
65+
66+
def test_no_default_config_in_non_ga_region():
67+
"""No default config when nothing provided in non-GA region (THE FIX)."""
68+
mock_session = _create_mock_session("us-gov-west-1")
69+
pipeline = Pipeline(name="test-pipeline", sagemaker_session=mock_session)
70+
assert pipeline.pipeline_experiment_config is None
71+
72+
73+
def test_explicit_none_respected_in_ga_region():
74+
"""None gets default config in GA region."""
75+
mock_session = _create_mock_session("us-east-1")
76+
pipeline = Pipeline(name="test-pipeline", sagemaker_session=mock_session, pipeline_experiment_config=None)
77+
assert pipeline.pipeline_experiment_config is None
78+
79+
80+
def test_custom_config_respected():
81+
"""Custom config respected regardless of region."""
82+
mock_session = _create_mock_session("us-east-1")
83+
custom_config = PipelineExperimentConfig("my-experiment", "my-trial")
84+
pipeline = Pipeline(name="test-pipeline", sagemaker_session=mock_session, pipeline_experiment_config=custom_config)
85+
assert pipeline.pipeline_experiment_config == custom_config

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def mock_session():
2626
"""Create a mock SageMaker session for testing."""
2727
session = Mock()
2828
session.boto_session.client.return_value = Mock()
29+
session.boto_region_name = "us-east-1"
2930
session.sagemaker_client = Mock()
3031
session.local_mode = False
3132
session.sagemaker_config = {}

0 commit comments

Comments
 (0)