Last active
January 3, 2020 21:23
-
-
Save jeanmidevacc/9019970beabfacb1c182a77564ccf068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
# Name of the app that you defined during the deployment on sagemaker | |
app_name = "xxxxx" | |
# AWS region of the deployment of the app on sagemaker | |
region = "xxxxx" | |
# Function to collect data from the endpoint on sagemaker | |
def query_endpoint(input_json): | |
client = boto3.session.Session().client("sagemaker-runtime", region) | |
response = client.invoke_endpoint( | |
EndpointName=app_name, | |
Body=input_json, | |
ContentType='application/json; format=pandas-split', | |
) | |
preds = response['Body'].read().decode("ascii") | |
preds = json.loads(preds) | |
print("Received response: {}".format(preds)) | |
return preds | |
# Make a call to the endpoint | |
query_endpoint(input_json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment