[AIRFLOW-4292] Cleanup and improve SLA code#5517
[AIRFLOW-4292] Cleanup and improve SLA code#5517serkef wants to merge 5 commits intoapache:masterfrom
Conversation
* Replace unnecessary list allocators with generators * Remove redundant filter * Fix typos * Improve readability and comments
| We are assuming that the scheduler runs often, so we only check for | ||
| tasks that should have succeeded in the past hour. | ||
| """ | ||
| if not any([isinstance(ti.sla, timedelta) for ti in dag.tasks]): |
airflow/jobs/scheduler_job.py
Outdated
There was a problem hiding this comment.
Doing such refactor it would be a good idea to change this sq name to something more pylint compatible. Maybe then we will be able to remove it from TODO list?
There was a problem hiding this comment.
Thanks, didn't know about this one. Will change.
There was a problem hiding this comment.
hm seems that file has several issues. I would prefer to keep the scope of this ticket on the specific function.
| session.merge(sla) | ||
| session.commit() | ||
| if not slas: | ||
| return |
There was a problem hiding this comment.
Reversing the control statement for readability. Will comment below on the specific changes.
| if not slas: | ||
| return | ||
|
|
||
| sla_dates = {sla.execution_date for sla in slas} |
There was a problem hiding this comment.
Changing list to set
| session.commit() | ||
|
|
||
| task_list = "\n".join( | ||
| sla.task_id + ' on ' + sla.execution_date.isoformat() |
There was a problem hiding this comment.
Changing list to generator
| sla.task_id + ' on ' + sla.execution_date.isoformat() | ||
| for sla in slas) | ||
| blocking_task_list = "\n".join( | ||
| ti.task_id + ' on ' + ti.execution_date.isoformat() |
There was a problem hiding this comment.
Changing list to generator
|
Can one help me with the pylint errors? It complains for accessing unknown property. Issue is class has a method |
|
Neither. I have a change pending approval/merge to CONTRIBUTING.md on how to deal with pylint errors. You should disable the pylint error for that particular line: |
This reverts commit 80bd78f
Codecov Report
@@ Coverage Diff @@
## master #5517 +/- ##
==========================================
- Coverage 79.07% 78.74% -0.34%
==========================================
Files 489 489
Lines 30744 30727 -17
==========================================
- Hits 24312 24196 -116
- Misses 6432 6531 +99
Continue to review full report at Codecov.
|
|
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. |
|
Working on it... |
|
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. |
(This continues #5083 which got quite hard to rebase)
Make sure you have checked all steps below.
Jira
Description
This is code cleanup. Some small functional improvements, improve readability by adding comments and fixing typos
Tests
No new features. This is already covered.
Commits
Documentation
Code Quality
flake8