I have been stuck here for too long. I am trying to deploy a python microservice that uses tensorflow. There is a single file by the name of handler.py which has the simple code below:
import json
import tensorflow as tf
import numpy as np
def main(event, context):
# a = np.arange(15).reshape(3, 5)
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response
# Use this code if you don't use the http event with the LAMBDA-PROXY
# integration
"""
return {
"message": "Go Serverless v1.0! Your function executed successfully!",
"event": event
}
"""
I also tried to upload without installing the above modules thinking that lambda will itself initialize from requirements.txt but then get an error that Unable to import module ‘handler’: No module named ‘tensorflow’. What should I do? I have spent lots of time in this and still not convinced that AWS Lambda would not allow me to do this.
Related question: https://stackoverflow.com/questions/50523674/deploying-a-microservice-with-tensorflow-at-aws-lambda