Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "canary" workflow for HMR simulations [WIP] #22

Merged
merged 10 commits into from
Oct 13, 2020
Merged

Conversation

mattwthompson
Copy link
Member

@mattwthompson mattwthompson commented Oct 7, 2020

Resolves #21

What the script looks like in action:

(openff-dev) [openforcefields] echo openforcefields/offxml/openff-1.2.0.offxml | python canary/scripts/test_hmr.py
Running HMR with force field openff-1.2.0 and molecule with SMILES [H]C#CC([H])([H])[H]
Running HMR with force field openff-1.2.0 and molecule with SMILES [H]c1c(c(c(c(c1[H])[H])C#CC([H])([H])[H])[H])[H]
Traceback (most recent call last):
  File "canary/scripts/test_hmr.py", line 92, in <module>
    raise HMRCanaryError(failed_runs)
__main__.HMRCanaryError: [[Molecule with name '' and SMILES '[H]c1c(c(c(c(c1[H])[H])C#CC([H])([H])[H])[H])[H]', 'openff-1.2.0']]
(openff-dev) [openforcefields] echo openforcefields/offxml/openff-1.2.1.offxml | python canary/scripts/test_hmr.py
Running HMR with force field openff-1.2.1 and molecule with SMILES [H]C#CC([H])([H])[H]
Running HMR with force field openff-1.2.1 and molecule with SMILES [H]c1c(c(c(c(c1[H])[H])C#CC([H])([H])[H])[H])[H]
  • I was running into some stochastic test passes with 2 ps runs, so bumped it up to 10 ps.
  • Many of the "coverage" mols are not covered by Parsley. Haven't dug into them much for more insightful failures.
  • I intentionally kept these functions out of the module structure of the Python package as I don't believe these are things we should focus on shipping out. These are intentionally not rigorous and I'd like to avoid making long-term guarantees to the users that these tests are stable, or even a part of the API.

@mattwthompson
Copy link
Member Author

mattwthompson commented Oct 7, 2020

This will be a little tricky to review, let me try to provide the necessary context:

  • This branch at 7de9632 is "the real" version
  • In ab97f08 I added back openff-1.2.0.offxml, which at least does what's expected locally, and should cause CI to fail. It will be rolled back before merging (also goofed some stuff, so 0ddea85 should be used as a point of comparison)
(openff-dev) [openforcefields] git diff upstream/master --name-only | grep "\.offxml" | python canary/scripts/test_hmr.py
Running HMR with force field openff-1.2.0-old-and-bad and molecule with SMILES [H]C#CC([H])([H])[H]
Running HMR with force field openff-1.2.0-old-and-bad and molecule with SMILES [H]c1c(c(c(c(c1[H])[H])C#CC([H])([H])[H])[H])[H]
Traceback (most recent call last):
  File "canary/scripts/test_hmr.py", line 92, in <module>
    raise HMRCanaryError(failed_runs)
__main__.HMRCanaryError: [[Molecule with name '' and SMILES '[H]c1c(c(c(c(c1[H])[H])C#CC([H])([H])[H])[H])[H]', 'openff-1.2.0-old-and-bad']]

Copy link
Member

@j-wags j-wags left a comment

Choose a reason for hiding this comment

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

This is so cool! I think NaNs aren't being caught properly, but an uncaught NaN is still an informative canary, so it's up to you whether to try and catch them. Also, I don't think these sims are actually running for 10ps (rather they're still just at 2), so I left a comment on that.

Before you merge, could you modify step 2 of the release process to include the best way of running the canaries, and the criteria for blocking/not blocking the release? I think it will look like "ensure the new FF was tested by looking for these lines, and then ensure that no tests failed"

"rigidWater": True,
"removeCMMotion": False,
"hydrogenMass": 4
* unit.amu, # Does this also _subtract_ mass from heavy atoms?:w
Copy link
Member

Choose a reason for hiding this comment

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

I think so. So carbons get really light sometimes.

context.setPositions(mol.conformers[0])

# Run for 10 ps
integrator.step(500)
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 only 2ps

Copy link
Member

Choose a reason for hiding this comment

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

Also, here's where we could put the try/except to catch NaNs from the simulation.

for mol in hmr_mols:
try:
hmr_driver(mol, ff_name)
except NANEnergyError:
Copy link
Member

Choose a reason for hiding this comment

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

On linux, NaN failures don't seem to be getting caught. Not a huge deal since failing is the whole point of the canary, but it may be helpful to make it so that multiple NaNs can be caught and a summary of failures can be shown to users.

Copy link
Member Author

@mattwthompson mattwthompson Oct 13, 2020

Choose a reason for hiding this comment

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

Unfortunately, we run into one of those "un-Pythonic" behaviors in OpenMM, as the triggered exception cannot be caught.

>>> from simtk.openmm import OpenMMException
>>> try:
...     raise OpenMMException
... except OpenMMException:
...     print('caught!')
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: exceptions must derive from BaseException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
TypeError: catching classes that do not inherit from BaseException is not allowed

I can just catch it later, but not with the specificity we'd normally prefer (catching more than less is better for these tests, anyway):

(test) root@af8cfd33010c:/openforcefields# echo openforcefields/offxml/openff-1.2.0.offxml | python canary/scripts/test_hmr.py -vs
Warning: Unable to load toolkit 'OpenEye Toolkit'. The Open Force Field Toolkit does not require the OpenEye Toolkits, and can use RDKit/AmberTools instead. However, if you have a valid license for the OpenEye Toolkits, consider installing them for faster performance and additional file format support: https://docs.eyesopen.com/toolkits/python/quickstart-python/linuxosx.html OpenEye offers free Toolkit licenses for academics: https://www.eyesopen.com/academic-licensing
[16:05:40] WARNING: no name column found on line 0
[16:05:40] WARNING: no name column found on line 1
Running HMR with force field openff-1.2.0 and molecule with SMILES [H][C]#[C][C]([H])([H])[H]
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
Running HMR with force field openff-1.2.0 and molecule with SMILES [H][c]1[c]([H])[c]([H])[c]([C]#[C][C]([H])([H])[H])[c]([H])[c]1[H]
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /opt/conda/envs/test/lib/libtinfo.so.6: no version information available (required by /bin/bash)
Traceback (most recent call last):
  File "canary/scripts/test_hmr.py", line 94, in <module>
    raise HMRCanaryError(failed_runs)
__main__.HMRCanaryError: [[Molecule with name '' and SMILES '[H][C]#[C][C]([H])([H])[H]', 'openff-1.2.0', 'NaN Position(s)'], [Molecule with name '' and SMILES '[H][c]1[c]([H])[c]([H])[c]([C]#[C][C]([H])([H])[H])[c]([H])[c]1[H]', 'openff-1.2.0', 'NaN Position(s)']]

@mattwthompson
Copy link
Member Author

All canary tests failing in 372a96a, rolling back the bad OFFXML and merging

The 1.2.0 OFFXML was used just for testing, as it needed to mimic
a new file that not tracked by git on the master branch
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.

Automate running HMR "canary" tests before release
2 participants