Bug 1281062 - Create Action Tasks to schedule new jobs. r=dustin
MozReview-Commit-ID: 5MvqLfGrlLC
This commit is contained in:
@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
|
||||
TASK_REFERENCE_PATTERN = re.compile('<([^>]+)>')
|
||||
|
||||
|
||||
def optimize_task_graph(target_task_graph, do_not_optimize):
|
||||
def optimize_task_graph(target_task_graph, do_not_optimize, existing_tasks=None):
|
||||
"""
|
||||
Perform task optimization, without optimizing tasks named in
|
||||
do_not_optimize.
|
||||
@@ -27,7 +27,11 @@ def optimize_task_graph(target_task_graph, do_not_optimize):
|
||||
# taskId where applicable. Second, generate a new task graph containing
|
||||
# only the non-optimized tasks, with all task labels resolved to taskIds
|
||||
# and with task['dependencies'] populated.
|
||||
annotate_task_graph(target_task_graph, do_not_optimize, named_links_dict, label_to_taskid)
|
||||
annotate_task_graph(target_task_graph=target_task_graph,
|
||||
do_not_optimize=do_not_optimize,
|
||||
named_links_dict=named_links_dict,
|
||||
label_to_taskid=label_to_taskid,
|
||||
existing_tasks=existing_tasks)
|
||||
return get_subgraph(target_task_graph, named_links_dict, label_to_taskid), label_to_taskid
|
||||
|
||||
|
||||
@@ -55,7 +59,8 @@ def resolve_task_references(label, task_def, taskid_for_edge_name):
|
||||
return recurse(task_def)
|
||||
|
||||
|
||||
def annotate_task_graph(target_task_graph, do_not_optimize, named_links_dict, label_to_taskid):
|
||||
def annotate_task_graph(target_task_graph, do_not_optimize,
|
||||
named_links_dict, label_to_taskid, existing_tasks):
|
||||
"""
|
||||
Annotate each task in the graph with .optimized (boolean) and .task_id
|
||||
(possibly None), following the rules for optimization and calling the task
|
||||
@@ -86,6 +91,10 @@ def annotate_task_graph(target_task_graph, do_not_optimize, named_links_dict, la
|
||||
# if any dependencies can't be optimized, this task can't, either
|
||||
elif any(not t.optimized for t in dependencies):
|
||||
optimized = False
|
||||
# Let's check whether this task has been created before
|
||||
elif existing_tasks is not None and label in existing_tasks:
|
||||
optimized = True
|
||||
replacement_task_id = existing_tasks[label]
|
||||
# otherwise, examine the task itself (which may be an expensive operation)
|
||||
else:
|
||||
optimized, replacement_task_id = task.optimize()
|
||||
|
||||
Reference in New Issue
Block a user