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

Protocols: Consider way of "popping" when overrides is None #653

Open
mbercx opened this issue Feb 18, 2021 · 0 comments · May be fixed by #1022
Open

Protocols: Consider way of "popping" when overrides is None #653

mbercx opened this issue Feb 18, 2021 · 0 comments · May be fixed by #1022

Comments

@mbercx
Copy link
Member

mbercx commented Feb 18, 2021

Currently, we call quite a lot of pop methods in the get_builder_from_protocol() methods to remove inputs which are not necessary for the underlying work chain, for example:

relax.pop('structure', None)
relax.pop('clean_workdir', None)
relax.pop('base_final_scf', None)
scf['pw'].pop('structure', None)
scf.pop('clean_workdir', None)
bands['pw'].pop('structure', None)
bands.pop('clean_workdir', None)
bands.pop('kpoints_distance', None)
bands.pop('kpoints_force_parity', None)

I was thinking it would be good to be able to simply add this removal of inputs to the .yaml files. I.e. replace:

default_inputs:
bands_kpoints_distance: 0.025
clean_workdir: True
nbands_factor: 3.0

with

default_inputs:
    bands_kpoints_distance: 0.025
    clean_workdir: True
    nbands_factor: 3.0
    relax:
        structure: null
        clean_workdir: null
        base_final_scf: null
    scf:
        pw:
            structure: null
<...>

I think this would be cleaner since you can see the inputs that are added/updated/removed in one place: the .yaml file. I especially noticed this when working on the PdosWorkChain protocol (see this PR in case you're just too curious and already want to have a look and maybe review it, @sphuber 😁 ). There are several inputs which need to be removed from the default values for the nscf PwBaseWorkChain, and I think it would cleaner and more readable to do this in the PwBaseWorkChain.

There are other advantages to adding the possibility of being able to remove inputs by setting the overrides value to None. @flavianojs was trying to switch to using the kpoints input (i.e. providing a KpointsData) instead of the kpoints_distance input. This is currently not possible by providing the correct overrides. Of course, it's possible to adjust this after obtaining the builder, but I think it should be possible to change all inputs with the overrides. This will also make it easier in the future for people to define their own protocols - which can touch every input - by writing .yaml files.

I'm not entirely sure yet how to implement this. We have to be careful not to just pop the None already in the ProtocolMixin.get_protocol_inputs() method, since then it will already be popped at a higher level work chain. Perhaps we should only pop here the highest level inputs, with the sole exception of the PwBaseWorkChain, since this is sort of the end of the line for all work chains. I'll come up with a working solution and open a PR, but I already wanted to see if anyone has comments on this.

@mbercx mbercx self-assigned this Feb 18, 2021
bastonero added a commit that referenced this issue Mar 28, 2024
Fixes #653

Add the possibility of popping input namespaces by specifying
None in the override for the specific namespace. A decorator
is added that generalize the concept to any implementation of
get_builder_from_protocol.
@bastonero bastonero linked a pull request Mar 28, 2024 that will close this issue
bastonero added a commit that referenced this issue Mar 29, 2024
Fixes #653

Add the possibility of popping input namespaces by specifying
None in the override for the specific namespace. A decorator
is added that generalize the concept to any implementation of
get_builder_from_protocol.
bastonero added a commit that referenced this issue Mar 29, 2024
Fixes #653

Add the possibility of popping input namespaces by specifying
None in the override for the specific namespace. A decorator
is added that generalize the concept to any implementation of
get_builder_from_protocol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant