daily pastebin goal
34%
SHARE
TWEET

Code to use an AWS SageMaker Endpoint

gnomezgrave Jul 4th, 2018 (edited) 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2.  
  3. import boto3
  4. from botocore.exceptions import ClientError
  5.  
  6. endpoint_name = 'your_endpoint_name'
  7.  
  8. runtime = boto3.Session().client('runtime.sagemaker')
  9. try:
  10.     response = runtime.invoke_endpoint(EndpointName=endpoint_name,
  11.                                        ContentType='application/json',
  12.                                        Body="{request body goes here}")
  13.                                        
  14.     result = response['Body'].read()
  15.     print(json.loads(result))
  16.    
  17. except ClientError as e:
  18.     print(e)
  19.     print(e.response['Error']['Code'])
  20.     print(e.response['ResponseMetadata']['HTTPStatusCode'])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top