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

Simplify get_builder_from_protocol in ProjwfcBandsWorkChain #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

t-reents
Copy link

@t-reents t-reents commented Jul 5, 2024

Hi @qiaojunfeng, thanks for this nice work!

We (well, mainly @AndresOrtegaGuerrero) are working on integrating the ProjwfcBandsWorkChain into AiiDAlab. Andres realized that it's not possible to provide Python datatypes in the overrides when using the get_builder_from_protocol method (I could confirm this behavior). One example is passing a float for kpoints_distance. However, this is possible in the AiiDA-QE plugin.

The problem occurs in the following part:

inputs = recursive_merge_container(inputs, protocol_inputs)

The PwBandsWorkChain.get_builder_from_protocol transformed the relevant inputs into AiiDA datatypes, but the aforementioned call of recursive_merge_container merges the plain Python datatypes from the protcol_inputs again.

I fixed this behavior in this PR and generally tried to simplify the get_builder_from_protocol. As the ProjwfcBandsWorkChain is a child class of the PwBandsWorkChain, the majority of the preparation is already done in PwBandsWorkChain.get_builder_from_protocol.
For example, I'm not sure if the following is really needed:

protocol_inputs = cls.get_protocol_inputs(
protocol=protocol, overrides=overrides
)

The protocol inputs are anyway passed to the get_builder_from_protocol methods of the sub-workchains and the ProjwfcBandsWorkChain doesn't have any additional inputs that are specific to this WorkChain.

I tested the changes and the results seem to be identical (at least within my tests). In case I removed parts that are necessary for the intended functionality because I misunderstood them, please let me know. I'm happy to revert certain changes/to adapt them.

Copy link
Contributor

aiida-cla-bot bot commented Jul 5, 2024

All contributors have accepted the CLA ✅


You might need to click the "Update/Rebase branch" button to update the pull request and rerun the GitHub actions to pass the CLA check.
Posted by the CLA Assistant Lite bot.

@t-reents t-reents force-pushed the imp/get_builder_from_protocol branch from e6ad2a2 to 717756b Compare July 5, 2024 07:53
@t-reents
Copy link
Author

t-reents commented Jul 5, 2024

I have read the CLA Document and I hereby accept the CLA

@AndresOrtegaGuerrero
Copy link

@t-reents could you update the branch and also solve the issue with the CLA Assistant error ? , I already tested the branch and it works.

@t-reents t-reents force-pushed the imp/get_builder_from_protocol branch from 717756b to 852d7d3 Compare August 15, 2024 18:29
This commit mainly simplifies the current version of the
`get_builder_from_protocol` method in `ProjwfcBandsWorkChain`.

Moreover, it adds support for overrides containing standard Python datatypes,
e.g. `kpoints_distance` specified as a float`.
@t-reents t-reents force-pushed the imp/get_builder_from_protocol branch from 852d7d3 to 0db533e Compare August 15, 2024 18:32
Copy link

@AndresOrtegaGuerrero AndresOrtegaGuerrero left a comment

Choose a reason for hiding this comment

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

LGTM! thank you for your job @t-reents !, I tested the PR no issues , @superstar54

Comment on lines -122 to -125
protocol_inputs = cls.get_protocol_inputs(
protocol=protocol, overrides=overrides
)

Copy link
Member

Choose a reason for hiding this comment

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

Hi @t-reents , thanks for the PR.

These lines should remain. They are used to read the protocol parameters from the file, projwfcbands.yaml. For the moment, the file only specifies clean_workdir. I think that's why you get identical results even after you remove them. However, more parameters may be added in the future.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @superstar54

I see the point that one might create a specific protocol for this WorkChain. I also mentioned this in the PR description. My point was that this WorkChain doesn't implement any additional inputs and basically inherits the PwBandsWorkChain only. I assumed that one would simply provide the individual changes via the overrides.

But yeah, it makes sense to have the possibility to specify a protocol to overwrite the defaults of the parents. Otherwise, one would always need to provide adjusted protocols for PwBandsWorkChain and ProjwfcBaseWorkChain.

Copy link
Author

Choose a reason for hiding this comment

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

@superstar54 Coming back to the point, that the ProjwfcBandsWorkChain doesn't have additional inputs, I'd suggest to load the protocol inputs and merge the relevant parts with the overrides for the subsequent calls of PwBandsWorkChain and ProjwfcBaseWorkChain. In this way, we still have the possibility to provide custom protocols but also fix the initial problem that the transformed values get overwritten by the Python base types.

Copy link
Member

Choose a reason for hiding this comment

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

Fine to me. If you do this, please also remove the projwfcbands.yaml file, and then add a detailed comment in the code that the WorkChain uses the parent protocol setting.

It would be good that @qiaojunfeng could have a quick look at it.

@superstar54 superstar54 self-requested a review August 15, 2024 19:54
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.

3 participants