Skip to content

Commit 1b68ecf

Browse files
authored
Merge branch 'master' into feature/lumen-ai-inference-recommender
2 parents 9777904 + d18005d commit 1b68ecf

5 files changed

Lines changed: 104 additions & 19 deletions

File tree

‎sagemaker-core/src/sagemaker/core/model_monitor/model_monitoring.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4174,7 +4174,7 @@ def __init__(
41744174
41754175
"""
41764176
self.data_captured_destination_s3_uri = data_captured_destination_s3_uri
4177-
self.s3_output.s3_uri = destination
4177+
self.destination = destination
41784178
self.s3_input_mode = s3_input_mode
41794179
self.s3_data_distribution_type = s3_data_distribution_type
41804180
self.dataset_format = dataset_format
@@ -4193,7 +4193,7 @@ def _to_request_dict(self):
41934193
"""Generates a request dictionary using the parameters provided to the class."""
41944194
batch_transform_input_data = {
41954195
"DataCapturedDestinationS3Uri": self.data_captured_destination_s3_uri,
4196-
"LocalPath": self.s3_output.s3_uri,
4196+
"LocalPath": self.destination,
41974197
"S3InputMode": self.s3_input_mode,
41984198
"S3DataDistributionType": self.s3_data_distribution_type,
41994199
"DatasetFormat": self.dataset_format,

‎sagemaker-core/tests/unit/test_model_monitoring.py‎

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
CONSTRAINT_VIOLATIONS_JSON_DEFAULT_FILE_NAME,
3030
DEFAULT_REPOSITORY_NAME,
3131
)
32+
from sagemaker.core.model_monitor.dataset_format import MonitoringDatasetFormat
3233
from sagemaker.core.processing import ProcessingInput, ProcessingOutput
3334
from sagemaker.core.shapes import ProcessingS3Input, ProcessingS3Output
3435
from sagemaker.core.network import NetworkConfig
@@ -140,8 +141,81 @@ def test_to_request_dict_minimal(self):
140141

141142
class TestBatchTransformInput:
142143
def test_init_minimal(self):
143-
# Skip this test as BatchTransformInput has initialization issues in the source code
144-
pytest.skip("BatchTransformInput has initialization issues in the source code")
144+
bti = BatchTransformInput(
145+
data_captured_destination_s3_uri="s3://bucket/captured",
146+
destination="/opt/ml/processing/input",
147+
dataset_format=MonitoringDatasetFormat.csv(header=False),
148+
)
149+
assert bti.data_captured_destination_s3_uri == "s3://bucket/captured"
150+
assert bti.destination == "/opt/ml/processing/input"
151+
assert bti.s3_input_mode == "File"
152+
assert bti.s3_data_distribution_type == "FullyReplicated"
153+
154+
def test_init_with_all_parameters(self):
155+
bti = BatchTransformInput(
156+
data_captured_destination_s3_uri="s3://bucket/captured",
157+
destination="/opt/ml/processing/input",
158+
dataset_format=MonitoringDatasetFormat.csv(header=False),
159+
s3_input_mode="Pipe",
160+
s3_data_distribution_type="ShardedByS3Key",
161+
start_time_offset="-PT1H",
162+
end_time_offset="-PT0H",
163+
features_attribute="features",
164+
inference_attribute="prediction",
165+
probability_attribute="probability",
166+
probability_threshold_attribute=0.5,
167+
exclude_features_attribute="feature1,feature2",
168+
)
169+
assert bti.s3_input_mode == "Pipe"
170+
assert bti.start_time_offset == "-PT1H"
171+
assert bti.features_attribute == "features"
172+
173+
def test_to_request_dict_minimal(self):
174+
bti = BatchTransformInput(
175+
data_captured_destination_s3_uri="s3://bucket/captured",
176+
destination="/opt/ml/processing/input",
177+
dataset_format=MonitoringDatasetFormat.csv(header=False),
178+
)
179+
request_dict = bti._to_request_dict()
180+
assert "BatchTransformInput" in request_dict
181+
payload = request_dict["BatchTransformInput"]
182+
assert payload["DataCapturedDestinationS3Uri"] == "s3://bucket/captured"
183+
assert payload["LocalPath"] == "/opt/ml/processing/input"
184+
assert payload["S3InputMode"] == "File"
185+
assert payload["S3DataDistributionType"] == "FullyReplicated"
186+
187+
def test_to_request_dict_excludes_none_values(self):
188+
bti = BatchTransformInput(
189+
data_captured_destination_s3_uri="s3://bucket/captured",
190+
destination="/opt/ml/processing/input",
191+
dataset_format=MonitoringDatasetFormat.csv(header=False),
192+
)
193+
payload = bti._to_request_dict()["BatchTransformInput"]
194+
assert "StartTimeOffset" not in payload
195+
assert "EndTimeOffset" not in payload
196+
assert "FeaturesAttribute" not in payload
197+
assert "InferenceAttribute" not in payload
198+
assert "ProbabilityAttribute" not in payload
199+
assert "ProbabilityThresholdAttribute" not in payload
200+
assert "ExcludeFeaturesAttribute" not in payload
201+
202+
def test_to_request_dict_includes_optional_values(self):
203+
bti = BatchTransformInput(
204+
data_captured_destination_s3_uri="s3://bucket/captured",
205+
destination="/opt/ml/processing/input",
206+
dataset_format=MonitoringDatasetFormat.csv(header=False),
207+
start_time_offset="-PT1H",
208+
end_time_offset="-PT0H",
209+
probability_attribute="probability",
210+
probability_threshold_attribute=0.5,
211+
exclude_features_attribute="f1,f2",
212+
)
213+
payload = bti._to_request_dict()["BatchTransformInput"]
214+
assert payload["StartTimeOffset"] == "-PT1H"
215+
assert payload["EndTimeOffset"] == "-PT0H"
216+
assert payload["ProbabilityAttribute"] == "probability"
217+
assert payload["ProbabilityThresholdAttribute"] == 0.5
218+
assert payload["ExcludeFeaturesAttribute"] == "f1,f2"
145219

146220

147221
class TestBaseliningJob:

‎sagemaker-mlops/tests/integ/feature_store/feature_processor/test_feature_processor_integ.py‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,11 @@ def transform(raw_s3_data_as_df):
528528
)
529529

530530

531-
@pytest.mark.skipif(
532-
sys.version_info[:2] not in [(3, 9), (3, 12)],
533-
reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
534-
)
531+
# @pytest.mark.skipif(
532+
# sys.version_info[:2] not in [(3, 9), (3, 12)],
533+
# reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
534+
# )
535+
@pytest.mark.spark_py312
535536
@pytest.mark.slow_test
536537
def test_feature_processor_transform_offline_only_store_ingestion_run_with_remote(
537538
sagemaker_session,
@@ -669,10 +670,11 @@ def transform(raw_s3_data_as_df):
669670
)
670671

671672

672-
@pytest.mark.skipif(
673-
sys.version_info[:2] not in [(3, 9), (3, 12)],
674-
reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
675-
)
673+
# @pytest.mark.skipif(
674+
# sys.version_info[:2] not in [(3, 9), (3, 12)],
675+
# reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
676+
# )
677+
@pytest.mark.spark_py312
676678
@pytest.mark.slow_test
677679
def test_to_pipeline_and_execute(
678680
sagemaker_session,
@@ -792,10 +794,16 @@ def transform(raw_s3_data_as_df):
792794
# cleanup_pipeline(pipeline_name="pipeline-name-01", sagemaker_session=sagemaker_session)
793795

794796

795-
@pytest.mark.skipif(
796-
sys.version_info[:2] not in [(3, 9), (3, 12)],
797-
reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
797+
# @pytest.mark.skipif(
798+
# sys.version_info[:2] not in [(3, 9), (3, 12)],
799+
# reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
800+
# )
801+
@pytest.mark.skip(
802+
reason="Lake Formation credential vending (GetTemporaryGlueTableCredentials) requires "
803+
"full LF environment setup (resource registration, trust policy, data location grants) "
804+
"that is not configured in CI. See quip-amazon.com/S3FEAMMMuKm0 for details."
798805
)
806+
@pytest.mark.spark_py312
799807
@pytest.mark.slow_test
800808
def test_to_pipeline_and_execute_with_lake_formation(
801809
sagemaker_session,
@@ -940,10 +948,11 @@ def transform(raw_s3_data_as_df):
940948
cleanup_feature_group(car_data_fg, sagemaker_session=sagemaker_session)
941949

942950

943-
@pytest.mark.skipif(
944-
sys.version_info[:2] not in [(3, 9), (3, 12)],
945-
reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
946-
)
951+
# @pytest.mark.skipif(
952+
# sys.version_info[:2] not in [(3, 9), (3, 12)],
953+
# reason=f"SageMaker Spark image only supports Python 3.9 and 3.12, got {sys.version_info[:2]}",
954+
# )
955+
@pytest.mark.spark_py312
947956
@pytest.mark.slow_test
948957
def test_schedule_and_event_trigger(
949958
sagemaker_session,

‎sagemaker-mlops/tests/integ/feature_store/feature_processor/test_feature_processor_spark_compat.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def test_spark_session_factory_configs_include_dynamic_hadoop():
5454
assert f"org.apache.hadoop:hadoop-common:{hadoop_version}" in packages
5555

5656

57+
@pytest.mark.spark_py312
5758
@pytest.mark.slow_test
5859
def test_image_resolver_returns_uri_for_installed_pyspark():
5960
"""Verify the image resolver returns a valid URI for the installed PySpark + Python version."""

‎sagemaker-mlops/tox.ini‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ markers =
6060
cron
6161
local_mode
6262
slow_test
63+
spark_py312: mark a test that requires Python 3.12 (Spark image compatibility).
6364
release
6465
image_uris_unit_test
6566
timeout: mark a test as a timeout.

0 commit comments

Comments
 (0)