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

Add TaskCollection for waiting_on and children. #223

Merged
merged 5 commits into from
Aug 14, 2024

Conversation

superstar54
Copy link
Member

@superstar54 superstar54 commented Aug 13, 2024

Although there remains some debate over whether to use the append or replace method for managing the waiting_on list, I've decided to proceed with the append approach based on my past experiences. We are open to revising this if there is strong opposition.

For instance, the code below demonstrates how to append "task1" and "task2" to the waiting_on list for task3, rather than replacing the existing list with ("task1", "task2"):

task3.waiting_on.add(["task1", "task2"])

TaskCollection

Implement a TaskCollection to store a collection of tasks. This is used for the waiting_on and children attributes of the Task class. For example:

self.waiting_on = TaskCollection()
self.children = TaskCollection()

waiting_on

Take waiting_on as an example:

# can use the name of the task, or the task object itself
task3.waiting_on.add(["task1", task2])
task3.waiting_on.remove(["task1", "task2"])
task3.waiting_on.clear()

When adding or removing the task, it will check if the task exists or not.

Children

The children attribute is used to assign tasks to a Zone (e.g., While zone or If zone). For example,

# add task1 and task2 to the while loop
while_task.children.add(["task1", "task2"])

@superstar54 superstar54 linked an issue Aug 13, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 93.20388% with 7 lines in your changes missing coverage. Please review.

Project coverage is 79.39%. Comparing base (5937b88) to head (e358fab).
Report is 28 commits behind head on main.

Files Patch % Lines
aiida_workgraph/task.py 90.38% 5 Missing ⚠️
aiida_workgraph/tasks/builtins.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #223      +/-   ##
==========================================
+ Coverage   75.75%   79.39%   +3.63%     
==========================================
  Files          70       61       -9     
  Lines        4615     4479     -136     
==========================================
+ Hits         3496     3556      +60     
+ Misses       1119      923     -196     
Flag Coverage Δ
python-3.11 79.28% <93.20%> (+3.61%) ⬆️
python-3.9 79.34% <93.20%> (+3.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@edan-bainglass
Copy link
Member

I agree, regardless of the debate, good to get the code in for live testing. Maybe experience helps (partially) resolve the debate 🤞

Copy link
Member

@edan-bainglass edan-bainglass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We can always hash out the API details (naming mostly) down the road, once we have a better feel of the system as a whole.

@superstar54 superstar54 merged commit b3ce2ef into main Aug 14, 2024
8 checks passed
@superstar54 superstar54 deleted the feature/task_collection branch August 14, 2024 14:29
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change the syntax for wait
3 participants