dash: not compatible with zappa for serverless deployments

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:

(venv) rich@vbox:~/repos/explore_dash$ zappa deploy test                                                                                             
Calling deploy for stage test..
Creating zappa-permissions policy on ZappaLambdaExecution IAM Role.
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/home/rich/.pyenv/versions/3.6.1/lib/python3.6/distutils/dir_util.py", line 70, in mkpath
    os.mkdir(head, mode)
FileExistsError: [Errno 17] File exists: '/tmp/user/1000/1498073842/dash'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rich/repos/explore_dash/venv/lib/python3.6/site-packages/zappa/cli.py", line 2351, in handle
    sys.exit(cli.handle())
  File "/home/rich/repos/explore_dash/venv/lib/python3.6/site-packages/zappa/cli.py", line 456, in handle
    self.dispatch_command(self.command, stage)
  File "/home/rich/repos/explore_dash/venv/lib/python3.6/site-packages/zappa/cli.py", line 490, in dispatch_command
    self.deploy()
  File "/home/rich/repos/explore_dash/venv/lib/python3.6/site-packages/zappa/cli.py", line 650, in deploy
    self.create_package()
  File "/home/rich/repos/explore_dash/venv/lib/python3.6/site-packages/zappa/cli.py", line 1943, in create_package
    output=output
  File "/home/rich/repos/explore_dash/venv/lib/python3.6/site-packages/zappa/core.py", line 488, in create_lambda_zip
    copy_tree(temp_package_path, temp_project_path, update=True)
  File "/home/rich/.pyenv/versions/3.6.1/lib/python3.6/distutils/dir_util.py", line 159, in copy_tree
    verbose=verbose, dry_run=dry_run))
  File "/home/rich/.pyenv/versions/3.6.1/lib/python3.6/distutils/dir_util.py", line 135, in copy_tree
    mkpath(dst, verbose=verbose)
  File "/home/rich/.pyenv/versions/3.6.1/lib/python3.6/distutils/dir_util.py", line 74, in mkpath
    "could not create '%s': %s" % (head, exc.args[-1]))
distutils.errors.DistutilsFileError: could not create '/tmp/user/1000/1498073842/dash': File exists

==============

I removed the dash and dcc 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:

[1498077793326] /var/task/plotly/tools.py:103: UserWarning:
[1498077793326] Looks like you don't have 'read-write' permission to your 'home' ('~') directory or to our '~/.plotly' directory. That means plotly's python api can't setup local configuration files. No problem though! You'll just have to sign-in using 'plotly.plotly.sign_in()'. For help with that: 'help(plotly.plotly.sign_in)'.
'Dash' object is not callable

If the dash and dcc 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!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 20 (5 by maintainers)

Commits related to this issue

Most upvoted comments

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

Dope work guys!

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:

app.config['requests_pathname_prefix'] = '/dev'+app.config['requests_pathname_prefix']