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_r245907657
 
 

 ##########
 File path: airflow/jobs.py
 ##########
 @@ -2237,7 +2244,7 @@ def _process_backfill_task_instances(self,
                             session=session,
                             verbose=self.verbose):
                         ti.refresh_from_db(lock_for_update=True, 
session=session)
-                        if ti.state == State.SCHEDULED or ti.state == 
State.UP_FOR_RETRY:
+                        if ti.state in [State.SCHEDULED, State.UP_FOR_RETRY, 
State.UP_FOR_RESCHEDULE]:
 
 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

Reply via email to