-
Notifications
You must be signed in to change notification settings - Fork 75
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
Include detailed tests for forcefield metadata #435
Include detailed tests for forcefield metadata #435
Conversation
Previously, the tests in test_forcefield.py were assumed to test that forcefield metadata like `version`, `name`, etc. were properly loaded into the `Forcefield` object. This is only partially true, as there are cases where the files either go out of scope before that information is gathered, etc. This PR includes additional tests to ensure that this information is not being lost prematurely. Big thanks to: @mattwthompson, @ahy3nz for discovering this issue, creating MWE's for some of these cases, and taking my investigation further and most likely pinpointing the issue.
Codecov Report
@@ Coverage Diff @@
## master #435 +/- ##
==========================================
- Coverage 73.59% 73.58% -0.02%
==========================================
Files 17 17
Lines 1803 1802 -1
==========================================
- Hits 1327 1326 -1
Misses 476 476 |
When a forcefield file is provided by using the internal name: `foyer.Forcefield(name='oplsaa)`, the final file processing would happen in a separate part of the logic and use variables that were only accessed if the user used `forcefield_files` in the `Forcefield` constructor method. Now the same final processing occurs for all input types to load the forcefields. All tests currently pass with this fix in place.
Looks like this reproduces the issue ( I took Alex's suggested patch (#434 (comment)) and made a couple fixes so that tests would pass. I haven't thought much about unintended side effects yet. Here is the commit; feel free to move it around, copy, etc. : 22855d4 |
Yeah we essentially had the same design process and handling of the strings. Once this passes and we have the approvals, we can merge. Thanks @mattwthompson and @ahy3nz for both of your contributions! |
Does it matter that you're using |
(Sorry for the misclick 😬) |
That was my thought, we already strip out/handle things that might not behave the way we expect once we have pre-processed. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM iff tests pass.
There should be some added confidence if another piece of metadata can be added (#433) without re-engineering this machinery.
While I agree the pre-processed XML files are safer to try reading, we might have to consider this block of code that is being deleted in this PR. Originally, IIRC @justinGilmer ran into some problems with try:
super(Forcefield, self).__init__(*preprocessed_files)
finally:
for ff_file_name in preprocessed_files:
os.remove(ff_file_name) |
I did add a small section at the end of this init method to iterate through the open files and os.remove them. It runs into the problem where I cant really put a try catch finally around the entire part of that code to always ensure that the files are deleted, but it should handle most cases. |
My mistake! Good catch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
PR Summary:
Previously, the tests in test_forcefield.py were assumed to test that
forcefield metadata like
version
,name
, etc. were properly loadedinto the
Forcefield
object.This is only partially true, as there are cases where the files either
go out of scope before that information is gathered, etc. This PR
includes additional tests to ensure that this information is not being
lost prematurely. Big thanks to: @mattwthompson, @ahy3nz for discovering
this issue, creating MWE's for some of these cases, and taking my
investigation further and most likely pinpointing the issue.
PR Checklist
Refer to issues/PRs: #433 #434
Note: This does not have @ahy3nz 's fix incorporated yet, just the test cases that fail and currently work.