Allow using Airflow with Flask CLI#9030
Conversation
airflow/www/app.py
Outdated
There was a problem hiding this comment.
The actual WSGI application. This is not implemented in
:meth:`__call__` so that middlewares can be applied without
losing a reference to the app object. Instead of doing this::
app = MyMiddleware(app)
It's a better idea to do this instead::
app.wsgi_app = MyMiddleware(app.wsgi_app)
Then you still have the original application object around and
can continue to call methods on it.
airflow/www/app.py
Outdated
There was a problem hiding this comment.
This causes a side effect. We want the cache to be modified only by the cached_app method.
airflow/www/app.py
Outdated
There was a problem hiding this comment.
This middleware is now optional. We use addresses in the form of blocked which do not work properly with this middleware. This middleware expects the addresses to be in the form /blocked. However, if we don't use this middleware, it doesn't matter.
There was a problem hiding this comment.
We don't use it in tests - test_views. This is still needed in production for some users.
potiuk
left a comment
There was a problem hiding this comment.
I do not know FAB that well but it looks good and if we can use standard flask tools to interact with the app- that's fantastic. I'd love someone else to take a look at that, but for me itis LGTM
airflow/www/app.py
Outdated
airflow/www/app.py
Outdated
|
I still have to find one side effect because MySQL behaves differently than PostgresSQL. |
| from airflow.configuration import conf | ||
| from tests.test_utils.config import conf_vars | ||
|
|
||
| mock.patch('airflow.utils.cli.action_logging', lambda x: x).start() |
There was a problem hiding this comment.
This caused a side effect. I don't know why it affected this change. Probably some session is now saving properly.
|
|
||
| task2 = dag2.get_task(task_id='print_the_context') | ||
| defaut_date2 = timezone.make_aware(datetime(2016, 1, 9)) | ||
| dag2.clear() |
There was a problem hiding this comment.
We may have data from another run.
|
|
||
| # Check that prints, and log messages, are shown | ||
| self.assertEqual(expected.replace("\n", ""), actual_out.replace("\n", "")) | ||
| self.assertIn(expected.replace("\n", ""), actual_out.replace("\n", "")) |
There was a problem hiding this comment.
On the console, we have action_logger logs too.
|
@turbaszek I fixed the side effects. Can you look at it again? |
I wanna print all routes using FLASK CLI
This will facilitate the development of Airflow.
We also have other commands in CLI
Make sure to mark the boxes below before creating PR: [x]
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.