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

Build NodeTree on demand #583

Merged
merged 5 commits into from
Apr 23, 2024
Merged

Conversation

superstar54
Copy link
Member

@superstar54 superstar54 commented Apr 10, 2024

Fix #584

This PR introduces the idea that: only build NodeTree on demand.

  • do not build tree recursively, only show the top-level
  • build the sub-tree when users select it, and expand it.

Demo

Here I used the result of the IR/Raman plugin (from @AndresOrtegaGuerrero ) as a example. Before, it's almost impossible to load it in the NodeTree.

Using this PR:

qeapp-node-tree.mp4

- do not build tree recursively, only show the top-level
- build the tree when users select it
@superstar54 superstar54 changed the title Improve node tree Build NodeTree on demand Apr 10, 2024
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.17%. Comparing base (826ad43) to head (795af3f).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #583   +/-   ##
=======================================
  Coverage   96.17%   96.17%           
=======================================
  Files          11       11           
  Lines        1177     1177           
=======================================
  Hits         1132     1132           
  Misses         45       45           
Flag Coverage Δ
python-3.10 96.17% <ø> (ø)
python-3.9 96.17% <ø> (ø)

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.

@superstar54
Copy link
Member Author

@danielhollas This PR is also relevant to your app; please review it if you have time.

@superstar54
Copy link
Member Author

@giovannipizzi This PR tried to fix one of the two issues from the Node Tree widget, which we discussed in yesterday's meeting. Comments are welcome.

@danielhollas
Copy link
Contributor

@superstar54 this is amazing, thanks so much on working on this. 👏 I badly need it for my app as well so I will definitely take a look and test it with my app, hopefully tomorrow.

It's nice to see that there was not more code needed for this; I was a bit afraid that it will be more difficult to implement.
Did you notice any downsides / weird corner cases in your implementation?

@giovannipizzi
Copy link
Member

That's fantastic, great! If Daniel checks it it would be great and then please merge it! Pinging @cpignedoli as well.

As a note (on existing code, not what you changed): is _default_openend a typo for _default_opened or it's correct?

else getattr(node, "pk", None)
)

self._build_tree(self.find_node(node_pk, getattr(node, "namespaces", None)))
Copy link
Contributor

Choose a reason for hiding this comment

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

From just looking at this code, I wonder how is it ensured that the tree is build only once? i.e. if a user selects / deselects the same node multiple times, is it going to trigger the build_tree multiple times or will the existing nodes be reused somehow?

Copy link
Member Author

@superstar54 superstar54 Apr 10, 2024

Choose a reason for hiding this comment

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

Thanks for the review. It's designed to build the tree every time the user selects it, for two reasons:

  • if the job is running, it will ensure the user sees the latest node tree.
  • since it only builds the first level of the child nodes, it should be quick even for a large number of child nodes.

but, yes, I will check if the already loaded child nodes will be reused or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @danielhollas , the already loaded child nodes will be reused when running the _build_tree.

@superstar54
Copy link
Member Author

As a note (on existing code, not what you changed): is _default_openend a typo for _default_opened or it's correct?

👍 It's a typo. I fixed it.

@AndresOrtegaGuerrero
Copy link
Member

@superstar54 I noticed the change in color of the WorkChains with finished[0] from green to gray,
image
Technically it doesnt affect the performance, or the visualization of the elements of the three but i was just wondering if it should be address or ignored ?

@cpignedoli
Copy link
Member

@superstar54 this is great. I tested on my docker for something small just to confirm it works. In addiiton, I checked with @AndresOrtegaGuerrero on a large Raman case, this PR seems to solve our problems.

@superstar54
Copy link
Member Author

I noticed the change in color of the WorkChains with finished[0] from green to gray,

Hi @AndresOrtegaGuerrero , thanks for pointing out this. it should be fixed in 795af3f.

@AndresOrtegaGuerrero
Copy link
Member

I noticed the change in color of the WorkChains with finished[0] from green to gray,

Hi @AndresOrtegaGuerrero , thanks for pointing out this. it should be fixed in 795af3f.

Indeed now is fixed!, thank is great job

Copy link
Member

@AndresOrtegaGuerrero AndresOrtegaGuerrero left a comment

Choose a reason for hiding this comment

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

LGTM! , I did different tests in qe app and improve performance immensely!. Great Job.

@superstar54 superstar54 merged commit 01be224 into aiidalab:master Apr 23, 2024
11 checks passed
@superstar54 superstar54 deleted the improve_node_tree branch April 23, 2024 09:46
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.

NodeTree widget is slow for WorkChain with a lot of sub-process
5 participants