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

Improve simplified process tree #1174

Merged
merged 7 commits into from
Feb 20, 2025

Conversation

edan-bainglass
Copy link
Member

@edan-bainglass edan-bainglass commented Feb 20, 2025

This PR does the following:

  • Refactor tree classes to aiidalab_qe/common/process module
  • Add missing "not rendered" guards for monitor-triggered events
  • Improve tree styles, particularly height (max 500px)
  • Improve performance of counting finished jobs by replacing recursion with single DB query
  • Use a flag to signal when adding branches to avoid race conditions with monitoring thread

Future plan

  • Replace more iterative/recursive tree components with single DB query
  • Fetch more info from plugins to avoid on-the-fly processing

@edan-bainglass
Copy link
Member Author

@mikibonacci @superstar54 please test for duplicate nodes. I added a test, but not sure how reliable it is.

@superstar54
Copy link
Member

Hi @edan-bainglass , thanks for the work. The test seems not reliable. I think the test needs to mock the _add_branches_recursive with some time duration (~ 5 seconds), then you start another thread to trigger the _add_branches_recursive simultaneously. The time duration is important to test whether the lock indeed works.. If this is not easy to implement, we can skip the test for the moment.

@edan-bainglass
Copy link
Member Author

Hi @edan-bainglass , thanks for the work. The test seems not reliable. I think the test needs to mock the _add_branches_recursive with some time duration (~ 5 seconds), then you start another thread to trigger the _add_branches_recursive simultaneously. The time duration is important to test whether the lock indeed works.. If this is not easy to implement, we can skip the test for the moment.

I'll give it a try. I'm more concerned in the meantime not being able to resolve the compatibility issue with v2.3

@edan-bainglass
Copy link
Member Author

@superstar54 @mikibonacci test improved and indeed shows that the flag is necessary and effective.

Comment on lines +254 to +257
# With the flag in place, the monitor thread bails from adding
# branches when the parent branch is presently doing so, leading
# to only the adding of the single intended branch
assert len(self.tree.trunk.branches) == 1
Copy link
Member

Choose a reason for hiding this comment

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

The code starts the threading first, then click in main. Thus, it can not guarantee that the main will run first.

Copy link
Member Author

Choose a reason for hiding this comment

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

The monitor thread cannot add new branches to collapsed branches. Only after the main branch expands a parent branch and begins adding sub-branches does the monitor thread attempt to add sub-branches.

This was the root of the problem. Duplications happened when a monitor event happened shortly (and while) the user was expanding a parent node.

@superstar54 superstar54 self-requested a review February 20, 2025 17:22
Copy link
Member

@superstar54 superstar54 left a comment

Choose a reason for hiding this comment

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

LGTM

@edan-bainglass edan-bainglass merged commit 082185f into aiidalab:main Feb 20, 2025
5 checks passed
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.

2 participants