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

Introduced the "extract" function to all the parsers, with relative tests #240

Conversation

DrDomenicoMarson
Copy link
Contributor

Ok, I hope not to have broken anything with this PR :-)
I added the extract(file, T) function to all the existing parsers, with a relative test for each parser.

The only parser that was heavily hit by this PR is the AMBER parser, as was mentioned in issue #222 .
Here I had to make different adjustments, on my machine all tests are passing through.
I took the opportunity to make also some small, cosmetic, changes to the code in the amber parser (just a couple of them, like removing the unnecessary 'class SomeThing(Object').

PS: brace yourself, I now have a copy of Amber2022, and it seems the way dHdl/MBAR data is written has changed, so the parser will need an urgent update to handle AMBER <2022 | >=2022)

@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Merging #240 (71020ee) into master (cb965ad) will increase coverage by 0.11%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #240      +/-   ##
==========================================
+ Coverage   98.44%   98.56%   +0.11%     
==========================================
  Files          25       25              
  Lines        1673     1672       -1     
  Branches      357      353       -4     
==========================================
+ Hits         1647     1648       +1     
+ Misses          5        3       -2     
  Partials       21       21              
Impacted Files Coverage Δ
src/alchemlyb/postprocessors/units.py 100.00% <ø> (ø)
src/alchemlyb/parsing/__init__.py 95.00% <100.00%> (-5.00%) ⬇️
src/alchemlyb/parsing/amber.py 98.64% <100.00%> (+1.16%) ⬆️
src/alchemlyb/parsing/gmx.py 98.20% <100.00%> (+0.02%) ⬆️
src/alchemlyb/parsing/gomc.py 93.33% <100.00%> (+0.12%) ⬆️
src/alchemlyb/parsing/namd.py 99.18% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@xiki-tempula xiki-tempula left a comment

Choose a reason for hiding this comment

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

These are great changes. This is an initial review. Do you mind bumping the coverage a bit? Thanks,

src/alchemlyb/parsing/amber.py Outdated Show resolved Hide resolved
src/alchemlyb/parsing/amber.py Show resolved Hide resolved
src/alchemlyb/parsing/amber.py Outdated Show resolved Hide resolved
@@ -252,63 +248,94 @@ def extract_u_nk(outfile, T):
Temperature in Kelvin at which the simulations were performed;
needed to generated the reduced potential (in units of kT)

Returns
Returns a dictionary with elements:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't change this as this would break sphinx.
Just say return a dictionary. Might also be good to check if the doc builds correctly.

Returns
-------
Dict
    A dictionary with keys of 'u_nk', which is a pandas DataFrame ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, I didn't know about that :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I edited the docstring for every new extract functions, and added to the docs, now the extract function appears correctly when the docs are built.

src/alchemlyb/parsing/gmx.py Show resolved Hide resolved
src/alchemlyb/parsing/gomc.py Show resolved Hide resolved
src/alchemlyb/parsing/namd.py Show resolved Hide resolved
src/alchemlyb/tests/parsing/test_amber.py Show resolved Hide resolved
src/alchemlyb/tests/parsing/test_gomc.py Outdated Show resolved Hide resolved
@DrDomenicoMarson
Copy link
Contributor Author

These are great changes. This is an initial review. Do you mind bumping the coverage a bit? Thanks,

This is unfortunately impossible right now. I made a detailed check, the lines that are not covered by the tests are unaffected/not created by my modifications (so the coverage is the same as before, just the total number of lines is reduced as I removed an entire function in the amber parser).
I would like not to touch the other parsers, as I'm not an expert in doing TI/FEP with other software. In issue #241 I pointed out a place where we could increase coverage.

In the amber parser, I could easily reach a coverage of 99%, but the issues in alchemtest have to be addressed before, as I need 3 "properly" created files. Currently, in the amber parser, we have 4 lines that are not covered by the tests (and were not covered also before this PR), 3 of which are easily addressable with the 3 new files, while for the 4th I have to go deeper in understanding a function that was already there and that I don't currently understand 100% :-).

Copy link
Collaborator

@xiki-tempula xiki-tempula left a comment

Choose a reason for hiding this comment

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

The current one looks reasonable to me. Just some comments.

This is unfortunately impossible right now. I made a detailed check, the lines that are not covered by the tests are unaffected/not created by my modifications (so the coverage is the same as before, just the total number of lines is reduced as I removed an entire function in the amber parser).

I do understand that some of the code are not being covered by the previous tests, do you mind adding # pragma: no cover to bump the coverage?

@DrDomenicoMarson
Copy link
Contributor Author

# pragma: no cover added to AMBER parser, it feels like cheating though :-)

@xiki-tempula
Copy link
Collaborator

xiki-tempula commented Sep 25, 2022

@DrDomenicoMarson It would be best that all lines are covered.
Obviously, some lines are more difficult to cover and offer little value to cover, so it is fine that those are not being covered.
What we don't want is a surprise where we thought that some lines of code are being covered but they are not, thus, # pragma: no cover will acknowledge that this line is not covered.

@xiki-tempula
Copy link
Collaborator

Have you checked that sphinx builds? As RTD is failing?

@DrDomenicoMarson
Copy link
Contributor Author

Have you checked that sphinx builds? As RTD is failing?

I just re-checked, in my computer if I go inside alchemtest/docs and run make html it creates a perfectly fine HTML file, with the extract methods reported.
sphinx gives me some warning, but concerning alchemlyb.workflows.* stuff, so I supposed those were already there!

@DrDomenicoMarson
Copy link
Contributor Author

Ok, digging deeper the problem was unrelated to this PR.
sphinx was complaining about the first lines in `postprocessors/units.py'
my sphinx (which is v4.3.2 vs the v5 here) didn't complain about that.
For now I tried just commenting the offending lines (maybe a better solution exists?)

@DrDomenicoMarson
Copy link
Contributor Author

Ok, it's a good thing this happened for us, as I fixed also a couple of other things in the docs regarding extract, but the problem is not on us, it is from the sphinx side, as [https://github.com/readthedocs/sphinx_rtd_theme/issues/1343]

Copy link
Collaborator

@xiki-tempula xiki-tempula left a comment

Choose a reason for hiding this comment

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

I'm happy with the content but we cannot merge it when the RTD fails.

src/alchemlyb/parsing/namd.py Show resolved Hide resolved
src/alchemlyb/parsing/gomc.py Show resolved Hide resolved
src/alchemlyb/parsing/gmx.py Show resolved Hide resolved
src/alchemlyb/parsing/amber.py Show resolved Hide resolved
@xiki-tempula
Copy link
Collaborator

Ok, probably give it a day or two and see if it got fixed by sphinx.

@orbeckst orbeckst linked an issue Sep 27, 2022 that may be closed by this pull request
@orbeckst
Copy link
Member

PS: brace yourself, I now have a copy of Amber2022, and it seems the way dHdl/MBAR data is written has changed, so the parser will need an urgent update to handle AMBER <2022 | >=2022)

Argh. Sigh. Thanks for raising #242 , that's the right approach!

@orbeckst
Copy link
Member

Regarding coverage: Are you saying that if we merged alchemistry/alchemtest#71 then you could increase the test coverage here and avoid no-cover pragmas?

@DrDomenicoMarson
Copy link
Contributor Author

@orbeckst Yeah, I can cover all lines of parsers/amber.py except 1 line, but maybe it's better not in this PR, I'd prefer to merge this with the pragma, then merge alchemistry/alchemtest#71 and I'll submit a PR that removes pragma.

@xiki-tempula they fixed the bug in sphinx, so now all checks are passed here!

Copy link
Collaborator

@xiki-tempula xiki-tempula left a comment

Choose a reason for hiding this comment

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

Do you mind add the versionadded and this PR is ready to go.

Copy link
Collaborator

@xiki-tempula xiki-tempula left a comment

Choose a reason for hiding this comment

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

LGTM will merge if all tests passes.

@DrDomenicoMarson
Copy link
Contributor Author

@xiki-tempula what do you think about the #Note in the namd.py parser? Should we keep it like that, with just returning u_nk, or should we also add the item dHdl: None to be consistent with the other parsers?

@xiki-tempula
Copy link
Collaborator

@DrDomenicoMarson I think at the moment both of them are good. I mean it is either if 'dhdl' in extract() or if extract()['dhdl'] is None. Both of them are quite intuitive and both of them are ok with me.

@DrDomenicoMarson
Copy link
Contributor Author

Ok, so we can just leave it like it's now, I remove the commented line in the test then, before the final merging!

@xiki-tempula xiki-tempula merged commit 48a719b into alchemistry:master Sep 27, 2022
@DrDomenicoMarson DrDomenicoMarson deleted the add-the-single-extract-function-in-parsers branch September 27, 2022 08:13
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.

Why test with exception in test_import?
3 participants