From e5c4d705138134b8c846614b58b0eb19942ce1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20=C3=98stergaard=20Nielsen?= Date: Fri, 28 Jul 2023 10:53:34 +0200 Subject: [PATCH] fix bug: update successors --- src/planbee/scheduler/task_batch_processor.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/planbee/scheduler/task_batch_processor.py b/src/planbee/scheduler/task_batch_processor.py index c5f8311..1d3cd19 100644 --- a/src/planbee/scheduler/task_batch_processor.py +++ b/src/planbee/scheduler/task_batch_processor.py @@ -12,7 +12,7 @@ class TaskBatchProcessor: def __init__(self, task_graph: nx.DiGraph, task_dict: dict[str, Task]): self.task_graph = task_graph - self.task_dict = task_dict + self.task_dict = deepcopy(task_dict) def split_tasks_into_batches(self) -> dict[str, Task]: """ @@ -20,8 +20,6 @@ def split_tasks_into_batches(self) -> dict[str, Task]: an updated task dictionary with possibly split tasks. Tasks are split only if they have a batch size and the quantity is greater than the batch size. """ - task_dict_copy = deepcopy(self.task_dict) - # get the order of tasks based on their dependencies task_order = list(nx.topological_sort(self.task_graph)) @@ -39,13 +37,13 @@ def split_tasks_into_batches(self) -> dict[str, Task]: self._update_predecessor_successor_relationships(current_task, task_splits) # remove the current task from the task dictionary - del task_dict_copy[task_uid] + del self.task_dict[task_uid] # add the split tasks to the task dictionary for split_task in task_splits: - task_dict_copy[split_task.uid] = split_task + self.task_dict[split_task.uid] = split_task - return task_dict_copy + return self.task_dict def _update_predecessor_successor_relationships( self, task: Task, batches: list[Task]