Skip to content

Conversation

@IAlibay
Copy link
Member

@IAlibay IAlibay commented Dec 5, 2025

Fixes #1739

Checklist

  • All new code is appropriately documented (user-facing code must have complete docstrings).
  • Added a news entry, or the changes are not user-facing.
  • Ran pre-commit by making a comment with pre-commit.ci autofix before requesting review.

Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).

Developers certificate of origin

@IAlibay IAlibay changed the title Migrate validation to Protocol._validate in HybridTopologyProtocol [WIP] Migrate validation to Protocol._validate in HybridTopologyProtocol Dec 5, 2025
@IAlibay IAlibay changed the title [WIP] Migrate validation to Protocol._validate in HybridTopologyProtocol Migrate validation to Protocol._validate in HybridTopologyProtocol Jan 2, 2026
@IAlibay
Copy link
Member Author

IAlibay commented Jan 3, 2026

pre-commit.ci autofix

@IAlibay IAlibay mentioned this pull request Jan 3, 2026
6 tasks
Comment on lines 538 to 545
if m.componentA not in alchemical_components["stateA"]:
raise ValueError(
f"Mapping componentA {m.componentA} not in alchemical components of stateA"
)
if m.componentB not in alchemical_components["stateB"]:
raise ValueError(
f"Mapping componentB {m.componentB} not in alchemical components of stateB"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could maybe squash the repeated errors into a single loop?

Suggested change
if m.componentA not in alchemical_components["stateA"]:
raise ValueError(
f"Mapping componentA {m.componentA} not in alchemical components of stateA"
)
if m.componentB not in alchemical_components["stateB"]:
raise ValueError(
f"Mapping componentB {m.componentB} not in alchemical components of stateB"
)
for label in ["A", "B"]:
if getattr(m, f"component{label}") not in alchemical_components[f"state{label}"]:
raise ValueError(f"Mapping component{label} {gatattr(m, f'component{label}') not in alchemical components of state{label}")

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I implemented a variant of this. I'm generally not a massive fan of using getattr, but I guess if it can be reduced to the one call then it's ok.

* Mappings which involve element changes in core atoms
"""
# if a single mapping is provided, convert to list
if isinstance(mapping, ComponentMapping):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is done for us in the default_validate method on the base class so we could skip it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I might be missing something - it's not doing it inplace / in self, so we have to do it again here?

Copy link
Collaborator

@jthorton jthorton left a comment

Choose a reason for hiding this comment

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

Great to see this being used, left a couple of optional things you might consider changing otherwise LGTM!

Copy link
Contributor

@hannahbaumann hannahbaumann left a comment

Choose a reason for hiding this comment

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

Thanks @IAlibay , love the validate method! Just some small spelling things.


# Validate charge difference
# Note: validation depends on the mapping & solvent component checks
if stateA.contains(SolventComponent):
Copy link
Contributor

Choose a reason for hiding this comment

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

More a note to self, we'll have to see how to best do all these validations with the explicit solvent component.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is where we will need to make an explicit solvent component be a subclasses of both protein and solvent components

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

No API break detected ✅

@IAlibay IAlibay merged commit fd8101b into main Jan 6, 2026
4 of 11 checks passed
@IAlibay IAlibay deleted the validate-rfe branch January 6, 2026 15:02
IAlibay added a commit that referenced this pull request Jan 6, 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.

Migrate HybridTopologyProtocol to use validate

4 participants