Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.2k forks source link

Use zappa with tensorflow #2069

Open ghost opened 4 years ago

ghost commented 4 years ago

Context

Cannot use tensorflow with zappa

Actual Behavior

On running zappa deploy the following error message shows: Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code. When I hit the endpoint the following message shows:

An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.
[Traceback (most recent call last):                                                                                                                                                                                                                                                                                                                                       
    File \"/var/task/handler.py\", line 540, in handler
    with Response.from_app(self.wsgi_app, environ) as response:
    File \"/var/task/werkzeug/wrappers/base_response.py\", line 287, in from_app
    return cls(*_run_wsgi_app(app, environ, buffered))
    File \"/var/task/werkzeug/wrappers/base_response.py\", line 26, in _run_wsgi_app
    return _run_wsgi_app(*args)
    File \"/var/task/werkzeug/test.py\", line 1119, in run_wsgi_app
    app_rv = app(environ, start_response)
    TypeError: 'NoneType' object is not callable
]}  

Steps to Reproduce

mkdir .venv
python3 -m virtualenv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install flask 
pip install zappa
pip install tensorflow-cpu==2.1.0
pip freeze > requirements.txt
cat zappa_settings.json
{
    "dev": {
        "s3_bucket": <HIDDEN>,
        "debug": true,
        "app_function": "app.app",
        "exclude": ["*.gz", "*.rar"],
        "memory_size": 1536,
        "timeout_seconds": 300,
        "debug": true,
        "slim_handler": true,
        "use_precompiled_packages": false
    }
}

cat app.py
from flask import Flask
import logging

logging.getLogger().setLevel(logging.INFO)

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def hello_world(event=None, context=None):
    logging.info('Hello world called')
    return 'Hello, World!'

if __name__ == '__main__':
    app.run(threaded=True)

zappa deploy dev

Your Environment

Operating System: Kubuntu 18.04, Python 3.7.5 Zappa version:0.51.0

ghost commented 4 years ago

Just tested this also on Amazon Linux instance and it didn't work.

jneves commented 4 years ago

Is the app.py file in the same directory as zappa_settings?What errors do you have on cloudwatch? 

ghost commented 4 years ago

Both are in the same directory. The cloudwatch log only shows the error: TypeError: 'NoneType' object is not callable

Michael-Bar commented 3 years ago

Also seeing the same issue now