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

Python 3 #160

Closed
wants to merge 28 commits into from
Closed

Python 3 #160

wants to merge 28 commits into from

Conversation

ALescoulie
Copy link
Contributor

@ALescoulie ALescoulie commented Jul 21, 2021

Replaced yield tests. Removed type annotations. Added more compatibility code for python 2.

VOD555 and others added 20 commits July 15, 2021 15:04
* remove plt.close
* update default setting for SI
* return fig in fep.plot
* remove matplotlib.use('agg')
* remove plt.close
* update default setting for SI
* return fig in fep.plot
* remove matplotlib.use('agg')
@ALescoulie
Copy link
Contributor Author

Just realized there was a small error in formatting a string in conifg, fixed it in a commit.

@ALescoulie
Copy link
Contributor Author

With the fix to GromacsWrapper only 10 tests of 73 are failing, Solvate wet octanol, and the two analysis tests

@ALescoulie
Copy link
Contributor Author

With the fix to GromacsWrapper only 10 tests of 73 are failing, solvation of wet octanol, and the two analysis tests

uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
fail_ci_if_error: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Started CI file similar to one by @orbeckst for gromacswrapper, work in progress.

mdpow/equil.py Outdated

super(Simulation, self).__init__(**kwargs)

@staticmethod
def load_pickle():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For compatibility between 2 and 3, could probably also use six

Copy link
Member

Choose a reason for hiding this comment

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

six is preferred — better use existing, tested libraries and six is standard and already used

yield has_identifier, identifier
yield itp_in_top, identifier
yield coordinates_in_top, identifier
def test_watermodelsdat(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding parameterized tests to replace yield tests

@@ -1,4 +1,4 @@
path: mdpow/tests/testing_resources/states
path: /nfs/homes3/alescoul/MDPOW_dev/mdpow/tests/testing_resources/states
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was having issues finding path, will need to replace.

for k,v in self.iteritems():
x[k] = copy.deepcopy(v, memo)
return x
if sys.version_info.major == 3:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

iteritems() method not available in python 3, Iterable not variable in python 2, would like more elegant solution, but this should function.

mdpow/restart.py Outdated
@staticmethod
def get_pickle():
if sys.version_info.major == 3:
import _pickle as pickle
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugly compatibility code probably could use six

Copy link
Member

Choose a reason for hiding this comment

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

use six if possible — from six.moves import pickle probably, see docs and/or try it out interactively


def merge_dicts(user, default):
# TODO test merge_dicts
Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced with recursive method for merging dict containing multiple other dict, passed runinput

Copy link
Contributor Author

@ALescoulie ALescoulie left a comment

Choose a reason for hiding this comment

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

Current draft for update to python 3. Modified several outdated sections expecially around dictionary syntax. Replaced merge_dicts with recursive function with method not dependent on isiter. Many changes just adding spacing to follow PEP8. Tests still need to be modified to run generally, at the moment some paths have been set for locations on workstation for sake of simplicity. Some Errors still occur in the analysis tests some of which appear to be associated with numkit integrate.

Defiantly still a work in progress, hopefully nearing a functioning version.

Comment on lines 7 to 8
from mdpow.fep import *
from mdpow.equil import *
Copy link
Member

Choose a reason for hiding this comment

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

avoid blanket imports — only import what you need or better, use the qualified names as before

from numpy.testing import assert_array_almost_equal

from six.moves import cPickle as pickle

import mdpow.fep
Copy link
Member

Choose a reason for hiding this comment

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

leave as before with full paths as it makes it MUCH clearer where code comes from

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'll make that replacement in fep and equil in a new commit.

@@ -4,17 +4,18 @@

import yaml
import pybol

import gromacs
from numpy.testing import assert_array_almost_equal

from six.moves import cPickle as pickle
Copy link
Member

Choose a reason for hiding this comment

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

example for pickle use

class TestEnergyMinimization(object):

def setup(self):
gromacs.config.set_gmxrc_environment('~/.conda/envs/MDPOW3/bin/GMXRC')
Copy link
Member

Choose a reason for hiding this comment

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

should not be needed

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'll try without it, I was having some issues with it not finding the conda GMXRC, mostly a temporary solution to get tests running so I could evaluate my code. I defiantly need to remove some of the modifications I made while trying to troubleshoot import errors.

Comment on lines 5 to 6
from mdpow.config import *
from mdpow.fep import *
Copy link
Member

Choose a reason for hiding this comment

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

keep full imports

@@ -50,7 +50,8 @@ class TestFEPschedule(object):

def setup(self):
# load default bundled configuration
self.cfg = mdpow.config.get_configuration()
gromacs.config.set_gmxrc_environment('~/.conda/envs/MDPOW3/bin/GMXRC')
Copy link
Member

Choose a reason for hiding this comment

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

should not be needed

class TestFEPScript(object):
def setup(self):
gromacs.config.set_gmxrc_environment('~/.conda/envs/MDPOW3/bin/GMXRC')
Copy link
Member

Choose a reason for hiding this comment

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

should not be needed

@ALescoulie
Copy link
Contributor Author

@orbeckst I looked at your comments and to address the concerns will add six.moves to the files currently using cPickle or _pickle. I'll also go back and try to reverse some of the changes I made while trying to troubleshoot getting tests to run for me. They were a bit finicky to get working in particular surrounding sourcing GMXRC and importing the modules.

@ALescoulie
Copy link
Contributor Author

Just pushed 3 commits addressing @orbeckst comments on the code. Fixed the test imports and switched to six.moves, also removed the set_gmxrc_environment worked without it.

@orbeckst
Copy link
Member

As discussed offline: start from a recent develop (at least 355dbe8) and only add code that is directly necessary for Py 2/3 compatibility. I took your changes for the tests (yield replacement and added them to PR #164 e.g. in 86f5638 ).

@orbeckst
Copy link
Member

Close this PR because it is superseded by PR #166.

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