Skip to content
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

gunicorn cant find create_app() #8795

Closed
3 tasks
blcksrx opened this issue Dec 9, 2019 · 33 comments
Closed
3 tasks

gunicorn cant find create_app() #8795

blcksrx opened this issue Dec 9, 2019 · 33 comments
Labels
#bug:cant-reproduce Bugs that cannot be reproduced !deprecated-label:bug Deprecated label - Use #bug instead inactive Inactive for >= 30 days

Comments

@blcksrx
Copy link
Contributor

blcksrx commented Dec 9, 2019

gunicorn cant find create_app()

 gunicorn -b 0.0.0.0:6666 "superset.app:create_app()"
[2019-12-09 19:14:22 +0330] [23027] [INFO] Starting gunicorn 19.9.0
[2019-12-09 19:14:22 +0330] [23027] [INFO] Listening at: http://0.0.0.0:6666 (23027)
[2019-12-09 19:14:22 +0330] [23027] [INFO] Using worker: sync
[2019-12-09 19:14:22 +0330] [23031] [INFO] Booting worker with pid: 23031
Loaded your LOCAL configuration at [/home/superset/superset_config.py]
2019-12-09 19:14:24,395:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 362, in import_app
    app = eval(obj, vars(mod))
  File "<string>", line 1, in <module>
NameError: name 'create_app' is not defined
Failed to find application object 'create_app()' in 'superset.app'
[2019-12-09 19:14:25 +0330] [23031] [INFO] Worker exiting (pid: 23031)
[2019-12-09 19:14:26 +0330] [23027] [INFO] Shutting down: Master
[2019-12-09 19:14:26 +0330] [23027] [INFO] Reason: App failed to load.

Expected results

what you expected to happen.

Actual results

what actually happens.

Screenshots

If applicable, add screenshots to help explain your problem.

How to reproduce the bug

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Environment

(please complete the following information):

  • superset version: superset version
  • python version: python --version
  • node.js version: node -v
  • npm version: npm -v

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Add any other context about the problem here.

@issue-label-bot issue-label-bot bot added the !deprecated-label:bug Deprecated label - Use #bug instead label Dec 9, 2019
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.88. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@dpgaspar
Copy link
Member

dpgaspar commented Dec 9, 2019

Hi @blcksrx, can you please add the superset version your using?

@blcksrx
Copy link
Contributor Author

blcksrx commented Dec 9, 2019

Hi @blcksrx, can you please add the superset version your using?

Master branch, I cloned it about an hour ago

@craig-rueda
Copy link
Member

@blcksrx - Take a look here: https://github.com/apache/incubator-superset/blob/master/CONTRIBUTING.md#sql-lab-async

Celery needs a pointer to the actual "celery instance": celery worker --app=superset.tasks.celery_app:app -Ofair

@blcksrx
Copy link
Contributor Author

blcksrx commented Dec 9, 2019

@blcksrx - Take a look here: https://github.com/apache/incubator-superset/blob/master/CONTRIBUTING.md#sql-lab-async

Celery needs a pointer to the actual "celery instance": celery worker --app=superset.tasks.celery_app:app -Ofair

Its not about celery worker or celery beat. Its about running webserver with gunicorn

@craig-rueda
Copy link
Member

Oops, didn't see that. I would second @dpgaspar's concern about not being up to date. After pulling latest, did you re-pip? It's possible that you're still pointing at something old in your site-packages...

@blcksrx
Copy link
Contributor Author

blcksrx commented Dec 9, 2019

Ofcourse yes. I did it

@dpgaspar
Copy link
Member

Sorry it's not clear to me, is it solved?

@blcksrx
Copy link
Contributor Author

blcksrx commented Dec 10, 2019

No, its not solved yet

@dpgaspar
Copy link
Member

I'm not able to replicate the problem, can you please create a clean/new virtualenv and reinstall superset and dependencies, then test and report back. If the problem persists, give us all commands you went through and output

@dpgaspar dpgaspar added the #bug:cant-reproduce Bugs that cannot be reproduced label Dec 12, 2019
@miquel-simo
Copy link

Same error happened to me. Versions:
Superset 0.35.1
Python 3.6.8
Flask 1.1.1
Werkzeug 0.16.0

followed setup instructions from official apache-superset "installation how-to" except that I did not created a virtualenv. All other steps done as how-to stated.

@facePlanted
Copy link

same here, ubuntu 18.04.3
followed the installation instructions and also created virtualenv:

NameError: name 'create_app' is not defined
Failed to find application object 'create_app()' in 'superset.app'
[2019-12-14 23:22:23 +0100] [3352] [INFO] Worker exiting (pid: 3352)
Traceback (most recent call last):
File "/root/venv/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app
app = eval(obj, vars(mod))
File "", line 1, in
NameError: name 'create_app' is not defined
Failed to find application object 'create_app()' in 'superset.app'
[2019-12-14 23:22:23 +0100] [3350] [INFO] Worker exiting (pid: 3350)
[2019-12-14 23:22:24 +0100] [3336] [INFO] Shutting down: Master
[2019-12-14 23:22:24 +0100] [3336] [INFO] Reason: App failed to load.

@craig-rueda
Copy link
Member

This is starting to make a bit of sense. The docs are for master, whereas 0.35 still does things the old way. Try 'superset.app' instead of 'superset.app:create_app()'.

After the next release, things should be consistent.

@facePlanted
Copy link

(venv) root@mike5:~# gunicorn -w 2 -k gevent --timeout 120 -b 0.0.0.0:6666 --limit-request-line 0 --limit-request-field_size 0 --statsd-host localhost:8125 'superset.app'
[2019-12-15 07:06:54 +0100] [17640] [INFO] Starting gunicorn 19.8.1
[2019-12-15 07:06:54 +0100] [17640] [INFO] Listening at: http://0.0.0.0:6666 (17640)
[2019-12-15 07:06:54 +0100] [17640] [INFO] Using worker: gevent
[2019-12-15 07:06:54 +0100] [17643] [INFO] Booting worker with pid: 17643
[2019-12-15 07:06:54 +0100] [17644] [INFO] Booting worker with pid: 17644
2019-12-15 07:06:55,908:INFO:root:logging was configured successfully
2019-12-15 07:06:55,961:INFO:root:logging was configured successfully
2019-12-15 07:06:56,029:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
2019-12-15 07:06:56,081:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
Traceback (most recent call last):
File "/root/venv/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app
app = eval(obj, vars(mod))
File "", line 1, in
NameError: name 'application' is not defined
Failed to find application object 'application' in 'superset.app'
[2019-12-15 07:06:57 +0100] [17644] [INFO] Worker exiting (pid: 17644)
Traceback (most recent call last):
File "/root/venv/lib/python3.6/site-packages/gunicorn/util.py", line 362, in import_app
app = eval(obj, vars(mod))
File "", line 1, in
NameError: name 'application' is not defined
Failed to find application object 'application' in 'superset.app'
[2019-12-15 07:06:57 +0100] [17643] [INFO] Worker exiting (pid: 17643)
[2019-12-15 07:06:57 +0100] [17640] [INFO] Shutting down: Master
[2019-12-15 07:06:57 +0100] [17640] [INFO] Reason: App failed to load.

@edge7
Copy link

edge7 commented Dec 15, 2019

try with: superset:app

@miquel-simo
Copy link

Confirmed. Works with superset.app

gunicorn -w 10 -k gevent --timeout 120 -b 0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 --statsd-host localhost:8125 superset:app

@facePlanted
Copy link

Yes superset:app instead of superset.app fixed the issue, thank you

@edge7
Copy link

edge7 commented Dec 16, 2019

If you look at the source code (0.35.1, you can see that the Flask App is defined in the superset module (in particular in init file---> superset:app
In master it is defined in superset/app.py with a function named create_app

Agree that documentation should be improved

@metaperl
Copy link

Agree that documentation should be improved

It's not that it should be improved. It just needs to be understood that the docs represent the master branch and not the pypi release.

@metaperl
Copy link

The docs are for master, whereas 0.35 still does things the old way.

The online docs have an install section that suggest that one can install and upgrade apache via pip:
https://superset.incubator.apache.org/installation.html#upgrading

but the documentation suggesting this is generated from the git master not the pip release.

The building from source section of the docs is misleading. it says:

More advanced users may want to build Superset from sources.

This is incorrect: any user that wants Superset to behave the way to docs advertise would do this.

@facePlanted
Copy link

Hey since I'm a fresh new superset user, I'll provide my feedback as a noob which installs superset for the first time:

following the documentation here: https://superset.incubator.apache.org/installation.html
or here: https://superset.apache.org/installation.html
(i think they are the same)

my first attempt was on debian 9, using the "pip procedure",
and that failed because of python being 3.5 instead of 3.6

then i've tried the "docker procedure", still on debian 9,
and this failed because of some problem between docker-compose and python

(debian 9 is old and this didn't surprise me)

so i've created an ubuntu 18.04.3 vps and here the "pip procedure" went smooth
except for the final gunicorn part
(but the "superset run" web server worked fine, even if I was aware of: "Note that the development web server (superset run or flask run) is not intended for production use.")

I'll admit that I was suprised by the problem with gunicorn, since I was expecting the "pip procedure" to be the stable (battle-tested) one.

Also I got confused about the "docker procedure", which reads as follows: "It is currently not recommended to run docker-compose in production."
and it's not clear to me if it's the whole docker superset that is unstable
or just the docker superset WITH docker-compose.

Finally and most important: I'm still a little confused about which is the "stable" (for production use) procedure I must follow to install superset :)

@edge7
Copy link

edge7 commented Dec 16, 2019

Finally and most important: I'm still a little confused about which is the "stable" (for production use) procedure I must follow to install superset :)

Installing it on a virtualenv works fine and stable for me, please see this.
Am using Python 3.6.8, gunicorn (19.9.0), apache-superset (0.35.1)
Gunicorn works fine for me, even with HTTPS:
gunicorn -w 10 -k gevent --timeout 120 -b 0.0.0.0:8888 --ca-certs=/etc/letsencrypt/archive/www.xxx.social/chain4.pem --keyfile=/etc/letsencrypt/archive/www.xxx.social/privkey4.pem --certfile=/etc/letsencrypt/archive/www.xxx.social/cert4.pem --limit-request-line 0 --limit-request-field_size 0 superset:app&

@metaperl
Copy link

I'll admit that I was suprised by the problem with gunicorn, since I was expecting the "pip procedure" to be the stable (battle-tested) one

the docs are (currently) for the git master branch not the pypi release. The way to invoke superset via Unicorn changed:

"superset.app:create_app()" is for the git master branch
"superset:app" is for the 0.35.1 and earlier releases.

Finally and most important: I'm still a little confused about which is the "stable" (for production use) procedure I must follow to install superset :)

This is discussed here:
https://lists.apache.org/thread.html/9c76f2da91dbf30035b1a7b5a496ca5bc93205482a64d1f96a2db642%40%3Cdev.superset.apache.org%3E

@farhatabbas
Copy link

Thanks @miquel-simo this works like a charm
gunicorn -w 10 -k gevent --timeout 120 -b 0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 --statsd-host localhost:8125 superset:app

@john-sandall
Copy link

For those wishing to read the documentation associated with the current PyPI release (0.35.1), you can build them locally as follows:

pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints apache-superset
git clone https://github.com/apache/incubator-superset.git
git checkout 62c2e15a0adf76571ba14401c60d6f8a3216aa0a
cd incubator-superset/docs/
make html

Then load up path/to/incubator-superset/docs/_build/html/installation.html in your browser.

@metaperl
Copy link

For those wishing to read the documentation associated with the current PyPI release (0.35.1),

I would imagine the doc site should have a pulldown where you browse the docs for various releases instead of having to do this.

@mistercrunch
Copy link
Member

We have versioned docs here https://readthedocs.org/projects/apache-superset/

@blcksrx
Copy link
Contributor Author

blcksrx commented Jan 19, 2020

Nice job

@dataf3l
Copy link

dataf3l commented Feb 1, 2020

@john-sandall perhaps publishing the documentation on the website, instead of making people build the documentation?

@mistercrunch
Copy link
Member

Also I made the versioned docs discoverable in the docs here: #9069

@soumendra
Copy link

Agree that documentation should be improved

It's not that it should be improved. It just needs to be understood that the docs represent the master branch and not the pypi release.

This is not true. The documentation does need improvement.

At https://superset.incubator.apache.org/installation.html right now, both superset.app:create_app() (sec: A proper WSGI HTTP Server) and superset:app (sec: Flask-AppBuilder Permissions) are mentioned in back-to-back sections.

@dataf3l
Copy link

dataf3l commented Mar 26, 2020

"It's not that it should be improved. "

the product is confusing, the docs don't match the code,
the docs should match the code
things should be easy.
things should not be hard.
don't make me think.
installation is way too difficult, it used to be just "pip install superset" back in the day...

@stale
Copy link

stale bot commented May 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#bug:cant-reproduce Bugs that cannot be reproduced !deprecated-label:bug Deprecated label - Use #bug instead inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests