So I had Airflow’s webserver running fine until I created a Flask app within the same project root.
project/
|
-airflow_home/ # airflow dags, config, etc...
|
-app/
|
-__init__.py
-models.py
-config.py
-routes.py
|
-manage.py
here is the airflow-webserver error:
airflow[19435]: app = cached_app_rbac(None) if settings.RBAC else cached_app(None)
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/airflow/www/app.py", line 204, in cached_app
airflow[19435]: app = create_app(config, testing)
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/airflow/www/app.py", line 186, in create_app
airflow[19435]: return app
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/flask/ctx.py", line 249, in __exit__
airflow[19435]: self.pop(exc_value)
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/flask/ctx.py", line 241, in pop
airflow[19435]: assert rv is self, "Popped wrong app context. (%r instead of %r)" % (rv, self)
airflow[19435]: AssertionError: Popped wrong app context. (<flask.ctx.AppContext object at 0x7fa117448d10> instead of <flask.ctx.AppContext object at 0x7fa18678f0d0>)
app/init.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import app.config as config
db = SQLAlchemy()
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config_name)
db.init_app(app)
return app
manage.py
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
import app.config as config
from app import create_app, db
from app import models
app = create_app(config.Config)
app.app_context().push()
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
@manager.command
def run():
app.run()
if __name__ == '__main__':
manager.run()