AWS sagemaker documentation change
Summary
Added SageMaker Python SDK v3 examples for creating/deploying inference pipelines and making real-time predictions
Security assessment
Changes purely add new code samples for SDK v3 usage without addressing security vulnerabilities or adding security features documentation
Diff
diff --git a/sagemaker/latest/dg/inference-pipeline-real-time.md b/sagemaker/latest/dg/inference-pipeline-real-time.md index 4959fb704..d73136108 100644 --- a//sagemaker/latest/dg/inference-pipeline-real-time.md +++ b//sagemaker/latest/dg/inference-pipeline-real-time.md @@ -29,0 +30,26 @@ The following code creates and deploys a real-time inference pipeline model with +SageMaker Python SDK v3 + + + + from sagemaker.serve import ModelBuilder + + sparkml_data = 's3://{}/{}/{}'.format(s3_model_bucket, s3_model_key_prefix, 'model.tar.gz') + + model_name = 'serial-inference-' + timestamp_prefix + endpoint_name = 'serial-inference-ep-' + timestamp_prefix + + model_builder = ModelBuilder( + s3_model_data_url=sparkml_data, + role_arn=role, + instance_type='ml.c4.xlarge', + pipeline_models=[sparkml_data, xgb_model.s3_model_data_url], + ) + endpoint = model_builder.build().deploy( + initial_instance_count=1, + instance_type='ml.c4.xlarge', + endpoint_name=endpoint_name + ) + +SageMaker Python SDK v2 (Legacy) + + @@ -47,0 +74,55 @@ The following example shows how to make real-time predictions by calling an infe +SageMaker Python SDK v3 + + + + import json + from sagemaker.core.resources import Endpoint + + payload = { + "input": [ + { + "name": "Pclass", + "type": "float", + "val": "1.0" + }, + { + "name": "Embarked", + "type": "string", + "val": "Q" + }, + { + "name": "Age", + "type": "double", + "val": "48.0" + }, + { + "name": "Fare", + "type": "double", + "val": "100.67" + }, + { + "name": "SibSp", + "type": "double", + "val": "1.0" + }, + { + "name": "Sex", + "type": "string", + "val": "male" + } + ], + "output": { + "name": "features", + "type": "double", + "struct": "vector" + } + } + + endpoint = Endpoint(endpoint_name=endpoint_name) + + response = endpoint.invoke(body=json.dumps(payload), content_type='application/json', accept='application/json') + print(response) + +SageMaker Python SDK v2 (Legacy) + + @@ -97 +178 @@ The following example shows how to make real-time predictions by calling an infe -The response you get from `predictor.predict(payload)` is the model's inference result. +The response you get is the model's inference result.