New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not compatible with zappa for serverless deployments #22
Comments
If you're running Plotly online it means that you haven't setup your API keys, you'll need to do so here: https://plot.ly/settings/api However the default example should be offline by default, so I'm not sure what you did there. Try deploying the app with your credentials setup, otherwise it may be a secret key issue @chriddyp |
Hi @richiverse, thanks for the ping, I was just thinking about trying this! |
I'm on Python 3.6 in this environment.
I'm taking a look at dash.Dash() in the source now to see if I need to set something up there |
This is just a warning, it's not an error. You can ignore this for now. |
https://github.com/plotly/plotly.py/blob/master/plotly/plotly/plotly.py#L50 It looks like when plotly initializes it checks local file permissions which will fail in AWS Lambda https://github.com/plotly/plotly.py/blob/master/plotly/tools.py#L77 |
We would need any conf/install in our |
That would get rid of the warning is all I think. There still is some underlying issue of the Dash object not being callable. |
I believe the Dash object not being callable is simply its lack of a call method. I added the following to the Dash class and it loads in lambda now. It just says "Loading...." however so this might not be the right fix. def __call__(self, *args, **kwargs):
return self.server.__call__(*args, **kwargs) |
Does the new version of Dash use socket.io? I remember reading somewhere that socket.io wouldn't work with serverless. edit: Nevermind, it appears to be restful now. |
After adding the call method to dash I was able to get it on Lambda. I now see two other things.
I will leave the https://dash.struce.com up for a while so others can see its console output and network calls. The unminified version of react-dom are being used there for easier troubleshooting. |
Dope work guys! |
For now, you can set
Try setting the server's secret key with something like |
Hey good call on the secret key! Got Dash working on Lambda now! Zappa attempts to return a callable Flask object. Would adding the call method (as described above) to the Dash class be something you would merge? @Miserlou may have a better suggestion for a way to handle this on the zappa middleware side, but I'm not seeing it. |
Hm, weird. Why is it calling the Dash object? Can you just do something like:
and have it call the |
So simple. Works like a dream, thanks. The only thing now that I can't seem to get working is the /dev/ part, but it is fine using a subdomain. |
@mcrowson - did you try the |
I did, no dice. |
@mcrowson: apologies for the probably basic question but could this be used to run multiple dash(boards) as subdomains? I.e. if I have a few projects for which I want 1+ dash(boards), could they be deployed such that they are available using |
Yes. Those would each be a separate stage on your zappa deployment. I threw up the POC here: https://github.com/mcrowson/zappa_dash If you want to get more details check out the Zappa docs: https://github.com/Miserlou/Zappa |
I found a little workaround that might help anyone that doesn't want to use subdomains. This line of code lets you add your prefix into JUST the async requests made from js which solves the problem as long as you aren't using the option to serve locally:
|
match response order with request order
cc: @Miserlou
So I ran the app locally for the first tutorial example here:
https://plot.ly/dash/getting-started
I tried deploying via zappa and got the following error:
I removed the
dash
anddcc
local files and it deployed fine. However, when I go to the AWS URL, I get the following error:"{'message': 'An uncaught exception happened while servicing this request. You can investigate this with the `zappa tail` command.', 'traceback': ['Traceback (most recent call last):\\n', ' File \"/var/task/handler.py\", line 433, in handler\\n response = Response.from_app(self.wsgi_app, environ)\\n', ' File \"/var/task/werkzeug/wrappers.py\", line 903, in from_app\\n return cls(*_run_wsgi_app(app, environ, buffered))\\n', ' File \"/var/task/werkzeug/test.py\", line 884, in run_wsgi_app\\n app_rv = app(environ, start_response)\\n', ' File \"/var/task/zappa/middleware.py\", line 66, in __call__\\n response = self.application(environ, encode_response)\\n', \"TypeError: 'Dash' object is not callable\\n\"]}"
I get the following when tailing the logs:
If the
dash
anddcc
files are necessary, is there a way I can rename them and reference them separately?Also is there a way I can run the first tutorial in offline mode?
thanks!
The text was updated successfully, but these errors were encountered: