Add workflow module ordering validation - #1651
Open
amjjbonvin wants to merge 7 commits into
Open
Conversation
Validate the sequence of modules in a workflow config against ordering rules declared as data in gear/workflow_rules.yaml: - disallowed_sequences: a module may not directly follow another - required_preceding: a module must be immediately preceded by one of a set - required_prior: a module must be preceded anywhere earlier by one of a set - required_first: the first module must be one of a set gear/workflow_ordering.py reads the rules and checks the ordered module list, collecting all violations into a single ConfigurationError. The check is wired into setup_run() and skipped for --extend-run configs (which only describe the appended modules). Adjusted the finetune-clustfcc example so its clustfcc steps are no longer directly consecutive. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Format workflow_ordering.py and the setup_run() hook with ruff format - List gear/workflow_ordering.py in the architecture gear table - Note the ordering validation step in the setup_run() docstring Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
amjjbonvin
requested review from
AnnaKravchenko,
Comp-era,
VGPReys and
rvhonorato
August 4, 2026 18:16
Contributor
|
At a glance this goes agains the fine tuning of the clustfcc parameters from the user manual here, bottom of the page |
Member
Author
Indeed - this example was updated (but not the manual). This is intended to avoid similar problems as with clustrmsd. But as said in the PR, the list of rules need to be checked. |
VGPReys
reviewed
Aug 6, 2026
VGPReys
reviewed
Aug 6, 2026
Co-authored-by: Victor Reys <132575181+VGPReys@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do and why?
HADDOCK3 validates that each workflow module and its parameters are valid, but it does not check whether the sequence of modules makes sense. Some modules only work when another ran before them, some must not be chained to themselves, and a workflow must start by building topologies. Until now, such mistakes only surfaced at run time (or produced meaningless results).
This PR adds a data-driven workflow ordering check. Constraints are declared in
src/haddock/gear/workflow_rules.yamland enforced bysrc/haddock/gear/workflow_ordering.py, so new rules can be added without touching the validation logic. Four rule types are supported:disallowed_sequences— a module may not directly follow another (e.g.clustrmsd → clustrmsd,clustfcc → clustfcc,seletop → seletop,seletopclusts → seletopclusts).required_preceding— a module must be immediately preceded by one of a set (topocgaftertopoaa;clustrmsdafterrmsdmatrix/ilrmsdmatrix).required_prior— a module must appear somewhere earlier (cgtoaarequirestopoaa).required_first— the first module must be one of a set (topoaa).The check is wired into
setup_run()and raises a singleConfigurationErrorlisting all violations (with step numbers and allowed alternatives). It is skipped for--extend-run, whose config only describes the appended modules, so the full order is not known there.The
plot-finetune-clustfcc.cfgexample was adjusted so itsclustfccsteps are no longer directly consecutive, matching theclustfcc → clustfccrule.How was this tested?
tests/test_gear_workflow_ordering.py(100% coverage ofworkflow_ordering.py) covering each rule type, multi-violation reporting, empty workflows, and custom rules files.docking-extend-run-*.cfgconfigs "fail" standalone, and those are exclusively run with--extend-run(where the check is skipped by design).ruff format --checkandruff checkpass on changed files;pytest tests/test_gear_workflow_ordering.py tests/test_gear_prepare_run.py→ 93 passed.AI assistance
Drafted with Claude Code and reviewed manually. Claude wrote the validation logic, YAML rules, tests, and docs; verified the behaviour by running the full test suite and cross-checking the rules against every example workflow in the repo. This is config/ordering validation only — no scoring, energy, restraint, or CNS/topology logic is involved.
Checklist
architecture.md, docstrings); user-manual update still to doCHANGELOG.mdupdated for user-facing changesRelated issues
Related to #1530.
Notes for reviewers
gear/workflow_rules.yaml— reviewers should sanity-check the rule set for scientific correctness (e.g. whether any other module pairs should be disallowed/required).