drastically improved performance by removing unnecessary iteration over children of parent nodes, additionally added an extra check that the node didn't already have a job so that it wasn't cycling over nodes that had already run when running through all_nodes

This commit is contained in:
Rebeccah
2020-01-22 17:47:38 -05:00
parent 82dd4a3884
commit 6d2a2ab714

View File

@@ -210,36 +210,32 @@ class WorkflowDAG(SimpleDAG):
for node in self.sort_nodes_topological(): for node in self.sort_nodes_topological():
obj = node['node_object'] obj = node['node_object']
parent_nodes = [p['node_object'] for p in self.get_parents(obj)]
if obj.do_not_run is False and not obj.job and node not in root_nodes and not obj.all_parents_must_converge: if obj.do_not_run is False and not obj.job and node not in root_nodes and not obj.all_parents_must_converge:
parent_nodes = [p['node_object'] for p in self.get_parents(obj)]
if self._are_all_nodes_dnr_decided(parent_nodes): if self._are_all_nodes_dnr_decided(parent_nodes):
if self._should_mark_node_dnr(node, parent_nodes): if self._should_mark_node_dnr(node, parent_nodes):
obj.do_not_run = True obj.do_not_run = True
nodes_marked_do_not_run.append(node) nodes_marked_do_not_run.append(node)
if obj.do_not_run is False and obj.all_parents_must_converge: if obj.do_not_run is False and obj.all_parents_must_converge and not obj.job:
if self._are_relevant_parents_finished(node): if self._are_all_nodes_dnr_decided(parent_nodes):
# if the current node is a convergence node and all the if self._are_relevant_parents_finished(node):
# parents are finished then check to see if all parents # if the current node is a convergence node and all the
# met the needed criteria to run the convergence child # parents are finished then check to see if all parents
# (i.e. parent must fail, parent must succeed) # met the needed criteria to run the convergence child
parent_nodes = [p['node_object'] for p in self.get_parents(obj)] # (i.e. parent must fail, parent must succeed)
if any(p.do_not_run for p in parent_nodes): if any(p.do_not_run for p in parent_nodes):
obj.do_not_run = True obj.do_not_run = True
nodes_marked_do_not_run.append(node) nodes_marked_do_not_run.append(node)
else: else:
# import sdb for p in parent_nodes:
# sdb.set_trace() if p.job.status == "successful":
for p in parent_nodes: status = "success_nodes"
child_nodes = [] elif p.job.status == "failed":
if p.job.status == "successful": status = "failure_nodes"
child_nodes = [x for x in self.get_children(p, "success_nodes")] if (p not in [node['node_object'] for node in self.get_parents(obj, status)]
elif p.job.status == "failed": and p not in [node['node_object'] for node in self.get_parents(obj, "always_nodes")]):
child_nodes = [x for x in self.get_children(p, "failure_nodes")] obj.do_not_run = True
child_nodes.extend(x for x in self.get_children(p, "always_nodes")) nodes_marked_do_not_run.append(node)
if node not in child_nodes: break
obj.do_not_run = True
nodes_marked_do_not_run.append(node)
break
return [n['node_object'] for n in nodes_marked_do_not_run] return [n['node_object'] for n in nodes_marked_do_not_run]