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

check if code is none in workchain #505

Merged
merged 3 commits into from
Oct 18, 2023
Merged

check if code is none in workchain #505

merged 3 commits into from
Oct 18, 2023

Conversation

superstar54
Copy link
Member

@superstar54 superstar54 commented Oct 13, 2023

fix #506
If no code is not selected, it is None. So, in the workchain, we avoid loading it.

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (fc36106) 78.29% compared to head (6af7550) 78.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #505      +/-   ##
==========================================
+ Coverage   78.29%   78.31%   +0.02%     
==========================================
  Files          44       44              
  Lines        3160     3164       +4     
==========================================
+ Hits         2474     2478       +4     
  Misses        686      686              
Flag Coverage Δ
python-3.10 78.31% <100.00%> (+0.02%) ⬆️
python-3.8 ?
python-3.9 78.36% <100.00%> (+0.02%) ⬆️

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

Files Coverage Δ
src/aiidalab_qe/workflows/__init__.py 57.79% <100.00%> (ø)
tests/test_submit_qe_workchain.py 98.24% <100.00%> (+0.13%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@superstar54 superstar54 changed the title check if code is none check if code is none in workchain Oct 13, 2023
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.

Thanks @superstar54, I guess the issue only happens if there are other code, e.g xps involved in the calculation, correct?
The change looks all good for me, can you add a unit test to it?

@superstar54
Copy link
Member Author

I guess the issue only happens if there are other code, e.g xps involved in the calculation, correct?

For all codes. e.g if not calculate pdos, and codes dos is not selected. The dos code is passed as None to the builder.

@superstar54
Copy link
Member Author

The change looks all good for me, can you add a unit test to it?

Thanks for the suggestion. I have added the test.

"""Test if there is an error when the code is not selected."""
app = submit_app_generator()
app.submit_step.dos_code.value = None
app.submit_step._create_builder()
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding the test. But I didn’t see what you were testing for. Maybe add an assert statement, what is the value of dos code in the builder?
I also don’t understand why dos code will be None, the drop-down widget only has its value equal to None right after initialization but we already have localhost code for it as default.

But I agree the change is needed for the case such as xps code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also don’t understand why dos code will be None, the drop-down widget only has its value equal to None right after initialization but we already have localhost code for it as default.

If I may add something here (as the person that found this bug originally): I confirm that Xing's fix does work, though I agree that the nature of the issue is strange. From my own testing:

  • Running Bands or Xps alone without dos or pdos set returns the error: ValueError: one of the parameters 'identifier', pk', 'uuid' or 'label' has to be specified. You can actually request a Pdos calculation in step 2, set the dos.x and projwfc.x codes in step 3, then un-tick the Pdos calculation in step 2 to avoid the error without running Pdos.
  • Removing the line codes = {key: orm.load_node(value) for key, value in codes.items()} and just passing codes without converting the inputs (i.e. codes = parameters["codes"]) works without issues for Bands and Xps, but causes a different crash for Pdos. Unfortunately, I can't find the traceback for that one right now, but it seemed to be that the values for dos and pdos codes were in the form of their UUID, rather than a node like for pw.x.

Hope this helps a little in diagnosing the problem.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot for the details @PNOGillespie very helpful.

but it seemed to be that the values for dos and pdos codes were in the form of their UUID, rather than a node like for pw.x.

I have a feeling this could be related to the source of issue. The change look all good and I should not block the PR. approved.

Copy link
Member Author

Choose a reason for hiding this comment

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

@PNOGillespie Thanks for the information.

@superstar54 superstar54 merged commit bb8e3cb into main Oct 18, 2023
19 checks passed
@superstar54 superstar54 deleted the fix_code_none branch October 18, 2023 13:18
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.

Code is None in workchain
3 participants