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-4928] Move all config parses to class properties #5557
[AIRFLOW-4928] Move all config parses to class properties #5557
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5557 +/- ##
==========================================
- Coverage 80.05% 79.45% -0.61%
==========================================
Files 607 607
Lines 35040 35042 +2
==========================================
- Hits 28053 27841 -212
- Misses 6987 7201 +214
Continue to review full report at Codecov.
|
Did you notice a performance improvment from doing this, or is it just "this way is better"? |
@ashb I don't have a benchmark. The default arguments are evaluated in parsing, but still we don't need to evaluate multiple times. Also, two changes are in functions' bodies which is executed multiple times. (One is in a loop for every task). Configuration doesn't store the values (in that case it would be "same" cost to retrieve it from there), but instead it is only storing the plaintext and it's evaluating and "parsing" each variable on each call - I'm not 100% sure but that's what I got from skimming through the code. |
airflow/models/dagbag.py
Outdated
@@ -194,7 +200,7 @@ def process_file(self, filepath, only_if_updated=True, safe_mode=True): | |||
if mod_name in sys.modules: | |||
del sys.modules[mod_name] | |||
|
|||
with timeout(configuration.conf.getint('core', "DAGBAG_IMPORT_TIMEOUT")): | |||
with timeout(self.dagbag_import_timeout): |
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.
Let's make these class-level vars be constants - self.DAGBAG_IMPORT_TIMEOUT
etc.
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.
good point
@ashb Fixed your comments and rebased. Please take another look. |
Just made a few cosmetic changes. Will merge once it's green. (Feel free to ping me if I forget again!) |
@ashb It's good to go |
Make sure you have checked all steps below.
Jira
Description
Every
airflow.configuration.conf
method is being called multiple times. We can avoid redundant evaluation by storing the parsed value in the class namespace.Tests
Is already covered. No new features are implemented.
Commits
Documentation
Code Quality
flake8