Skip to content

Instantly share code, notes, and snippets.

@jeanmidevacc
Last active January 3, 2020 21:23
Show Gist options
  • Save jeanmidevacc/9019970beabfacb1c182a77564ccf068 to your computer and use it in GitHub Desktop.
Save jeanmidevacc/9019970beabfacb1c182a77564ccf068 to your computer and use it in GitHub Desktop.
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