[AIRFLOW-31] Use standard imports for hooks/operators - #1272
Conversation
|
|
|
|
|
|
|
|
|
|
|
|
|
Coverage decreased (-4.0%) to 63.165% when pulling 378f09aa80fea95f95f8bac073319c3ede372b02 on jlowin:standard-imports into f657c16 on airbnb:master. |
9eda57a to
f2049c1
Compare
7b8e62f to
1a32a83
Compare
In Python 3, errors don’t have a `message` attribute
Current coverage is 63.71%@@ master #1272 diff @@
==========================================
Files 116 117 +1
Lines 8330 8425 +95
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 5668 5368 -300
- Misses 2662 3057 +395
Partials 0 0
|
|
@criccomini at long last this appears to be ready for merge. The hardest part was that unit tests must use standard imports (I turn off the backwards-compatible import style via env var) and it was a real pain getting them all to comply. But it appears to be good to go. |
|
Awesome! I'm +1 then. :) Make sure to squash the commits, though. |
|
@jlowin hey @aoen and I think this is missing a dependency on zope. When I try to run even the most basic command (e.g. |
See #1238 for details.
This PR replaces Airflow's import machinery with standard Python imports. This has an impact in four places:
airflow.hooks.*airflow.operators.*airflow.contrib.hooks.*airflow.contrib.operators.*Operators that could formerly be accessed from these directories must now be accessed explicitly from submodules:
Old style imports will still work but will warn:
run_unit_tests.shexports an environment variableAIRFLOW_USE_NEW_IMPORTSwhich turns off the old-style (deprecated) imports completely. Therefore, unit tests must use the new style. I've tried to adjust the tests already but there are some I can't test locally so I will see what Travis has issues with and make adjustments.Plugins are handled similarly. Let's say the user creates a plugin
MyPluginwith some operators. Currently those operators are available atairflow.operators.*. Through this PR, that behavior is maintained (through Airflow 2.0) but a new module is dynamically created with the operators atairflow.operators.myplugin.*Lastly, I took advantage of the fact I was going into lots of files to add licenses to all hooks and operators.