Skip to content

👌 Only require pw.x in get_builder_from_protocol when it's actually needed - #101

Open
elinscott wants to merge 3 commits into
aiidateam:mainfrom
elinscott:feat/optional-scf-nscf-builder
Open

👌 Only require pw.x in get_builder_from_protocol when it's actually needed#101
elinscott wants to merge 3 commits into
aiidateam:mainfrom
elinscott:feat/optional-scf-nscf-builder

Conversation

@elinscott

Copy link
Copy Markdown
Collaborator

Problem

Wannier90WorkChain.get_builder_from_protocol always assembles the scf and nscf namespaces and always demands a pw code, even though the workchain itself might not require them (it runs those steps only when the namespace is present in its inputs).

A caller reusing a charge density or an nscf folder computed elsewhere is forced to provide a pw.x code that never runs, then delete both namespaces from the returned builder before submitting.

Changes

  • Add an nscf_parent_folder argument to Wannier90WorkChain.get_builder_from_protocol: if present, neither pw namespace is assembled, and the folder becomes the pw2wannier90 parent_folder, so the builder starts at the wannier90 step.
  • Add an scf_parent_folder argument: if present, the scf namespace is skipped, the nscf is still assembled, and the folder becomes the nscf parent_folder.
  • Reject passing both
  • Require the pw code only when a pw namespace is assembled, so nscf_parent_folder lets the caller omit it from codes entirely.
  • Give check_codes in utils/workflows/builder/submit.py a required_codes argument, matching the parameter of the same name already in utils/code.py.
  • To keep exlcude_semicore working, read the semicore pseudopotentials from whichever pw namespace is present, and from the pseudo family and the structure when neither is

The builder comes back ready to submit rather than needing to be patched up afterwards. Defaults are unchanged.

builder = Wannier90WorkChain.get_builder_from_protocol(
    codes={"pw2wannier90": pw2wannier90_code, "wannier90": w90_code},
    structure=structure,
    nscf_parent_folder=nscf_remote_folder,
)

Testing

  • A builder built with nscf_parent_folder and no pw code passes Wannier90WorkChain.spec().inputs.validate()
  • The same holds for scf_parent_folder
  • scf_parent_folder still requires pw
  • With nscf_parent_folder, exclude_semicore produces exactly the semicore list the full-assembly path produces
  • Passing both parent folders raises
  • an unresolvable pseudo family is reported
  • the default path still rejects a missing pw code with the original error

elinscott and others added 2 commits August 11, 2026 12:17
`Wannier90WorkChain.get_builder_from_protocol` always assembled the scf
and nscf namespaces and required a `pw` code, so a caller that reuses a
charge density or an nscf folder computed elsewhere had to pass a pw.x
code that never runs and then delete those namespaces from the builder.

- Add an `nscf_parent_folder` argument: neither pw namespace is
  assembled and the folder becomes the pw2wannier90 `parent_folder`.
- Add an `scf_parent_folder` argument: the scf namespace is skipped and
  the folder becomes the nscf `parent_folder`.
- Reject passing both, naming which one starts from which step.
- Require the `pw` code only when a pw namespace is assembled.
- Give `check_codes` a `required_codes` argument, matching the existing
  parameter of the same name in `utils/code.py`.
- Read the semicore pseudopotentials from whichever pw namespace is
  present, and raise when `exclude_semicore` is requested with neither.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`nscf_parent_folder` refused `exclude_semicore=True`, because the
semicore states were read off a pw namespace and neither is assembled on
that route. The pseudopotentials the states come from are fixed by the
pseudo family and the structure, both already resolved by then.

- Take the pseudos from `get_pseudo_and_cutoff` when no pw namespace was
  assembled, and drop the refusal.
- Cover it with an equality against the full-assembly path on structures
  that have semicore states.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@elinscott elinscott changed the title Feat/optional scf nscf builder 👌 Only require pw.x in get_builder_from_protocol when it's actually needed Aug 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.68%. Comparing base (8280e7b) to head (f1d0e36).
⚠️ Report is 112 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (8280e7b) and HEAD (f1d0e36). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (8280e7b) HEAD (f1d0e36)
4 2
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #101      +/-   ##
==========================================
- Coverage   43.25%   37.68%   -5.57%     
==========================================
  Files          44       45       +1     
  Lines        4231     5172     +941     
==========================================
+ Hits         1830     1949     +119     
- Misses       2401     3223     +822     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@elinscott elinscott added this to the v2.9.0 milestone Aug 14, 2026
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.

2 participants