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

projwfc.x: parse from XML instead of parent calc #747

Merged
merged 5 commits into from
Oct 8, 2021

Conversation

mbercx
Copy link
Member

@mbercx mbercx commented Oct 3, 2021

Fixes #299

The current ProjwfcParser uses several in and output nodes from the
parent calculation. This increased the complexity of the tests for this
parser, and made running opengrid.x in between the pw.x and
projwfc.x run impossible without adding these in and output nodes to
the calculation job of opengrid.x.

Here we switch to parsing the XML instead of relying on the parent
calculation. The data-file-schema.xml of the parent calculation is
retrieved and parsed, providing the required information for the
subsequent parsing of the projwfc.x output. All the parsing tests are
updated to include the XML output file and remove the in/output links
for the parent calculation.

The convert_qe_to_kpoints function is added to convert the k-points
data in the XML to a KpointsData node.

@mbercx mbercx added the pr/blocked PR is blocked by another PR that should be merged first label Oct 3, 2021
@mbercx
Copy link
Member Author

mbercx commented Oct 3, 2021

This PR is still blocked since it builds on #741 (I used the PdosWorkChain to generate the parser test files ^^).

Here I simply switch to parsing the XML, but leave the 🍝 -code of the parser. I'll open a second PR soon with the new (and hopefully more readable) code. I split these up for a couple of reasons:

  1. Make this PR easier to review since it's time-critical.
  2. Update the tests for using the XML with the old parsing code. I shouldn't have to adapt them when I switch to my code, so the tests should still pass without adapting them, demonstrating that the parsing is unchanged by my refactoring.
  3. Although I'm sure the parsing is the same for QE v6.6 (the version I ran my tests with), I'm also quite confident that e.g. QE v6.3 will no longer parse properly, since I've removed some extra logic required to support it. Since starting from aiida-quantumespresso==4.0.0 we'll only support QE v6.5+, the PR with the refactored code can only be merged when we're getting ready to release 4.0.

@mbercx
Copy link
Member Author

mbercx commented Oct 3, 2021

@sphuber one thing I was considering is that we duplicate a lot of files in the repository by retrieving the XML file. I suppose it would be better to instead add the XML file to the retrieve_temporary_list.

Additionally, I was wondering if we should move the PDOS files (e.g. aiida.pdos_atm#1(Fe)_wfc#6(p_j1.5)) to the temporary retrieve list as well. Adding all these to the repository adds quite a bit of files, since you get one of these for each orbital of each atom. Even for the simple 2 atom case of Fe, this results in 16 extra files in the repository when running spin-orbit calculations. I don't see the use case for keeping these in the repository save for testing, since all of this data is stored in the ProjectionData output under the link projections.

@mbercx
Copy link
Member Author

mbercx commented Oct 3, 2021

In the end I decided to only move the XML file to the temporary retrieve list here, since technically no longer retrieving the PDOS files is backwards incompatible. I've added this to #749 instead.

Note: Please don't pay too much attention to coding style for this PR. I've reworked the code a lot in #749, so leave coding style comments for that one. I too was very annoyed by the use of out_info_dict to just pass everything between the various methods.

@mbercx mbercx removed the pr/blocked PR is blocked by another PR that should be merged first label Oct 5, 2021
@mbercx
Copy link
Member Author

mbercx commented Oct 5, 2021

@qiaojunfeng I've adapted the branch so it no longer builds on top of #741, so it's ready for review. I guess the main question is if this allows you to simplify the definition of the opengrid.x calculation job in #714.

Copy link
Collaborator

@qiaojunfeng qiaojunfeng left a comment

Choose a reason for hiding this comment

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

Thanks Marnik! Only few minor issues.

aiida_quantumespresso/calculations/projwfc.py Outdated Show resolved Hide resolved
aiida_quantumespresso/parsers/projwfc.py Outdated Show resolved Hide resolved
aiida_quantumespresso/calculations/projwfc.py Outdated Show resolved Hide resolved
aiida_quantumespresso/calculations/projwfc.py Outdated Show resolved Hide resolved
aiida_quantumespresso/parsers/projwfc.py Show resolved Hide resolved
qiaojunfeng added a commit to qiaojunfeng/aiida-quantumespresso that referenced this pull request Oct 5, 2021
With (aiidateam#747) the `ProjwfcParser` has no implicit requirements on
parent calculation. The code for compatibility with `ProjwfcCalculation`
is now removed.
@mbercx
Copy link
Member Author

mbercx commented Oct 7, 2021

@qiaojunfeng I've fixed the failure to return the XML exit codes and added some tests. I've also refactored the tests a bit to use pytest.mark.parametrize and have added a fixture to avoid too much repetition.

One final question I still had here: Since the projwfc needs to have a pw.x parent calculation (or rather, ancestor calculation in case open_grid.x is called in between), I suppose it's always guaranteed that there is an XML? Or is there a use case I'm missing where the XML file won't be present?

qiaojunfeng
qiaojunfeng previously approved these changes Oct 7, 2021
@qiaojunfeng
Copy link
Collaborator

Thanks @mbercx , all look good to me!

One final question I still had here: Since the projwfc needs to have a pw.x parent calculation (or rather, ancestor calculation in case open_grid.x is called in between), I suppose it's always guaranteed that there is an XML? Or is there a use case I'm missing where the XML file won't be present?

Yes I think so, these post-processing codes need to read the outdir of QE, if XML is not there, the code won't run. So we can safely assume XML is always there. 🚀

@mbercx
Copy link
Member Author

mbercx commented Oct 7, 2021

Thanks @qiaojunfeng! I'll just wait for a final sign-off from @sphuber, since he still raised some questions above.

sphuber
sphuber previously approved these changes Oct 8, 2021
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @mbercx if you just add the comment to the code why XML is retrieved as temporary, then this is good to go for me :+:

@mbercx mbercx dismissed stale reviews from sphuber and qiaojunfeng via 0478536 October 8, 2021 13:50
The current `ProjwfcParser` uses several in and output nodes from the
parent calculation. This increased the complexity of the tests for this
parser, and made running `opengrid.x` in between the `pw.x` and
`projwfc.x` run impossible without adding these in and output nodes to
the calculation job of `opengrid.x`.

Here we switch to parsing the XML instead of relying on the parent
calculation. The `data-file-schema.xml` of the parent calculation is
retrieved and parsed, providing the required information for the
subsequent parsing of the `projwfc.x` output. All the parsing tests are
updated to include the XML output file and remove the in/output links
for the parent calculation.

The `convert_qe_to_kpoints` function is added to convert the k-points
data in the XML to a `KpointsData` node.
@mbercx
Copy link
Member Author

mbercx commented Oct 8, 2021

@sphuber Locked 'n loaded, jefe!

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

¡Ándale ándale!

@mbercx mbercx merged commit 0874d95 into aiidateam:develop Oct 8, 2021
@mbercx mbercx deleted the fix/299/projwfc-parse branch October 8, 2021 13:59
@mbercx
Copy link
Member Author

mbercx commented Oct 8, 2021

mexican_cat

bastonero pushed a commit to bastonero/aiida-quantumespresso that referenced this pull request Dec 20, 2021
The current `ProjwfcParser` uses several in and output nodes from the
parent calculation. This increased the complexity of the tests for this
parser, and made running `opengrid.x` in between the `pw.x` and
`projwfc.x` run impossible without adding these in and output nodes to
the calculation job of `opengrid.x`.

Here we switch to parsing the XML instead of relying on the parent
calculation. The `data-file-schema.xml` of the parent calculation is
retrieved and parsed, providing the required information for the
subsequent parsing of the `projwfc.x` output. All the parsing tests are
updated to include the XML output file and remove the in/output links
for the parent calculation.

Note that the XML file is added to the temporary retrieve list since
although it is required for parsing, it is already in repository of a an
ancestor calculation.

The `convert_qe_to_kpoints` function is added to convert the k-points
data in the XML to a `KpointsData` node.
mbercx added a commit to mbercx/aiida-quantumespresso that referenced this pull request Jan 18, 2022
In aiidateam#747 we adjusted the parser for `projwfc.x` to rely on the XML file
instead of the provenance for obtaining the structure. This worked fine
for structures that have chemical symbols as kind names, but once the
kind labels contain numbers the `convert_qe2aiida_structure` failed to
generate the `StructureData` based on the XML content since this case is
not considered.

Here we rename this method to `convert_qe_to_aiida_structure` and make
it more flexible by also adding the case of numbered kind names. This is
simply done by removing any digits from the kind names in the XML to
obtain the corresponding `symbol` of the kind name.
mbercx added a commit to mbercx/aiida-quantumespresso that referenced this pull request Jan 18, 2022
In aiidateam#747 we adjusted the parser for `projwfc.x` to rely on the XML file
instead of the provenance for obtaining the structure. This worked fine
for structures that have chemical symbols as kind names, but once the
kind labels contain numbers the `convert_qe2aiida_structure` failed to
generate the `StructureData` based on the XML content since this case is
not considered.

Here we rename this method to `convert_qe_to_aiida_structure` and make
it more flexible by also adding the case of numbered kind names. This is
simply done by removing any digits from the kind names in the XML to
obtain the corresponding `symbol` of the kind name.
mbercx added a commit to mbercx/aiida-quantumespresso that referenced this pull request Jan 27, 2022
In aiidateam#747 we adjusted the parser for `projwfc.x` to rely on the XML file
instead of the provenance for obtaining the structure. This worked fine
for structures that have chemical symbols as kind names, but once the
kind labels contain numbers the `convert_qe2aiida_structure` failed to
generate the `StructureData` based on the XML content since this case is
not considered.

Here we rename this method to `convert_qe_to_aiida_structure` and make
it more flexible by also adding the case of numbered kind names. This is
simply done by removing any digits from the kind names in the XML to
obtain the corresponding `symbol` of the kind name.
sphuber pushed a commit that referenced this pull request Jan 28, 2022
In #747 we adjusted the parser for `projwfc.x` to rely on the XML file
instead of the provenance for obtaining the structure. This worked fine
for structures that have chemical symbols as kind names, but once the
kind labels contain numbers the `convert_qe2aiida_structure` failed to
generate the `StructureData` based on the XML content since this case is
not considered.

Here we rename this method to `convert_qe_to_aiida_structure` and make
it more flexible by also adding the case of numbered kind names. This is
simply done by removing any digits from the kind names in the XML to
obtain the corresponding `symbol` of the kind name.
qiaojunfeng added a commit to qiaojunfeng/aiida-quantumespresso that referenced this pull request Nov 22, 2022
With (aiidateam#747) the `ProjwfcParser` has no implicit requirements on
parent calculation. The code for compatibility with `ProjwfcCalculation`
is now removed.
mbercx pushed a commit to qiaojunfeng/aiida-quantumespresso that referenced this pull request Feb 7, 2023
With (aiidateam#747) the `ProjwfcParser` has no implicit requirements on
parent calculation. The code for compatibility with `ProjwfcCalculation`
is now removed.
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.

ProjwfcParser uses input nodes up to 3 links back, and prevents easy testing
3 participants