Skip to content

Conversation

@jthorton
Copy link
Collaborator

@jthorton jthorton commented Dec 1, 2025

Add a test to make sure user charges are respected by the espaloma small molecule force field

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

@jthorton
Copy link
Collaborator Author

jthorton commented Dec 1, 2025

pre-commit.ci autofix

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.50%. Comparing base (44a3f7d) to head (5fd4562).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1707      +/-   ##
==========================================
- Coverage   95.47%   92.50%   -2.97%     
==========================================
  Files         187      187              
  Lines       16231    16244      +13     
==========================================
- Hits        15496    15027     -469     
- Misses        735     1217     +482     
Flag Coverage Δ
fast-tests 92.50% <100.00%> (?)
slow-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Am I correct in understanding this is happening because "from-molecule" is the default argument if you don't pass any template kwargs? https://github.com/openmm/openmmforcefields/blob/main/openmmforcefields/generators/template_generators.py#L1735

I might be looking in the wrong place, but it seems conflicting with the docstring: https://github.com/openmm/openmmforcefields/blob/1c969a638f72e8814fd29c5fd86f1af37517a783/openmmforcefields/generators/template_generators.py#L1657-L1658

Given that the defaults for when you pass in the kwargs is different from when you don't, I suspect it's actually a bug that is working in our favour.

It might be good to deal with this upstream (even if it means it might break behaviour here).

stateB=benzene_vacuum_system,
mapping=None,
)
unit = list(dag.protocol_units)[0]
Copy link
Member

Choose a reason for hiding this comment

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

This is why we should slowly rename things to offunit and ommunit, but maybe not in this PR.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

No API break detected ✅

@jthorton
Copy link
Collaborator Author

jthorton commented Dec 2, 2025

Am I correct in understanding this is happening because "from-molecule" is the default argument if you don't pass any template kwargs?

Yes thats right, so the doc string seems to be incorrect, while its working in a our favour now if we ever pass some args to the generator it could break in future so this test should give us peace of mind for now. I'll open an issue upstream to see what needs to be fixed.

@jthorton
Copy link
Collaborator Author

jthorton commented Dec 2, 2025

@IAlibay its slightly more complicated than we thought, I found that the section which assigns the charges in the espaloma template generator which does another check for user charges and if they are not present changes the method back to nn charges.

@IAlibay
Copy link
Member

IAlibay commented Dec 2, 2025

@IAlibay its slightly more complicated than we thought, I found that the section which assigns the charges in the espaloma template generator which does another check for user charges and if they are not present changes the method back to nn charges.

Could you expand on the complication here? I might be misunderstanding, but that bit of the code seems to be doing what I would expect. I.e. if it's got no charges it's going to have to generate some, might as well generate them with espaloma.

@IAlibay IAlibay merged commit 6a9e7e7 into main Dec 2, 2025
11 of 13 checks passed
@IAlibay IAlibay deleted the espaloma_user_charges branch December 2, 2025 11:48
@jthorton
Copy link
Collaborator Author

jthorton commented Dec 2, 2025

My thinking was that it adds another layer of confusion with regards to the docstring, it should should say by default checks for user charges and then if not defaults to espaloma.

@atravitz atravitz mentioned this pull request Dec 4, 2025
7 tasks
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.

3 participants