Skip to content

Commit 6eaea0d

Browse files
mahithsureshmahithsureshchuyang-deng
authored
feature: Add SDK support for SparkML Serving Container version 2.4 (aws#1917)
* feature: add support for spark ml serving container version 2.4 * Edited the ChangeLog. * Updated README.rst * Update the image URI config for sparkml serving. Co-authored-by: mahithsuresh <[email protected]> Co-authored-by: Chuyang <[email protected]>
1 parent bd32aa9 commit 6eaea0d

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

Diff for: README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ In order to host a SparkML model in SageMaker, it should be serialized with ``ML
201201

202202
For more information on MLeap, see https://github.com/combust/mleap .
203203

204-
Supported major version of Spark: 2.2 (MLeap version - 0.9.6)
204+
Supported major version of Spark: 2.4 (MLeap version - 0.9.6)
205205

206206
Here is an example on how to create an instance of ``SparkMLModel`` class and use ``deploy()`` method to create an
207207
endpoint which can be used to perform prediction against your trained SparkML Model.

Diff for: src/sagemaker/image_uri_config/sparkml-serving.json

+30-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,34 @@
3030
},
3131
"repository": "sagemaker-sparkml-serving"
3232
}
33-
}
33+
},
34+
"2.4": {
35+
"registries": {
36+
"af-south-1": "510948584623",
37+
"ap-east-1": "651117190479",
38+
"ap-northeast-1": "354813040037",
39+
"ap-northeast-2": "366743142698",
40+
"ap-south-1": "720646828776",
41+
"ap-southeast-1": "121021644041",
42+
"ap-southeast-2": "783357654285",
43+
"ca-central-1": "341280168497",
44+
"cn-north-1": "450853457545",
45+
"cn-northwest-1": "451049120500",
46+
"eu-central-1": "492215442770",
47+
"eu-north-1": "662702820516",
48+
"eu-west-1": "141502667606",
49+
"eu-west-2": "764974769150",
50+
"eu-west-3": "659782779980",
51+
"eu-south-1": "978288397137",
52+
"me-south-1": "801668240914",
53+
"sa-east-1": "737474898029",
54+
"us-east-1": "683313688378",
55+
"us-east-2": "257758044811",
56+
"us-gov-west-1": "414596584902",
57+
"us-iso-east-1": "833128469047",
58+
"us-west-1": "746614075791",
59+
"us-west-2": "246618743249"
60+
},
61+
"repository": "sagemaker-sparkml-serving"
62+
}
3463
}

Diff for: src/sagemaker/sparkml/model.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SparkMLModel(Model):
5959
model .
6060
"""
6161

62-
def __init__(self, model_data, role=None, spark_version=2.2, sagemaker_session=None, **kwargs):
62+
def __init__(self, model_data, role=None, spark_version=2.4, sagemaker_session=None, **kwargs):
6363
"""Initialize a SparkMLModel.
6464
6565
Args:
@@ -73,7 +73,7 @@ def __init__(self, model_data, role=None, spark_version=2.2, sagemaker_session=N
7373
artifacts. After the endpoint is created, the inference code
7474
might use the IAM role, if it needs to access an AWS resource.
7575
spark_version (str): Spark version you want to use for executing the
76-
inference (default: '2.2').
76+
inference (default: '2.4').
7777
sagemaker_session (sagemaker.session.Session): Session object which
7878
manages interactions with Amazon SageMaker APIs and any other
7979
AWS services needed. If not specified, the estimator creates one

Diff for: tests/integ/test_sparkml_serving.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,18 @@
1717

1818
import pytest
1919

20+
from botocore.errorfactory import ClientError
21+
2022
from sagemaker.sparkml.model import SparkMLModel
2123
from sagemaker.utils import sagemaker_timestamp
2224
from tests.integ import DATA_DIR
2325
from tests.integ.timeout import timeout_and_delete_endpoint_by_name
2426

2527

2628
@pytest.mark.canary_quick
27-
@pytest.mark.skip(
28-
reason="This test has always failed, but the failure was masked by a bug. "
29-
"This test should be fixed. Details in https://github.com/aws/sagemaker-python-sdk/pull/968"
30-
)
3129
def test_sparkml_model_deploy(sagemaker_session, cpu_instance_type):
32-
# Uploads an MLeap serialized MLeap model to S3 and use that to deploy a SparkML model to perform inference
30+
# Uploads an MLeap serialized MLeap model to S3 and use that to deploy
31+
# a SparkML model to perform inference
3332
data_path = os.path.join(DATA_DIR, "sparkml_model")
3433
endpoint_name = "test-sparkml-deploy-{}".format(sagemaker_timestamp())
3534
model_data = sagemaker_session.upload_data(
@@ -59,7 +58,8 @@ def test_sparkml_model_deploy(sagemaker_session, cpu_instance_type):
5958
predictor = model.deploy(1, cpu_instance_type, endpoint_name=endpoint_name)
6059

6160
valid_data = "1.0,C,38.0,71.5,1.0,female"
62-
assert predictor.predict(valid_data) == "1.0,0.0,38.0,1.0,71.5,0.0,1.0"
61+
assert predictor.predict(valid_data) == b"1.0,0.0,38.0,1.0,71.5,0.0,1.0"
6362

6463
invalid_data = "1.0,28.0,C,38.0,71.5,1.0"
65-
assert predictor.predict(invalid_data) is None
64+
with pytest.raises(ClientError):
65+
predictor.predict(invalid_data)

Diff for: tests/unit/test_sparkml_serving.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def sagemaker_session():
4949

5050
def test_sparkml_model(sagemaker_session):
5151
sparkml = SparkMLModel(sagemaker_session=sagemaker_session, model_data=MODEL_DATA, role=ROLE)
52-
assert sparkml.image_uri == image_uris.retrieve("sparkml-serving", REGION, version="2.2")
52+
assert sparkml.image_uri == image_uris.retrieve("sparkml-serving", REGION, version="2.4")
5353

5454

5555
def test_predictor_type(sagemaker_session):

0 commit comments

Comments
 (0)