Skip to content

Commit

Permalink
Update dependency requirements (#457)
Browse files Browse the repository at this point in the history
* Make foyer an optional dependency

* Split dependencies into required and required for development

* Update developer requirements

* Marked appropriate tests to check if Foyer is installed

* Remove duplicate line

* Remove openbabel and gsd from Appveyor testing

* Attempt to fix coverage dependency issue (#466)

* Attempt to fix coverage dependency issue

Currently, the most recent version of python-coveralls requires
`coverage==4.0.3`, while pytest-cov requires `Coverage>=4.4`.

The current fix seems to be to pin `pytest-cov` to a previous
version. This can be changed once:
z4r/python-coveralls#66

has been resolved.

* Hotfix for MDTraj MOL2 file issues

MDTraj has merged a fix for MOL2 file reading
mdtraj/mdtraj#1378

However, it has not been included in a new release on
`conda` yet.

Pinning to an older version without the MOL2 fixes
currently.

* Forgot to update Appveyor build script

* Bump to version 0.8.1

* Update changelog to 0.8.1

* Fixes issues with packmol input files (#474)

* Fixes issues with packmol input file

Also reports error based on process code instead of output,
which prevented report of error about input issues.

* Bump to version 0.8.1

* Update changelog to 0.8.1

* Small formatting nits

* Run `activate base` before `conda build`

See ContinuumIO/anaconda-issues#10211 (comment)

* Update changelog

* Re-pin mdtraj and pytest-cov
  • Loading branch information
summeraz authored and justinGilmer committed Jan 7, 2019
1 parent 858f385 commit 64c02c3
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install:
- conda config --add channels bioconda
- conda config --add channels conda-forge
- conda config --add channels mosdef
- conda create -n test-environment python=$PYTHON_VERSION --file requirements.txt
- conda create -n test-environment python=$PYTHON_VERSION --file requirements-dev.txt
- source activate test-environment
- pip install -e .

Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ requirements:
- oset
- parmed
- mdtraj 1.9.1
- foyer

test:
requires:
Expand All @@ -32,6 +31,7 @@ test:
- ipykernel
- ipyext
- pytest-ignore-flaky
- foyer

source_files:
- mbuild/examples/*
Expand Down
11 changes: 6 additions & 5 deletions mbuild/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,9 +1445,10 @@ def _energy_minimize_openmm(
"""
from foyer import Forcefield
foyer = import_('foyer')

to_parmed = self.to_parmed()
ff = Forcefield(forcefield_files=forcefield_files, name=forcefield_name)
ff = foyer.Forcefield(forcefield_files=forcefield_files, name=forcefield_name)
to_parmed = ff.apply(to_parmed)

from simtk.openmm.app.simulation import Simulation
Expand Down Expand Up @@ -1727,9 +1728,9 @@ def save(self, filename, show_ports=False, forcefield_name=None,
show_ports=show_ports)
# Apply a force field with foyer if specified
if forcefield_name or forcefield_files:
from foyer import Forcefield
ff = Forcefield(forcefield_files=forcefield_files,
name=forcefield_name, debug=forcefield_debug)
foyer = import_('foyer')
ff = foyer.Forcefield(forcefield_files=forcefield_files,
name=forcefield_name, debug=forcefield_debug)
structure = ff.apply(structure, references_file=references_file)
structure.combining_rule = combining_rule

Expand Down
9 changes: 7 additions & 2 deletions mbuild/tests/test_compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import mbuild as mb
from mbuild.exceptions import MBuildError
from mbuild.utils.geometry import calc_dihedral
from mbuild.utils.io import get_fn, has_intermol, has_openbabel
from mbuild.utils.io import get_fn, has_foyer, has_intermol, has_openbabel
from mbuild.tests.base_test import BaseTest

class TestCompound(BaseTest):
Expand Down Expand Up @@ -52,6 +52,7 @@ def test_save_overwrite(self, ch3):
with pytest.raises(IOError):
ch3.save(filename=outfile, overwrite=False)

@pytest.mark.skipif(not has_foyer, reason="Foyer is not installed")
def test_save_forcefield(self, methane):
exts = ['.gsd', '.hoomdxml', '.lammps', '.lmp', '.top', '.gro',
'.mol2', '.pdb', '.xyz']
Expand All @@ -60,6 +61,7 @@ def test_save_forcefield(self, methane):
forcefield_name='oplsaa',
overwrite=True)

@pytest.mark.skipif(not has_foyer, reason="Foyer is not installed")
def test_save_forcefield_with_file(self, methane):
exts = ['.gsd', '.hoomdxml', '.lammps', '.lmp', '.top', '.gro',
'.mol2', '.pdb', '.xyz']
Expand All @@ -83,11 +85,13 @@ def test_save_resnames_single(self, c3, n4):
assert struct.residues[0].number == 1
assert struct.residues[1].number == 2

@pytest.mark.skipif(not has_foyer, reason="Foyer is not installed")
def test_save_references(self, methane):
methane.save('methyl.mol2', forcefield_name='oplsaa',
references_file='methane.bib')
assert os.path.isfile('methane.bib')

@pytest.mark.skipif(not has_foyer, reason="Foyer is not installed")
def test_save_combining_rule(self, methane):
combining_rules = ['lorentz', 'geometric']
gmx_rules = {'lorentz': 2, 'geometric': 3}
Expand Down Expand Up @@ -668,13 +672,14 @@ def test_energy_minimization_ports(self, octane):
assert np.array_equal(distances, updated_distances)
assert np.array_equal(orientations, updated_orientations)

@pytest.mark.skipif(not has_foyer, reason="Foyer is not installed")
def test_energy_minimize_openmm(self, octane):
octane.energy_minimize(forcefield='oplsaa')

@pytest.mark.skipif(not has_foyer, reason="Foyer is not installed")
def test_energy_minimize_openmm_xml(self, octane):
octane.energy_minimize(forcefield=get_fn('small_oplsaa.xml'))


def test_clone_outside_containment(self, ch2, ch3):
compound = mb.Compound()
compound.add(ch2)
Expand Down
11 changes: 9 additions & 2 deletions mbuild/tests/test_gsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest
from mbuild.tests.base_test import BaseTest
from mbuild.utils.io import has_gsd
from mbuild.utils.io import has_foyer, has_gsd


class TestGSD(BaseTest):
Expand All @@ -13,19 +13,23 @@ class TestGSD(BaseTest):
def test_save(self, ethane):
ethane.save(filename='ethane.gsd')

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_save_forcefield(self, ethane):
ethane.save(filename='ethane-opls.gsd', forcefield_name='oplsaa')

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_save_box(self, ethane):
box = mb.Box(lengths=np.array([2.0,2.0,2.0]))
ethane.save(filename='ethane-box.gsd', forcefield_name='oplsaa',box=box)

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
def test_save_triclinic_box_(self, ethane):
box = mb.Box(lengths=np.array([2.0, 2.0, 2.0]), angles=[60, 70, 80])
ethane.save(filename='triclinic-box.gsd', forcefield_name='oplsaa', box=box)

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_particles(self, ethane):
from collections import OrderedDict
Expand Down Expand Up @@ -65,6 +69,7 @@ def test_particles(self, ethane):
assert np.array_equal(types_from_gsd, unique_types)
assert np.array_equal(typeids_from_gsd, expected_typeids)

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_box(self, ethane):
import gsd, gsd.pygsd
Expand Down Expand Up @@ -99,7 +104,7 @@ def test_box(self, ethane):
assert np.isclose(np.cos(np.radians(70)), xz / c)
assert np.isclose(np.cos(np.radians(80)), xy / b)


@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_rigid(self, benzene):
import gsd, gsd.pygsd
Expand All @@ -115,6 +120,7 @@ def test_rigid(self, benzene):
for gsd_body, expected_body in zip(rigid_bodies, expected_bodies):
assert gsd_body == expected_body

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_bonded(self, ethane):
from foyer import Forcefield
Expand Down Expand Up @@ -190,6 +196,7 @@ def test_bonded(self, ethane):
assert np.array_equal(dihedral_atoms, expected_dihedral_atoms)
assert np.array_equal(dihedral_typeids, np.zeros(n_dihedrals))

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
@pytest.mark.skipif(not has_gsd, reason="GSD package not installed")
def test_pairs(self, benzene):
from foyer import Forcefield
Expand Down
3 changes: 3 additions & 0 deletions mbuild/tests/test_hoomdxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

import mbuild as mb
from mbuild.tests.base_test import BaseTest
from mbuild.utils.io import has_foyer


class TestHoomdXML(BaseTest):

def test_save(self, ethane):
ethane.save(filename='ethane.hoomdxml')

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
def test_save_forcefield(self, ethane):
ethane.save(filename='ethane-opls.hoomdxml', forcefield_name='oplsaa')

Expand Down Expand Up @@ -38,6 +40,7 @@ def test_rigid(self, benzene):
assert rigid_bodies.count(body_id) == 6
assert rigid_bodies.count(-1) == n_benzenes * 6

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
def test_number_in_each_section(self, box_of_benzenes):
box_of_benzenes.save(filename='benzene.hoomdxml', forcefield_name='oplsaa')
xml_file = xml.etree.ElementTree.parse('benzene.hoomdxml').getroot()
Expand Down
3 changes: 3 additions & 0 deletions mbuild/tests/test_lammpsdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@

import mbuild as mb
from mbuild.tests.base_test import BaseTest
from mbuild.utils.io import has_foyer


class TestLammpsData(BaseTest):

def test_save(self, ethane):
ethane.save(filename='ethane.lammps')

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
def test_save_forcefield(self, ethane):
ethane.save(filename='ethane-opls.lammps', forcefield_name='oplsaa')

@pytest.mark.skipif(not has_foyer, reason="Foyer package not installed")
def test_save_box(self, ethane):
box = mb.Box(lengths=np.array([2.0, 2.0, 2.0]))
ethane.save(filename='ethane-box.lammps', forcefield_name='oplsaa', box=box)
Expand Down
19 changes: 19 additions & 0 deletions mbuild/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ class DelayImportError(ImportError, SkipTest):

MESSAGES['pybel'] = MESSAGES['openbabel']

MESSAGES['foyer'] = '''
The code at {filename}:{line_number} requires the "foyer" package
foyer can be installed using:
# conda install -c mosdef foyer
or
# pip install foyer
'''


def import_(module):
"""Import a module, and issue a nice message to stderr if the module isn't installed.
Expand Down Expand Up @@ -133,6 +145,13 @@ def import_(module):
except ImportError:
has_openbabel = False

try:
import foyer
has_foyer = True
del foyer
except ImportError:
has_foyer = False


def get_fn(name):
"""Get the full path to one of the reference files shipped for utils.
Expand Down
31 changes: 31 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
numpy
scipy
packmol=1.0.0
nglview>=0.6.2.3
oset
parmed
# TODO: Remove pinning of mdtraj version once mol2 reader issues have been resolved.
# https://github.com/mdtraj/mdtraj/pull/1378
# Once this has been released in a new MDTraj version, this can be removed.
mdtraj==1.9.1
foyer
gsd
openbabel
pytest >=3.0
jupyter
nbformat
ipykernel
ipyext
python-coveralls
# TODO: Remove the pinning of the pytest-cov version again once issue
# https://github.com/z4r/python-coveralls/issues/66
# is resolved.
# Background: pytest-cov 2.6.0 has increased the version
# requirement for the coverage package from >=3.7.1 to
# >=4.4, which is in conflict with the version requirement
# defined by the python-coveralls package for coverage==4.0.3.
# This fix from:
# https://github.com/pywbem/pywbem/commit/d85a3e73e08d2846073087733b790b5a8864d93f
pytest-cov>=2.4.0,<2.6
pytest-faulthandler
pytest-ignore-flaky
21 changes: 0 additions & 21 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,3 @@ parmed
# https://github.com/mdtraj/mdtraj/pull/1378
# Once this has been released in a new MDTraj version, this can be removed.
mdtraj==1.9.1
foyer
gsd
openbabel
pytest >=3.0
jupyter
nbformat
ipykernel
ipyext
python-coveralls
# TODO: Remove the pinning of the pytest-cov version again once issue
# https://github.com/z4r/python-coveralls/issues/66
# is resolved.
# Background: pytest-cov 2.6.0 has increased the version
# requirement for the coverage package from >=3.7.1 to
# >=4.4, which is in conflict with the version requirement
# defined by the python-coveralls package for coverage==4.0.3.
# This fix from:
# https://github.com/pywbem/pywbem/commit/d85a3e73e08d2846073087733b790b5a8864d93f
pytest-cov>=2.4.0,<2.6
pytest-faulthandler
pytest-ignore-flaky

0 comments on commit 64c02c3

Please sign in to comment.