-
Notifications
You must be signed in to change notification settings - Fork 14
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
Feature/handling molecules #834
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #834 +/- ##
==========================================
+ Coverage 67.87% 68.12% +0.25%
==========================================
Files 50 50
Lines 4507 4555 +48
==========================================
+ Hits 3059 3103 +44
- Misses 1448 1452 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
For this PR We need #833 merged to get the PDOS peaks otherwise is all 0.0 |
@edan-bainglass I included you since it involves widgets and some behaviour of the app , so you can give your opinion for changes or things to consider |
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.
tested in combination with #833
Automatic selection of periodicity will have to follow as a separate PR. The user can then override the automatic selection.
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.
Okay, all good from me! Note that it will likely all change in my PR - not the behavior, but the implementation, due to the introduction of MVC.
One comment though - I find it odd that a control that modifies the app behavior (disable this, remove that) is somewhat "hidden" deep down (expand step, expand editors, switch tab...). I would consider elevating such controls. I am planning a layout redesign PR after my MVC PR. Should be a fun one!
@tl.observe("input_structure") | ||
def _on_input_structure_change(self, change): | ||
"""Update the relax type options based on the input 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.
In my rework, I generally reserve _on_some_state_change
methods as handlers of observations, as you do here. But this also means they themselves do not handle logic. So everything below the method header (including the docstring) moves to a more specific method, here maybe _update_relax_type
, passing to is change["new"]
(or change
if more than "new"
is required). This keeps the "controller" _on
methods light and clear. Reading them effectively tells you what is happening in the app (e.g., on input_structure
change). Note that in my design, such methods as _update_relax_type
end up moving to the model. The controller triggers this so-called "business logic" via the model, keeping the controller light and dedicated only to reactions.
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.
Just giving you a heads up of what to expect in my beast PR, so no worries on changing it here 🙂
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.
Yeah, I know! that part of removing was something that i wanted to check with you , so for molecules we cannot allow the user to do Cell Optimization , however in ipywidgets the ToogleButtons , there is no way to disable one option .. so I opted to go my way around and remove that option for molecules, while making sure it should be present for 1d,2d, and 3d systems.
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.
Right, I've encountered the limitation before. Would be nice in general if any option-selection widget allowed disabling certain options. Oh well...
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.
So , i would rename as
@tl.observe("input_structure")
def _update_relax_type(self, change):
or keep the name of _on_input_structure_change name , since i need the traitlets to trigger this function ?
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.
Again, I wouldn't change it at this stage. But if you did...
@tl.observe("input_structure")
def _on_input_structure_change(self, change):
self._update_relax_type(change["new"]) # or `change` if you need more from it
def _update_relax_type(self, input_structure): # or change (see above)
...
Sometimes, the triggered handler (_on_<state>_change
) might trigger several methods. This pattern makes it clear what does are. For example:
on structure change:
do this()
then do that()
then finally do the last thing()
Easier to maintain. Also, this
, that
, etc. are effectively "business logic", so they are moved to the model. Then you get
on structure change:
model.do_this()
model.do_that()
model.the_last_thing()
Exception to the rule: controllers can also modify the view directly. In such a case, the method would not go through the model.
Please don't let any of the above block your 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.
ok i will keep the name , and i guess later we sit together for lazy loading :D
I will wait for the input from @superstar54 or @PNOGillespie , to know there is no conflict with the XAS or XPS plugins. or extra modifications so is 100% compatible |
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 @AndresOrtegaGuerrero , thanks for the nice work! I requested a few changes.
-
For the kpoints, I think we need to use
gamma_only
for molecule instead of [1, 1, 1], because the former one is faster. -
XAS plugin does not support molecule calculation. I think @PNOGillespie could add a warning message in the XAS GUI if users activate the molecule option (in a future PR).
-
XPS plugin supports molecule, and has a molecule option in the XPS GUI explicitly, I can modify it in a future PR to use the molecule option from this PR.
So, I think your PR can go ahead without worry XAS and XPS.
def create_kpoints_distance_link(self): | ||
"""Create the dlink for override and kpoints_distance.""" | ||
self.kpoints_distance_link = ipw.dlink( | ||
(self.override, "value"), | ||
(self.kpoints_distance, "disabled"), | ||
lambda override: not override, | ||
) | ||
|
||
def remove_kpoints_distance_link(self): | ||
"""Remove the kpoints_distance_link.""" | ||
if hasattr(self, "kpoints_distance_link"): | ||
self.kpoints_distance_link.unlink() | ||
del self.kpoints_distance_link | ||
|
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 suggest not creating the link; instead, modify the _override_changed
method. In this way, you only need to keep the logic in one place.
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 need this link to be created and removed , so that the kpoints distance is not modify for molecules , while keeping the same logic for other periodicities
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.
since is liked to the reset()
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 understand that the link is used to disable the kpoints_distance
widget. You can achieve this in _override_changed
. If input_structure is a molecule, the kpoints_distance
widget is disabled no matter the change is.
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.
but the issue, is when uploading a job with pbc that is not molecule , so I tried with the override ,but i realize that since is linked with the reset , it was better to create and remove the link ,
I would not use gamma_only , then there will be problems for vibroscopy app |
Another parameter is |
The idea is to set this first and in a follow up set the MT , since this a change in the workchain , |
Ok to add MT in another PR. btw, I can not find the |
and the MT for the assume isolate , Yest the best is to set that logic and how it affect other plugins in a follow up 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.
LGTM!
This feature handles #734
Modification to molecule editor
Cell option no available for Molecule
Kpoint_Distance disable for Molecules
New Workflow shuold restore behavior