Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError in ConcurrentWorkflow by Properly Initializing Tasks List #613

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

sambhavnoobcoder
Copy link
Contributor

@sambhavnoobcoder sambhavnoobcoder commented Oct 22, 2024

Description:

The ConcurrentWorkflow class was raising an AttributeError because the tasks attribute was not properly initialized in the class constructor. When the run() method attempted to access self.tasks, it failed because the attribute didn't exist. This caused workflows to fail when trying to execute tasks, particularly affecting use cases where tasks were added incrementally or when running multiple tasks in sequence.

Root Cause:

  • The tasks attribute was missing from the class's init method
  • The code assumed the existence of self.tasks but never properly initialized it
  • This caused the workflow to fail immediately upon attempting to access the tasks list

Solution:

The fix implements the following changes:

  • Added proper initialization of self.tasks = [] in the init method
  • Modified the task handling logic to append tasks when they're provided to the run() method
  • Ensured the tasks list is always available, even if empty
  • Added proper type hints and documentation for the tasks attribute

Benefits:

  • Prevents AttributeError when accessing tasks
  • Allows for both single-task and multi-task execution
  • Maintains state of tasks throughout the workflow's lifecycle
  • Improves code reliability and predictability

Breaking Changes:

  • None. This is a backward-compatible fix that maintains the existing API while resolving the underlying issue.

Related Issues:
Fixes #511


📚 Documentation preview 📚: https://swarms--613.org.readthedocs.build/en/613/

Added 
- Tasks 
- max_workers
- handles task assignment properly
@kyegomez kyegomez merged commit 1271980 into kyegomez:master Oct 24, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ConcurrentWorkflow
2 participants