-
Notifications
You must be signed in to change notification settings - Fork 16
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 electronic_structure
plugin
#522
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #522 +/- ##
==========================================
+ Coverage 78.92% 79.07% +0.14%
==========================================
Files 45 47 +2
Lines 3213 3211 -2
==========================================
+ Hits 2536 2539 +3
+ Misses 677 672 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @superstar54, I have two things ask to change, please have a look.
wcv = WorkChainViewer(wkchain.node) | ||
assert ( | ||
"DOS grouped by:" | ||
== wcv.result_tabs.children[2].children[0].children[0].children[0].value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea of all these children are, a detailed comment will be very useful.
Since now things are implemented as "Panel", is some of these children are panel? If so, I think Panel
can have some way to associate children with name to make it easy to access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test here is too detailed, and not necessary, so I removed it. A new test that checks the length of the panel children is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that is better!
children=[ | ||
ipw.HBox( | ||
children=[ | ||
ipw.Label( | ||
"DOS grouped by:", | ||
layout=ipw.Layout( | ||
justify_content="flex-start", width="120px" | ||
), | ||
), | ||
group_dos_by, | ||
] | ||
), | ||
], | ||
layout={"margin": "0 0 30px 30px"}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid a deep nest of widgets, if there are many, define it outside with a comment on what the box is for and where it is displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the code. Now, it's become more simple and clear.
BTW, there is no need to always merge the branch, if I find time to review I'll merge the main before I review. Usually, this happens before the final merge if there is no conflict. |
@unkcpz I refactored the code and added detailed comments. It's ready for review. Please focus on the plugin part, which is the primary purpose of this PR. The part of plotting the electronic structure is simply copied and pasted from the previous code, with few updates. If the code needs polished, it is better to open another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @superstar54, thanks a lot for refactoring, very beautiful! Just some minor questions.
bands=bands_data, | ||
dos=dos_data, | ||
) | ||
if False not in results_ready: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if False not in results_ready: | |
if all(results_ready): |
# add this plugin result panel | ||
self.result_tabs.children += (result,) | ||
self.result_tabs.set_title( | ||
len(self.result_tabs.children) - 1, result.title |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess len(self.result_tabs.children) - 1
is the idx of the tab. Please have a variable for it with comment.
@@ -29,14 +29,15 @@ class Result(ResultPanel): | |||
"""Result panel for the bands calculation.""" | |||
|
|||
title = "Bands" | |||
workchain_labels = ["bands"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this labels for? If there are more than one where will those shown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One can use the workchain_labels to specify which plugins (outputs) are needed for this result panel. For example, the electronic_structure result panel needs pdos and bands.
workchain_labels = ["bands", "pdos"]
To make this clear, I added a comment in the ResultPanel
.
wcv = WorkChainViewer(wkchain.node) | ||
assert ( | ||
"DOS grouped by:" | ||
== wcv.result_tabs.children[2].children[0].children[0].children[0].value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that is better!
tab = [ | ||
tab | ||
for tab in wcv.result_tabs.children | ||
if getattr(tab, "identifier", "") == "electronic_structure" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume identifier
is a mendatory attribute of panel, so get this be:
if getattr(tab, "identifier", "") == "electronic_structure" | |
if tab.identifier == "electronic_structure" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the comment above the code.
# the built-in summary and structure tabs is not a plugin panel,
# thus don't have identifiers
```
@unkcpz I updated the code based on your suggestions. It's ready for another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @superstar54 ! All good for me. Ready to 🚢
…` plugin (#522) This PR supports: - showing the result from multiple plugins. - only shows the result panel when it is available. - use `electronic_structure` plugin as an example, in which the result panel needs both `pdos` and `bands` plugin.
This PR supports
One can use the workchain_labels to specify which plugins (outputs) are needed for this result panel. For example, the
electronic_structure
result panel needspdos
andbands
.