nodes: 0, module; 1, function_definition; 2, function_name:_partition_tasks; 3, parameters; 4, block; 5, identifier:worker; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, return_statement; 24, comment:"""
      Takes a worker and sorts out tasks based on their status.
      Still_pending_not_ext is only used to get upstream_failure, upstream_missing_dependency and run_by_other_worker
      """; 25, assignment; 26, assignment; 27, assignment; 28, assignment; 29, assignment; 30, assignment; 31, assignment; 32, assignment; 33, assignment; 34, assignment; 35, assignment; 36, assignment; 37, assignment; 38, assignment; 39, assignment; 40, assignment; 41, identifier:set_tasks; 42, identifier:task_history; 43, attribute; 44, identifier:pending_tasks; 45, set_comprehension; 46, identifier:set_tasks; 47, dictionary; 48, subscript; 49, set_comprehension; 50, subscript; 51, set_comprehension; 52, subscript; 53, set_comprehension; 54, subscript; 55, binary_operator:set_tasks["ever_failed"] - set_tasks["completed"]; 56, subscript; 57, set_comprehension; 58, subscript; 59, set_comprehension; 60, subscript; 61, set_comprehension; 62, subscript; 63, call; 64, subscript; 65, call; 66, subscript; 67, call; 68, subscript; 69, call; 70, subscript; 71, call; 72, subscript; 73, call; 74, identifier:worker; 75, identifier:_add_task_history; 76, identifier:task; 77, for_in_clause; 78, if_clause; 79, identifier:set_tasks; 80, string:"completed"; 81, identifier:task; 82, for_in_clause; 83, if_clause; 84, identifier:set_tasks; 85, string:"already_done"; 86, identifier:task; 87, for_in_clause; 88, if_clause; 89, identifier:set_tasks; 90, string:"ever_failed"; 91, identifier:task; 92, for_in_clause; 93, if_clause; 94, identifier:set_tasks; 95, string:"failed"; 96, subscript; 97, subscript; 98, identifier:set_tasks; 99, string:"scheduling_error"; 100, identifier:task; 101, for_in_clause; 102, if_clause; 103, identifier:set_tasks; 104, string:"still_pending_ext"; 105, identifier:task; 106, for_in_clause; 107, if_clause; 108, identifier:set_tasks; 109, string:"still_pending_not_ext"; 110, identifier:task; 111, for_in_clause; 112, if_clause; 113, identifier:set_tasks; 114, string:"run_by_other_worker"; 115, identifier:set; 116, argument_list; 117, identifier:set_tasks; 118, string:"upstream_failure"; 119, identifier:set; 120, argument_list; 121, identifier:set_tasks; 122, string:"upstream_missing_dependency"; 123, identifier:set; 124, argument_list; 125, identifier:set_tasks; 126, string:"upstream_run_by_other_worker"; 127, identifier:set; 128, argument_list; 129, identifier:set_tasks; 130, string:"upstream_scheduling_error"; 131, identifier:set; 132, argument_list; 133, identifier:set_tasks; 134, string:"not_run"; 135, identifier:set; 136, argument_list; 137, tuple_pattern; 138, identifier:task_history; 139, comparison_operator:status == 'PENDING'; 140, tuple_pattern; 141, identifier:task_history; 142, boolean_operator; 143, tuple_pattern; 144, identifier:task_history; 145, boolean_operator; 146, tuple_pattern; 147, identifier:task_history; 148, comparison_operator:status == 'FAILED'; 149, identifier:set_tasks; 150, string:"ever_failed"; 151, identifier:set_tasks; 152, string:"completed"; 153, tuple_pattern; 154, identifier:task_history; 155, comparison_operator:status == 'UNKNOWN'; 156, tuple_pattern; 157, identifier:task_history; 158, boolean_operator; 159, tuple_pattern; 160, identifier:task_history; 161, boolean_operator; 162, identifier:task; 163, identifier:status; 164, identifier:ext; 165, identifier:status; 166, string; 167, identifier:task; 168, identifier:status; 169, identifier:ext; 170, comparison_operator:status == 'DONE'; 171, comparison_operator:task in pending_tasks; 172, identifier:task; 173, identifier:status; 174, identifier:ext; 175, boolean_operator; 176, comparison_operator:task not in set_tasks["completed"]; 177, identifier:task; 178, identifier:status; 179, identifier:ext; 180, identifier:status; 181, string; 182, identifier:task; 183, identifier:status; 184, identifier:ext; 185, identifier:status; 186, string; 187, identifier:task; 188, identifier:status; 189, identifier:ext; 190, boolean_operator; 191, not_operator; 192, identifier:task; 193, identifier:status; 194, identifier:ext; 195, boolean_operator; 196, identifier:ext; 197, string_content:PENDING; 198, identifier:status; 199, string; 200, identifier:task; 201, identifier:pending_tasks; 202, comparison_operator:status == 'DONE'; 203, comparison_operator:task not in pending_tasks; 204, identifier:task; 205, subscript; 206, string_content:FAILED; 207, string_content:UNKNOWN; 208, boolean_operator; 209, comparison_operator:task not in set_tasks["completed"]; 210, identifier:ext; 211, boolean_operator; 212, comparison_operator:task not in set_tasks["completed"]; 213, string_content:DONE; 214, identifier:status; 215, string; 216, identifier:task; 217, identifier:pending_tasks; 218, identifier:set_tasks; 219, string:"completed"; 220, comparison_operator:status == 'PENDING'; 221, comparison_operator:task not in set_tasks["ever_failed"]; 222, identifier:task; 223, subscript; 224, comparison_operator:status == 'PENDING'; 225, comparison_operator:task not in set_tasks["ever_failed"]; 226, identifier:task; 227, subscript; 228, string_content:DONE; 229, identifier:status; 230, string; 231, identifier:task; 232, subscript; 233, identifier:set_tasks; 234, string:"completed"; 235, identifier:status; 236, string; 237, identifier:task; 238, subscript; 239, identifier:set_tasks; 240, string:"completed"; 241, string_content:PENDING; 242, identifier:set_tasks; 243, string:"ever_failed"; 244, string_content:PENDING; 245, identifier:set_tasks; 246, string:"ever_failed"
code: def _partition_tasks(worker):
      """
      Takes a worker and sorts out tasks based on their status.
      Still_pending_not_ext is only used to get upstream_failure, upstream_missing_dependency and run_by_other_worker
      """
      task_history = worker._add_task_history
      pending_tasks = {task for(task, status, ext) in task_history if status == 'PENDING'}
      set_tasks = {}
      set_tasks["completed"] = {task for (task, status, ext) in task_history if status == 'DONE' and task in pending_tasks}
      set_tasks["already_done"] = {task for (task, status, ext) in task_history
                                   if status == 'DONE' and task not in pending_tasks and task not in set_tasks["completed"]}
      set_tasks["ever_failed"] = {task for (task, status, ext) in task_history if status == 'FAILED'}
      set_tasks["failed"] = set_tasks["ever_failed"] - set_tasks["completed"]
      set_tasks["scheduling_error"] = {task for(task, status, ext) in task_history if status == 'UNKNOWN'}
      set_tasks["still_pending_ext"] = {task for (task, status, ext) in task_history
                                        if status == 'PENDING' and task not in set_tasks["ever_failed"] and task not in set_tasks["completed"] and not ext}
      set_tasks["still_pending_not_ext"] = {task for (task, status, ext) in task_history
                                            if status == 'PENDING' and task not in set_tasks["ever_failed"] and task not in set_tasks["completed"] and ext}
      set_tasks["run_by_other_worker"] = set()
      set_tasks["upstream_failure"] = set()
      set_tasks["upstream_missing_dependency"] = set()
      set_tasks["upstream_run_by_other_worker"] = set()
      set_tasks["upstream_scheduling_error"] = set()
      set_tasks["not_run"] = set()
      return set_tasks