-
Notifications
You must be signed in to change notification settings - Fork 16.4k
[AIRFLOW-6005] Common classes should always be imported from airflow, Depends on [AIRFLOW-6128] #6597
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
[AIRFLOW-6005] Common classes should always be imported from airflow, Depends on [AIRFLOW-6128] #6597
Conversation
3a43e29 to
f61f006
Compare
|
I think I nicely solved the problem of old imports. I figured out a nice way how to throw a deprecation warning in case someone import "from airflow impot AirflowException". It will still work, but during tests/execution it will log a deprecation warning and also you will see this deprecation warning in IDE: This is a I think a very straightforward way to avoid potential cyclic imports like the ones described in #6596 and opens up the possibility of removing the class from 'airflow' package in the future. I have one problem though @mik-laj maybe you can help solving it. I added a new "deprecations" package where i will put all the "deprecated" classes. I had to remove it in I tried to add |
f61f006 to
0fa20ac
Compare
|
I think I found a nice (though a but hackish :) ) way of making the docs build @mik-laj and others. See the change :). |
|
Oh, I think I see the issue with both of my comments: Because
And as for the "two candidates for AirflowException class in autoapi generation": putting |
4ae7bce to
70fd500
Compare
|
@ashb - I looked at the options and now I implemented quickly version that does not do deprecation, but pre-commits. It requires:
I think that might make perfect sense rather than deprecating. It's even more "constraining" for core developers. The check is pretty much self-explanatory: |
9458142 to
971e0e3
Compare
1ed8492 to
43c5310
Compare
3ffb65c to
f14d7ab
Compare
Codecov Report
@@ Coverage Diff @@
## master #6597 +/- ##
=========================================
Coverage ? 83.79%
=========================================
Files ? 669
Lines ? 37668
Branches ? 0
=========================================
Hits ? 31565
Misses ? 6103
Partials ? 0
Continue to review full report at Codecov.
|
f14d7ab to
8185939
Compare
While adding type annotations, it was apparent that the code for plugin manager and webserver initialisation was rather convoluted and complex. This change fixes it as follow up after untangling cyclic dependnencies. As a side effect - it turned out that the test plugin view in airflow RBAC implementation was not working since 1.10.1 - it threw "render is not an attribute" error - this has been fixed in this commit as well. The Plugins/TestView now works as expected. See https://stackoverflow.com/questions/53701030/airflow-plugins-rbac-enabled-blueprint-not-working?answertab=active#tab-top
For the sake of consistency, all the common components exposed directly in 'airflow' __init__.py should be imported from there rather than from sub-packages. This is important also for back-porting purposes (AIP-21) to make sure that we are using stable imports. This change does it and implements pre-commit that prevents importing those common imports differently.
8185939 to
3d1182a
Compare
|
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. |
| - id: common-imports | ||
| language: pygrep | ||
| name: Make sure AirflowConfigException is imported consistently 'from airflow' | ||
| entry: "from airflow\\.exception import.* AirflowConfigException" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| entry: "from airflow\\.exception import.* AirflowConfigException" | |
| entry: "from airflow\\.exceptions import.* AirflowConfigException" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will come back to it some day :).
|
Since we are going to get rid of the airflow.init.py most likely - this one can be closed. |

NOTE FOR REVIEWER: This change depends on #6596 #6702 #6696 so please review only the last commit.
For the sake of consistency, all the common components exposed directly
in 'airflow' init.py should be imported from there rather than
from sub-packages. This is important also for back-porting
purposes (AIP-21) to make sure that we are using stable imports.
This change does it and implements pre-commit that prevents importing
those common imports differently.
Make sure you have checked all steps below.
Jira
Description
Tests
Commits
Documentation