heroku / heroku-airflow

Demo of Author data workflows with Airflow on Heroku (not maintained)
Other
23 stars 6 forks source link

app crashes on startup: no such table: connection #1

Open bryan0 opened 8 years ago

bryan0 commented 8 years ago

when I restart the app with "heroku ps:restart", I get the error:

app/web.1: sqlalchemy.exc.OperationalError: (OperationalError) no such table: connection u'SELECT connection.conn_id AS connection_conn_id \nFROM connection GROUP BY connection.conn_id' ()

I can see that "airflow initdb" created the sqlite table in: /app/airflow/airflow.db, so not sure why it's failing.

neovintage commented 8 years ago

This means that the PYTHONPATH env variable didn't get setup correctly.

Can you do heroku run bash and then echo $PYTHONPATH to see what it was set as?

Alternatively, I created this repo that has a Heroku Button if you don't want to use docker => https://github.com/neovintage/heroku-airflow

bryan0 commented 8 years ago

~ $ echo $PYTHONPATH /app/user/airflow_login::/app/user

bryan0 commented 8 years ago

After playing with the heroku button version, I think the issue here was that AIRFLOW_HOME wasnt set so it's not point to the right airflow.cfg. This shouldn't be using sqlite which is the default, it should use postgres. It is also could be something with the DATABASE_URL var itself but I havent looked at it yet.

jetaggart commented 8 years ago

I fixed this by doing what @bryan0 suggested. After I had to run $ airflow initdb and the app boots fine now.

shanewjohnson commented 8 years ago

@jetaggart did you fix it by setting AIRFLOW_HOME. If so what and where did you set it. The original repo had it set in the app.json but not inside Heroku.

app.json

... "env": { "AIRFLOW_HOME": { "description": "Where all the information for airflow lives", "value": "/app/user" }, ....

shanewjohnson commented 8 years ago

@jetaggart @neovintage I added the AIRFLOW_HOME as an environment variable with value of '/app/user'. That pointed to the right configue and I was able to initdb and see postgres spin up. However the app is still crashing.

sqlalchemy.exc.InvalidRequestError: Multiple classes found for path "User" in the registry of this declarative base. Please use a fully module-qualified path.

Any recomendations? Thank you.

slepkin commented 8 years ago

Yeah, I'm seeing the same error. Here's the full backtrace:

Starting process with command `cd /app/user && airflow webserver -p 25107` 
  ____________       _____________ 
 ____    |__( )_________  __/__  /________      __ 
____  /| |_  /__  ___/_  /_ __  /_  __ \_ | /| / / 
___  ___ |  / _  /   _  __/ _  / / /_/ /_ |/ |/ / 
 _/_/  |_/_/  /_/    /_/    /_/  \____/____/|__/ 
2016-04-29 18:59:09,797 - root - INFO - Filling up the DagBag from /app/user/dags 
Traceback (most recent call last): 
  File "/app/.heroku/python/bin/airflow", line 6, in <module> 
    exec(compile(open(__file__).read(), __file__, 'exec')) 
  File "/app/user/src/airflow/airflow/bin/airflow", line 10, in <module> 
    args.func(args) 
  File "/app/user/src/airflow/airflow/bin/cli.py", line 252, in webserver 
    from airflow.www.app import app 
  File "/app/user/src/airflow/airflow/www/app.py", line 1646, in <module> 
    mv = JobModelView(jobs.BaseJob, Session, name="Jobs", category="Browse") 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 291, in __init__ 
    menu_icon_value=menu_icon_value) 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/model/base.py", line 587, in __init__ 
    self._refresh_cache() 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/model/base.py", line 663, in _refresh_cache 
    self._list_columns = self.get_list_columns() 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/model/base.py", line 743, in get_list_columns 
    columns = self.scaffold_list_columns() 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 435, in scaffold_list_columns 
    for p in self._get_model_iterator(): 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 313, in _get_model_iterator 
    return model._sa_class_manager.mapper.iterate_properties 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 1805, in iterate_properties 
    configure_mappers() 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 2631, in configure_mappers 
    mapper._post_configure_properties() 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 1696, in _post_configure_properties 
    prop.init() 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/interfaces.py", line 144, in init 
    self.do_init() 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py", line 1550, in do_init 
    self._process_dependent_arguments() 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py", line 1606, in _process_dependent_arguments 
    self.target = self.mapper.mapped_table 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 725, in __get__ 
    obj.__dict__[self.__name__] = result = self.fget(obj) 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/orm/relationships.py", line 1523, in mapper 
    argument = self.argument() 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/ext/declarative/clsregistry.py", line 271, in __call__ 
    x = eval(self.arg, globals(), self._dict) 
  File "<string>", line 1, in <module> 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/util/_collections.py", line 680, in __missing__ 
    self[key] = val = self.creator(key) 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/ext/declarative/clsregistry.py", line 252, in _access_cls 
    return _determine_container(key, cls._decl_class_registry[key]) 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/ext/declarative/clsregistry.py", line 236, in _determine_container 
    value = value.attempt_get([], key) 
  File "/app/.heroku/python/lib/python2.7/site-packages/sqlalchemy/ext/declarative/clsregistry.py", line 89, in attempt_get 
    (".".join(path + [key])) 
sqlalchemy.exc.InvalidRequestError: Multiple classes found for path "User" in the registry of this declarative base. Please use a fully module-qualified path. 
Process exited with status 1