Skip to content

Add option to ignore suffix of gmx executables#165

Merged
orbeckst merged 15 commits intoBecksteinlab:masterfrom
theavey:master
Mar 7, 2019
Merged

Add option to ignore suffix of gmx executables#165
orbeckst merged 15 commits intoBecksteinlab:masterfrom
theavey:master

Conversation

@theavey
Copy link
Contributor

@theavey theavey commented Feb 10, 2019

In response to my very old issue, this fixes #124.

This adds an option in the config file called append_suffix. If it is set to 'no', the suffix of the gmx executables (such as "_mpi" or "_d") will be ignored when making the tool names. It's not ideal to not differentiate them, but it can make code much more consistent across computers.

The largest change here is that in order to properly test this, the config file has to be changed before gromacs is imported. pytest makes all imports relative to the highest package it can find. Therefore, when tests was nested in the gromacs folder, the tests would be imported as gromacs.tests.test_.... This means that the gromacs.__init__.py is run before even running any of the pytest setup functions. By moving the tests folder out of the gromacs package, the config file can be edited before the gromacs.__init__.py is ever called.

Because of this change, I've tried to refactor all the references to gromacs.tests or gromacs/tests that I could find.

This PR another item to the travis testing matrix that tests this option. Using two new command line options to pytest, a link to the gmx executable called 'gmx_mpi' is put into the home folder and written in the tools section of the config file; and the config file is written to ignore the suffix of the gmx executables found.

This adds two flags to pytest (one for making a link of gmx_mpi, the
other for ignoring the suffix on the gmx executable);
In order for this to work, the config file had to be edited before
anything from gromacs was imported
@theavey
Copy link
Contributor Author

theavey commented Feb 11, 2019

It seems that I was overly ambitious trying to make what I thought were trivial changes to the ConfigParser and some uses of it.

Seeing as you seem to want to continue Python 2 support, I can roll those changes back.

@richardjgowers
Copy link
Collaborator

@theavey what's the problem you're running into with Py2? I took a quick look and it looks like the super() call isn't happy, but I don't quite get why, it looks fine to me

@theavey
Copy link
Contributor Author

theavey commented Feb 11, 2019

So in Python 2, ConfigParser (or SafeConfigParser) are old-style classes (they don't inherit from object), so they can't be imported that way. If they were new-style classes, that syntax is correct.

It seems that one option is to add a second parent of object. I've done this and a couple other fixes for Python 2 in a different branch. If the tests pass, I'll pull those changes into my main branch so they will be reflected here.

Don't change behavior of the repo from which I forked

This reverts commit e0c154a.
@codecov
Copy link

codecov bot commented Feb 11, 2019

Codecov Report

Merging #165 into master will decrease coverage by 0.11%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
- Coverage   62.63%   62.52%   -0.12%     
==========================================
  Files          21       21              
  Lines        4135     4136       +1     
  Branches      662      662              
==========================================
- Hits         2590     2586       -4     
- Misses       1359     1362       +3     
- Partials      186      188       +2
Impacted Files Coverage Δ
gromacs/tools.py 55% <66.66%> (+1.04%) ⬆️
gromacs/config.py 73.41% <83.33%> (-1.27%) ⬇️
gromacs/core.py 68.93% <0%> (-0.86%) ⬇️
gromacs/utilities.py 68.06% <0%> (-0.65%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d96c34f...498e2e5. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 11, 2019

Codecov Report

Merging #165 into master will increase coverage by 0.13%.
The diff coverage is 95.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage    63.4%   63.54%   +0.13%     
==========================================
  Files          21       21              
  Lines        4148     4161      +13     
  Branches      663      664       +1     
==========================================
+ Hits         2630     2644      +14     
+ Misses       1334     1333       -1     
  Partials      184      184
Impacted Files Coverage Δ
gromacs/config.py 76.47% <100%> (+1.78%) ⬆️
gromacs/tools.py 55% <66.66%> (+1.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d2a19bb...a416776. Read the comment docs.

@theavey
Copy link
Contributor Author

theavey commented Feb 11, 2019

If the reason for moving the tests folder wasn't clear, I just wrote up a stackoverflow answer on a very related topic that might explain it more clearly.

@theavey
Copy link
Contributor Author

theavey commented Feb 14, 2019

Hi @orbeckst, this PR is not critical, but if any changes need to be made, sooner would be better for me. This is just fresh in my mind now, and it would be easier to work on now instead of having to get back into this later. Thanks!

_cf_getbool = ConfigParser.getboolean
_UNSET = object()

def _getboolean(self, section, option, fallback=_UNSET, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

this deserves a comment or two..

@orbeckst
Copy link
Member

@theavey sorry, I hadn't seen the PR – just very busy at the moment, so wasn't checking my GitHub feed. Generally speaking, if you need a reaction include @orbeckst so that I get an email notification.

@richardjgowers is already looking at the PR (THANK YOU Richard!!) and I won't really have time until the end of the week so whatever @richardjgowers decides is fine with me.

@orbeckst
Copy link
Member

And yes, I'd like to keep Python 2.7 compatibility – too much old code that uses it.

@orbeckst
Copy link
Member

orbeckst commented Mar 1, 2019

@theavey sorry for the slow responses from me. Could you please resolve the conflicts that are flagged here?

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

@theavey thanks for all the work.

Minor issues

  • comment on the _getboolean() method
  • I think the scripts/*.py files and the templates/*.sh should remain mode 755 – they are executable scripts. Or did you have a specific reason to change them to 644?
  • add an entry to CHANGES
  • add yourself to AUTHORS

@orbeckst
Copy link
Member

orbeckst commented Mar 1, 2019

Please ping me or @richardjgowers when we should review again. Thanks!

@orbeckst orbeckst self-assigned this Mar 1, 2019
theavey added 3 commits March 7, 2019 14:12
Add docstring and a few more comments on ConfigParser.getboolean for
Python 2;
Add entry to CHANGES;
add entry to AUTHORS;
fix accidental mode change to script files;
Fix conflicts because of updates to the base fork
@theavey
Copy link
Contributor Author

theavey commented Mar 7, 2019

Hi @orbeckst,

The conflicts were just that I had moved the tests.

I've added more comments on ConfigParser.getboolean. The main change here is that I backported the fallback kwarg for Python 2.

The mode changes were inadvertent. I think they must have just been 644 when I cloned the repository. I am not sure how else they would have been changed.

I've added to CHANGES and AUTHORS.

@orbeckst orbeckst merged commit 38fe957 into Becksteinlab:master Mar 7, 2019
@orbeckst
Copy link
Member

orbeckst commented Mar 7, 2019

@theavey many thanks for your contribution!

@theavey
Copy link
Contributor Author

theavey commented Mar 7, 2019

Of course! Thank you for the package

@orbeckst
Copy link
Member

orbeckst commented Mar 7, 2019

P.S.: We wanted to write a short JOSS paper #147 – if you're interested in participating, add yourself to the issue and add to the PR #158.

(Admittedly, I have been occupied with millions of other things and it's a bit slow going but it's going to happen eventually and anyone who contributed to the package has a chance to be on the paper.)

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.

Using differently named gromacs commands

3 participants