Last active
June 8, 2020 14:33
-
-
Save findtharun/0d9d613a45b719cd9a8efd92baa7cc10 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 os | |
import io | |
import boto3 | |
import json | |
import csv | |
# grab environment variables | |
ENDPOINT_NAME = os.environ['ENDPOINT_NAME'] | |
runtime= boto3.client('runtime.sagemaker') | |
def lambda_handler(event, context): | |
print("Received event: " + json.dumps(event, indent=2)) | |
data = json.loads(json.dumps(event)) | |
payload = data['data'] | |
print(payload) | |
response = runtime.invoke_endpoint(EndpointName=ENDPOINT_NAME, | |
ContentType='text/csv',Body=payload) | |
result = json.loads(response['Body'].read().decode()) | |
if(result=="0"): | |
result="Setosa" | |
elif(result=="1"): | |
result="Versicolor" | |
else: | |
result="Virginica" | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment