diff --git a/lib/pavilion/schedulers/advanced.py b/lib/pavilion/schedulers/advanced.py index f6ff2a4e5..6e01d3da2 100644 --- a/lib/pavilion/schedulers/advanced.py +++ b/lib/pavilion/schedulers/advanced.py @@ -336,18 +336,22 @@ def _get_chunks(self, node_list_id, sched_config) -> List[NodeSet]: for node in include_nodes: if node in nodes: nodes.remove(node) - chunk_size = chunk_size - len(include_nodes) - - chunks = [] - for i in range(len(nodes)//chunk_size): - # Apply the selection function and get our chunk nodes. - chunk = self.NODE_SELECTION[node_select](nodes, chunk_size) - # Filter out any chosen from our node list. - nodes = [node for node in nodes if node not in chunk] - - # Add the 'include_nodes' to every chunk. - chunk = include_nodes + chunk - chunks.append(chunk) + + if len(nodes) == chunk_size: + chunks = include_nodes + else: + chunk_size = chunk_size - len(include_nodes) + chunks = [] + + for i in range(len(nodes)//chunk_size): + # Apply the selection function and get our chunk nodes. + chunk = self.NODE_SELECTION[node_select](nodes, chunk_size) + # Filter out any chosen from our node list. + nodes = [node for node in nodes if node not in chunk] + + # Add the 'include_nodes' to every chunk. + chunk = include_nodes + chunk + chunks.append(chunk) if nodes and chunk_extra == BACKFILL: backfill = chunks[-1][:chunk_size - len(nodes)]