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

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions src/aiida_wannier90_workflows/workflows/projwfcbands.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def get_builder_from_protocol( # pylint: disable=arguments-differ
"""
from aiida_wannier90_workflows.utils.workflows.builder.submit import (
recursive_merge_builder,
recursive_merge_container,
)

type_check(pw_code, (str, int, orm.Code))
Expand All @@ -123,39 +122,26 @@ def get_builder_from_protocol( # pylint: disable=arguments-differ
protocol=protocol, overrides=overrides
)

projwfc_overrides = None
if overrides:
projwfc_overrides = overrides.pop("projwfc", None)
projwfc_overrides = protocol_inputs.pop("projwfc", None)

pwbands_builder = PwBandsWorkChain.get_builder_from_protocol(
code=pw_code,
structure=structure,
protocol=protocol,
overrides=overrides,
overrides=protocol_inputs,
**kwargs,
)

# By default do not run relax
pwbands_builder.pop("relax", None)
inputs = pwbands_builder._inputs(prune=True) # pylint: disable=protected-access

projwfc_builder = ProjwfcBaseWorkChain.get_builder_from_protocol(
projwfc_code, protocol=protocol, overrides=projwfc_overrides
)
projwfc_builder.pop("clean_workdir", None)

inputs["projwfc"] = projwfc_builder._inputs( # pylint: disable=protected-access
prune=True
)
inputs["projwfc"].pop("clean_workdir", None)

# Need to convert `clean_workdir` to `orm.Bool`
if "clean_workdir" in protocol_inputs:
protocol_inputs["clean_workdir"] = orm.Bool(
protocol_inputs["clean_workdir"]
)

inputs = recursive_merge_container(inputs, protocol_inputs)
builder = recursive_merge_builder(builder, inputs)
builder.projwfc = projwfc_builder
builder = recursive_merge_builder(builder, pwbands_builder)

return builder

Expand Down
Loading