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

Feature/adv tot charge #402

Merged
merged 19 commits into from
May 31, 2023
Merged

Feature/adv tot charge #402

merged 19 commits into from
May 31, 2023

Conversation

AndresOrtegaGuerrero
Copy link
Member

This PR updates #377 to be compatible with the new re factoring

@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Patch coverage: 91.20% and project coverage change: +1.60 🎉

Comparison is base (c16de4e) 50.53% compared to head (9af972f) 52.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #402      +/-   ##
==========================================
+ Coverage   50.53%   52.13%   +1.60%     
==========================================
  Files          16       16              
  Lines        1789     1849      +60     
==========================================
+ Hits          904      964      +60     
  Misses        885      885              
Flag Coverage Δ
python-3.10 52.13% <91.20%> (+1.60%) ⬆️

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

Impacted Files Coverage Δ
aiidalab_qe/app/report.py 28.57% <0.00%> (-0.47%) ⬇️
aiidalab_qe/app/steps.py 69.07% <90.78%> (+3.62%) ⬆️
tests/conftest.py 97.34% <100.00%> (+0.28%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@AndresOrtegaGuerrero
Copy link
Member Author

@mbercx I was wondering if maybe you could give me a hint of what could be the sources in the failure of our test with python 3.9 and 3.8 ??

@mbercx
Copy link
Member

mbercx commented May 24, 2023

@AndresOrtegaGuerrero thanks for the ping! Yeah our nightly builds also started failing, not sure what's going on, but will prioritise fixing it! Very weird that even the released version 4.3.0 is suddenly failing...

@mbercx
Copy link
Member

mbercx commented May 24, 2023

Probably related to explosion/spaCy#12659

@mbercx
Copy link
Member

mbercx commented May 24, 2023

Was most likely due to a bug in pydantic~=1.10, now fixed in 1.10.8. I've opened a PR to adapt the dependency:

aiidateam/aiida-quantumespresso#941

I reran some tests that were failing for an aiida-quantumespresso PR, which now pass. But here the pydantic version seems somehow restricted, since the CI is installing version 1.10.2. Not sure why, but let's see what happens after my PR is merged and release a hotfix version 3.4.1.

@AndresOrtegaGuerrero
Copy link
Member Author

Was most likely due to a bug in pydantic~=1.10, now fixed in 1.10.8. I've opened a PR to adapt the dependency:

aiidateam/aiida-quantumespresso#941

I reran some tests that were failing for an aiida-quantumespresso PR, which now pass. But here the pydantic version seems somehow restricted, since the CI is installing version 1.10.2. Not sure why, but let's see what happens after my PR is merged and release a hotfix version 3.4.1.

Thank you !

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

@AndresOrtegaGuerrero thanks a lot!

I am wondering how we categorize parameters as "advanced". One option is anything beyond protocol is advanced. Or the smearing and kpoints overrides are categorized as advance setting as well.

And what confuses me most is that we already have the Advance Setting tab but it has another advance setting. I think it is true we need a parent widget to collect all such "advance setting" widgets in one. Why not we put all the widgets in "Advance Settings" tab to a widget called AdvanceSettings and manage the display there solely?

aiidalab_qe/app/steps.py Outdated Show resolved Hide resolved
aiidalab_qe/app/steps.py Outdated Show resolved Hide resolved
@@ -1077,6 +1166,11 @@ def _extract_report_parameters(
] = builder.bands.bands_kpoints_distance.value
parameters["nscf_kpoints_distance"] = builder.pdos.nscf.kpoints_distance.value

if builder.relax.base["pw"]["parameters"]["SYSTEM"]["tot_charge"]:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if builder.relax.base["pw"]["parameters"]["SYSTEM"]["tot_charge"]:
tot_charge = builder.relax.base["pw"]["parameters"]["SYSTEM"]["tot_charge"]
if total_charge:

This better move to above under the comment where said why the value getting from builder.relax.base is feasible.

I also don't quite understand, the tot_charge can be a None?

Copy link
Member Author

@AndresOrtegaGuerrero AndresOrtegaGuerrero May 26, 2023

Choose a reason for hiding this comment

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

Yeah it can be None, if the user do not apply advanced settings override, or the tot_charge override

aiidalab_qe/app/steps.py Outdated Show resolved Hide resolved
@@ -92,6 +92,10 @@
<td>{{ nscf_kpoints_distance }} &#8491;<sup>-1</sup></td>
</tr>
{% endif %}
{% if tot_charge %}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this logic is needed, if tot_charge not set, it is 0 by default, we can show it as well.

Copy link
Member Author

@AndresOrtegaGuerrero AndresOrtegaGuerrero May 26, 2023

Choose a reason for hiding this comment

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

Is needed, if the user doesnt activate the tot_charge , that value should be None. Thats why the widget has a general override, so the user can determine if advanced setting will be use, and then tot_charge ,( or any future option) should have also an override (to determine if you want to use it or not)

Copy link
Member

Choose a reason for hiding this comment

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

if the user doesnt activate the tot_charge , that value should be None.

If tot_charge widget not activate, can it be set to 0.0, then we don't need this if tot_charge. We can always have tot_charge in pw input file.

Copy link
Member Author

Choose a reason for hiding this comment

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

@unkcpz The issue (i feel, not sure about it) is about compatibility (if we care at this point) , if calculations do not have the tot_charge in the parameters, an error will always be present to visualize the results. What do you think ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the logic

aiidalab_qe/app/steps.py Outdated Show resolved Hide resolved
@unkcpz
Copy link
Member

unkcpz commented May 30, 2023

@AndresOrtegaGuerrero thanks! Look at the failed test on py3.10, the change on total charge is expected but I am worried about the kpoints_distance also changing. Can you check if the widget worked as expected that the kpoints can be correctly overrided?

To get the new regression tast data you just need to run pytest tests/ --force-regen (https://pytest-regressions.readthedocs.io/en/latest/overview.html#force-regen).

@AndresOrtegaGuerrero
Copy link
Member Author

@AndresOrtegaGuerrero thanks! Look at the failed test on py3.10, the change on total charge is expected but I am worried about the kpoints_distance also changing. Can you check if the widget worked as expected that the kpoints can be correctly overrided?

To get the new regression tast data you just need to run pytest tests/ --force-regen (https://pytest-regressions.readthedocs.io/en/latest/overview.html#force-regen).

@unkcpz I just updated the conftest

@AndresOrtegaGuerrero
Copy link
Member Author

@unkcpz , there was a change in the 557a460 I need to another commit

@AndresOrtegaGuerrero
Copy link
Member Author

@unkcpz Now it should be fine

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

@AndresOrtegaGuerrero Thanks again! Still, some minor requests, but the overall shape is very satisfactory.

Comment on lines 248 to 249
self.smearing_settings = SmearingSettings()
self.kpoints_settings = KpointSettings()
Copy link
Member

Choose a reason for hiding this comment

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

You use self.advanced_settings.smearing_settings multiple times. It is better to have an interface for the class. See comment above.

description = ipw.HTML("""Select the advanced settings for the <b>pw.x</b> code.""")
# set here defaul values for the advanced settings
tot_charge_default = 0

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
smeaning_settings = tl.Instance(SmearingSettings())
kpoints_settings = tl.Instance(KpointsSettings())

Add interfaces for the parent class.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I use this here i get an error, however the interface is establish with AdvancedSetting in ConfigureQeAppWorkChainStep and SubmitQeAppWorkChainStep.

Copy link
Member

Choose a reason for hiding this comment

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

What is the error you got exactly?

Copy link
Member Author

Choose a reason for hiding this comment

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

if i use the traitlets.Instance , it complaints is not defined , However it is not needed since the traitlets is now on AdvancedSettings, like it was for SmearingSettings and KpointsSettings in ConfigureQeAppWorkChainStep and SubmitQeAppWorkChainStep. So there shouldn't be an issue here

Copy link
Member

Choose a reason for hiding this comment

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

Okay, no problem from my side. Thanks!

"kpoints_distance_override"
]
self.kpoints_settings.override_protocol_kpoints.value = True
self.advanced_settings.kpoints_settings.kpoints_distance.value = (
Copy link
Member

Choose a reason for hiding this comment

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

These long attributes call really frightened me, same for the smearing_settings. I think it makes sense to get rid of the duplications of variable names.

  • advanced_settings and kpoints_settings both has "settings", maybe kpoints_settings -> kpoints?
  • kpoints_distance is under kpoints_settings, maybe "distance" is enough?

So this line can be self.advanced_settings.kpoints.distance.value.
I am not very sure this won't bring more ambiguity, if it is too much, you can ignore this. Any idea?

@@ -92,6 +92,10 @@
<td>{{ nscf_kpoints_distance }} &#8491;<sup>-1</sup></td>
</tr>
{% endif %}
{% if tot_charge %}
Copy link
Member

Choose a reason for hiding this comment

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

if the user doesnt activate the tot_charge , that value should be None.

If tot_charge widget not activate, can it be set to 0.0, then we don't need this if tot_charge. We can always have tot_charge in pw input file.

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

Almost there, three tiny requests.

description = ipw.HTML("""Select the advanced settings for the <b>pw.x</b> code.""")
# set here defaul values for the advanced settings
tot_charge_default = 0

Copy link
Member

Choose a reason for hiding this comment

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

What is the error you got exactly?

] = self.advanced_settings.smearing.smearing.value

# smearing degauss setting
pw_overrides[key]["pw"]["parameters"]["SYSTEM"][
Copy link
Member

Choose a reason for hiding this comment

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

Why you remove the setdefault clause? Python dictionary method setdefault() is similar to get(), but will set dict[key]=default if key is not already in dict.

Copy link
Member Author

Choose a reason for hiding this comment

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

@unkcpz Because if self.advanced_settings.override.value can control if you are going to use overrides , and the next line already creates the dictionary pw_overrides[key]["pw"] = {"parameters": {"SYSTEM": {}}}.

Copy link
Member

Choose a reason for hiding this comment

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

I see, this is more clear, nice!

@@ -1077,6 +1191,12 @@ def _extract_report_parameters(
] = builder.bands.bands_kpoints_distance.value
parameters["nscf_kpoints_distance"] = builder.pdos.nscf.kpoints_distance.value

tot_charge = builder.relax.base["pw"]["parameters"]["SYSTEM"]["tot_charge"]
Copy link
Member

Choose a reason for hiding this comment

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

It will fail if SYSTEM namelist don't have tot_charge, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I will modify this

Comment on lines 1194 to 1199
tot_charge = builder.relax.base["pw"]["parameters"]["SYSTEM"]["tot_charge"]
if tot_charge:
parameters["tot_charge"] = tot_charge
else:
parameters["tot_charge"] = 0.0

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tot_charge = builder.relax.base["pw"]["parameters"]["SYSTEM"]["tot_charge"]
if tot_charge:
parameters["tot_charge"] = tot_charge
else:
parameters["tot_charge"] = 0.0
parameters["tot_charge"] = builder.relax.base["pw"]["parameters"]["SYSTEM"].get("tot_charge", 0.0)

And probably better having a _DEFAULT_TOT_CHARGE for the class.

Copy link
Member Author

Choose a reason for hiding this comment

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

@unkcpz I solve it but i didnt implement the _DEFAULT_TOT_CHARGE for the class, since that is a function

Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

Two nitpicks, then it is fine to go. I approved it.

aiidalab_qe/app/report.py Outdated Show resolved Hide resolved
description = ipw.HTML("""Select the advanced settings for the <b>pw.x</b> code.""")
# set here defaul values for the advanced settings
tot_charge_default = 0

Copy link
Member

Choose a reason for hiding this comment

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

Okay, no problem from my side. Thanks!

] = self.advanced_settings.smearing.smearing.value

# smearing degauss setting
pw_overrides[key]["pw"]["parameters"]["SYSTEM"][
Copy link
Member

Choose a reason for hiding this comment

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

I see, this is more clear, nice!

tests/conftest.py Outdated Show resolved Hide resolved
AndresOrtegaGuerrero and others added 2 commits May 31, 2023 17:15
Co-authored-by: Jusong Yu <jusong.yeu@gmail.com>
Co-authored-by: Jusong Yu <jusong.yeu@gmail.com>
@AndresOrtegaGuerrero
Copy link
Member Author

@unkcpz I accepted your changes, thank you for all the input and help!

@unkcpz
Copy link
Member

unkcpz commented May 31, 2023

@AndresOrtegaGuerrero thanks a lot for such nice work! Looking forward to reviewing more for new features.

@unkcpz unkcpz merged commit 827bb83 into main May 31, 2023
7 of 11 checks passed
@unkcpz unkcpz deleted the feature/adv_tot_charge branch May 31, 2023 21:56
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.

None yet

3 participants