Skip to content

Conversation

j-wags
Copy link
Member

@j-wags j-wags commented Apr 23, 2025

Implements NAGLChargesHandler, which is basically just the data structure mirroring the new SMIRNOFF spec section, since the Interchange PR does all the heavy lifting for parameter assignment.

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.64%. Comparing base (143a70f) to head (fc431e2).
⚠️ Report is 1 commits behind head on main.

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

@j-wags j-wags self-assigned this Jun 13, 2025
@@ -3261,7 +3297,7 @@ class ToolkitAM1BCCHandler(_NonbondedHandler):
"""

_TAGNAME = "ToolkitAM1BCC" # SMIRNOFF tag name to process
_DEPENDENCIES = [vdWHandler, ElectrostaticsHandler, LibraryChargeHandler]
Copy link
Member

Choose a reason for hiding this comment

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

For better or worse, Interchange does not use this and I don't think anything else does

@mattwthompson
Copy link
Member

While there is always the potential for surprises, I like this implementation and believe it will be better than how NAGL-based charges are currently applied, which relies on isomorphism checks and has the potential to be very slow for large molecules (see #2072 for a fun example)

@j-wags j-wags changed the title [WIP] Handle NAGLCharges Implement NAGLChargesHandler Jul 10, 2025
@j-wags j-wags marked this pull request as ready for review July 10, 2025 15:32
@j-wags j-wags assigned mattwthompson and unassigned j-wags Jul 10, 2025
Copy link
Member

@mattwthompson mattwthompson left a comment

Choose a reason for hiding this comment

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

I think this is in good shape, but there are a few things I came across I would like to see either changed or argued for, or split off into separate changes.

This was odd to work through because the handler itself basically just stores a string which is passed onto Interchange later. If I'm not mistaken, there isn't much to do here. I was expected to spend time playing around with NAGLChargesHandler in memory and seeing what charges it assigns, but I guess that's not here by design. I think that's probably good (?) just a bit of a surprise.

I think we probably want NAGLToolkitWrapper to be included in some of the star imports like other wrappers are, i.e. I want it to be included in from openff.toolkit.utils import * - don't care if that happens here or in another PR.

@j-wags j-wags marked this pull request as draft July 15, 2025 19:05
@j-wags j-wags self-assigned this Jul 15, 2025
@mattwthompson mattwthompson removed their assignment Jul 17, 2025
@j-wags
Copy link
Member Author

j-wags commented Jul 29, 2025

I think I've addressed all the comments from the (excellent and thorough!) review. Before I request re-review, I'm going to finish up the interchange and nagl-models PRs to ensure that there aren't any remaining items that need compensatory changes in this PR.

I think we probably want NAGLToolkitWrapper to be included in some of the star imports like other wrappers are, i.e. I want it to be included in from openff.toolkit.utils import * - don't care if that happens here or in another PR.

Added! from openff.toolkit import NAGLToolkitWrapper now works.

Copy link
Member

@mattwthompson mattwthompson left a comment

Choose a reason for hiding this comment

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

🟢🟢🟢

Comment on lines 147 to 150
model_path = get_model(filename=partial_charge_method,
doi=doi,
file_hash=file_hash)

Copy link
Member

Choose a reason for hiding this comment

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

If a bad/unavailable file name ("method") is passed here, the NAGL tooling raises BadFileSuffixError or something similar from openff.nagl_models, which is different than all of the other toolkits which raise ChargeMethodUnavailableError. I don't think this is bad per se and the API works fine, but it might be surprising for a power-user or some edge case

skip_version_check=True
)
with pytest.raises(IncompatibleParameterError, match="different digital_object_identifier values"):
handler1.check_handler_compatibility(handler3)
Copy link
Member

Choose a reason for hiding this comment

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

(not blocking) Might be worth symmetrizing each of these, though really unlikely to be an issue

Comment on lines +2918 to +2919
with pytest.raises(IncompatibleParameterError, match="different model_file_hash values"):
handler1.check_handler_compatibility(handler4)
Copy link
Member

Choose a reason for hiding this comment

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

(not blocking) if the DOI and hash are BOTH non-matching one will be part of the error message and the other won't be. If it's trivial, it might be useful to include both in the error message. Either way, might be worth having a test that encodes which of them are included in the error message

)
with pytest.raises(IncompatibleParameterError, match="different model_file_hash values"):
handler1.check_handler_compatibility(handler4)

Copy link
Member

Choose a reason for hiding this comment

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

(certainly not blocking) the earlier tests looked at combinations of optional arguments missing but in ways that could be combined. A marginal add would be those cases in this test, but not particularly important

@j-wags j-wags marked this pull request as ready for review August 7, 2025 15:19
@j-wags j-wags merged commit d70974d into main Aug 14, 2025
17 checks passed
@j-wags j-wags deleted the naglcharges-handler branch August 14, 2025 16:43
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