Fokko commented on a change in pull request #4408: [AIRFLOW-3589] Visualize
reschedule state in all views
URL: https://github.com/apache/airflow/pull/4408#discussion_r245907685
##########
File path: airflow/jobs.py
##########
@@ -947,7 +947,8 @@ def _process_task_instances(self, dag, queue,
session=None):
self.log.debug("Examining active DAG run: %s", run)
# this needs a fresh session sometimes tis get detached
tis = run.get_task_instances(state=(State.NONE,
Review comment:
Lately I've being giving preference to `{}` instead of `[]`. Especially the
set operations are faster when it comes to the `in`:
```
MacBook-Pro-van-Fokko:~ fokkodriesprong$ ipython
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from airflow.utils.state import State
In [2]: task_states_list = [
...: State.SUCCESS,
...: State.RUNNING,
...: State.FAILED,
...: State.UPSTREAM_FAILED,
...: State.SKIPPED,
...: State.UP_FOR_RETRY,
...: State.QUEUED,
...: State.NONE,
...: State.SCHEDULED,
...: ]
In [3]: task_states_set = {
...: State.SUCCESS,
...: State.RUNNING,
...: State.FAILED,
...: State.UPSTREAM_FAILED,
...: State.SKIPPED,
...: State.UP_FOR_RETRY,
...: State.QUEUED,
...: State.NONE,
...: State.SCHEDULED,
...: }
In [4]: %timeit State.NONE in task_states_set
...:
59.1 ns ± 2.07 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
In [5]: %timeit State.NONE in task_states_list
176 ns ± 0.704 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services