From 8d7e07d046f84114591fad70b6cd5a99dae1a581 Mon Sep 17 00:00:00 2001 From: Sambhav Dixit <94298612+sambhavnoobcoder@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:51:11 +0530 Subject: [PATCH 1/2] update __init__ Added - Tasks - max_workers --- swarms/structs/concurrent_workflow.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swarms/structs/concurrent_workflow.py b/swarms/structs/concurrent_workflow.py index 10950879..d63152d4 100644 --- a/swarms/structs/concurrent_workflow.py +++ b/swarms/structs/concurrent_workflow.py @@ -112,6 +112,7 @@ class ConcurrentWorkflow(BaseSwarm): return_str_on: bool = False, agent_responses: list = [], auto_generate_prompts: bool = False, + max_workers: int = None, *args, **kwargs, ): @@ -132,9 +133,12 @@ class ConcurrentWorkflow(BaseSwarm): self.return_str_on = return_str_on self.agent_responses = agent_responses self.auto_generate_prompts = auto_generate_prompts + self.max_workers = max_workers or os.cpu_count() + self.tasks = [] # Initialize tasks list self.reliability_check() + def reliability_check(self): try: logger.info("Starting reliability checks") From 5d17c50a8b48750b92b38d9587ecf56a2b60a1ba Mon Sep 17 00:00:00 2001 From: Sambhav Dixit <94298612+sambhavnoobcoder@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:54:19 +0530 Subject: [PATCH 2/2] Handles task assignment - handles task assignment properly --- swarms/structs/concurrent_workflow.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swarms/structs/concurrent_workflow.py b/swarms/structs/concurrent_workflow.py index d63152d4..1c6ea472 100644 --- a/swarms/structs/concurrent_workflow.py +++ b/swarms/structs/concurrent_workflow.py @@ -393,6 +393,9 @@ class ConcurrentWorkflow(BaseSwarm): ValueError: If an invalid device is specified. Exception: If any other error occurs during execution. """ + if task is not None: + self.tasks.append(task) + try: logger.info(f"Attempting to run on device: {device}") if device == "cpu": @@ -410,7 +413,6 @@ class ConcurrentWorkflow(BaseSwarm): count, self._run, task, img, *args, **kwargs ) - # If device gpu elif device == "gpu": logger.info("Device set to GPU") return execute_on_gpu(