Skip to content

Commit

Permalink
Merge pull request #165 from Autodesk/deploy
Browse files Browse the repository at this point in the history
Deploy 0.8.0beta2
  • Loading branch information
avirshup authored Jun 19, 2017
2 parents b15a84e + 65ba58f commit 939ed29
Show file tree
Hide file tree
Showing 43 changed files with 1,021 additions and 1,031 deletions.
2 changes: 1 addition & 1 deletion deployment/codeship_runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
set -e

VERSION="${TESTENV}.py${PYVERSION}"
PYTESTFLAGS="-n 6 --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=1800"
PYTESTFLAGS="-n 5 --durations=20 --junit-xml=/opt/reports/junit.${VERSION}.xml --timeout=1800 --tb=short"
if [ "${VERSION}" == "complete.py3" ]; then
PYTESTFLAGS="--cov moldesign ${PYTESTFLAGS}"
fi
Expand Down
25 changes: 20 additions & 5 deletions deployment/send_test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@

import github

status = {'0':'success', 'na':'pending'}.get(sys.argv[1], 'failure')
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('exitcode', type=str)
parser.add_argument('msg', type=str)
parser.add_argument('--deployed', action='store_true')
args = parser.parse_args()

status = {'0':'success', 'na':'pending'}.get(args.exitcode, 'failure')

missing_env = []
for key in 'CI_COMMIT_ID TESTENV GITHUB_REPO_TOKEN CI_PROJECT_ID CI_BUILD_ID PYVERSION'.split():
Expand All @@ -28,15 +36,22 @@
data = dict(state=status,
target_url='https://app.codeship.com/projects/%s/builds/%s' %
(projid, buildid),
description=" ".join(sys.argv[2:]).replace("=","").strip(),
description=args.msg.replace("=","").strip(),
context='%s/py%s' % (testenv, pyversion))


if missing_env:
print("Not sending status update b/c of missing env vars: %s" % ','.join(missing_env))
print(data)
sys.exit(0)


g = github.Github(ghtoken)
repo = g.get_repo('autodesk/molecular-design-toolkit')
commit = repo.get_commit(sha)

if args.deployed:
raise NotImplementedError
else:
g = github.Github(ghtoken)
repo = g.get_repo('autodesk/molecular-design-toolkit')
commit = repo.get_commit(sha)
commit.create_status(**data)

368 changes: 44 additions & 324 deletions moldesign/_notebooks/Tutorial 1. Making a molecule.ipynb

Large diffs are not rendered by default.

404 changes: 45 additions & 359 deletions moldesign/_notebooks/Tutorial 2. Biochemical basics.ipynb

Large diffs are not rendered by default.

39 changes: 37 additions & 2 deletions moldesign/_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def native_str_buffer(*args, **kwargs):
return io.StringIO(*args, **kwargs)



class ZeroEnergy(mdt.models.base.EnergyModelBase):
""" All 0, all the time
"""
Expand All @@ -84,10 +83,46 @@ def _internet(host="8.8.8.8", port=53, timeout=3):
"""
try:
socket.setdefaulttimeout(timeout)
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
try:
socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
except OSError:
return False
return True
except Exception as ex:
print(ex.message)
return False

INTERNET_ON = _internet()


def assert_something_resembling_minimization_happened(p0, e0, traj, mol):
""" Raises assertion error if results do not correspond to a successful optimization
Args:
p0 (Array[length]): initial position array
e0 (Scalar[energy]): initial energy
traj (moldesign.Trajectory): trajectory created from minimization
mol (moldesign.Molecule): state of molecule AFTER minimization
Returns:
"""
import scipy.optimize.optimize

assert traj.num_frames > 1

assert traj.potential_energy[0] == e0
assert traj.potential_energy[-1] < e0
assert traj.potential_energy[-1] == mol.potential_energy

assert (traj.positions[0] == p0).all()
assert (traj.positions[-1] != p0).any()
assert (traj.positions[-1] == mol.positions).all()

scipyresult = getattr(traj, 'info', None)
if isinstance(scipyresult, scipy.optimize.optimize.OptimizeResult):
np.testing.assert_allclose(scipyresult.x,
mol.positions.defunits_value().flat)
np.testing.assert_almost_equal(scipyresult.fun,
mol.potential_energy.defunits_value())

7 changes: 7 additions & 0 deletions moldesign/_tests/molecule_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def ligand3aid(ligand_residue_3aid):
return newmol


@typedfixture('molecule')
def ethylene_waterbox_2na_2cl():
mol = mdt.from_smiles('C=C')
solvated = mdt.add_water(mol, padding=15.0*u.angstrom, ion_concentration=0.6*u.molar)
return solvated


@pytest.fixture
def random_atoms_from_3aid(pdb3aid):
atoms = mdt.molecules.atomcollections.AtomList(random.sample(pdb3aid.atoms, 10))
Expand Down
44 changes: 44 additions & 0 deletions moldesign/_tests/test_atom_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from moldesign import units as u

from . import helpers
from .molecule_fixtures import pdb3aid, ethylene_waterbox_2na_2cl


registered_types = {}
Expand Down Expand Up @@ -234,3 +235,46 @@ def test_get_atoms(protein):
assert (atom.name == 'CA' and atom.residue.resname == 'GLY') == (
atom in gly_alpha_carbons)


def test_get_atoms_keywords(ethylene_waterbox_2na_2cl):
mol = ethylene_waterbox_2na_2cl
with pytest.raises(ValueError):
mol.get_atoms('arglebargle')

with pytest.raises(ValueError):
mol.get_atoms('ions') # it's "ion" only (for now)

ions = mol.get_atoms('ion')
assert ions.num_atoms == 4
for ion in ions:
assert ion.residue.resname in ('NA','CL') and ion.name in ('Na','Cl')

waters = mol.get_atoms('water')
for w in waters:
assert w.residue.resname == 'HOH'

solute = mol.get_atoms('unknown')
assert len(solute) == 6

assert len(waters) + len(ions) + len(solute) == mol.num_atoms


def test_get_residues_in_molecule(pdb3aid):
mol = pdb3aid
waters = mol.get_residues(type='water')
assert set(waters) == set(res for res in mol.residues if res.resname == 'HOH')


def test_get_residues_in_chain(pdb3aid):
mol = pdb3aid
chain = mol.chains['A']
waters = chain.get_residues(type='water')
assert set(waters) == set(res for res in mol.chains['A'].residues if res.resname == 'HOH')


def test_get_residues_two_parameters(pdb3aid):
mol = pdb3aid
alas = mol.chains['B'].get_residues(resname='ALA')
assert set(alas) == set(res for res in mol.chains['B'].residues if res.resname == 'ALA')
ala2 = mol.get_residues(resname='ALA', chain='B')
assert set(ala2) == set(alas)
21 changes: 21 additions & 0 deletions moldesign/_tests/test_biopython_xface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import pytest
import Bio.PDB
import moldesign as mdt

from .helpers import get_data_path
from .molecule_fixtures import pdb3aid


@pytest.fixture
def biopy_3aid():
parser = Bio.PDB.PDBParser()
structure = parser.get_structure('3aid', get_data_path('3aid.pdb'))
return structure


def test_biopy_to_mdt(biopy_3aid, pdb3aid):
mol = mdt.interfaces.biopython_to_mol(biopy_3aid)
assert mol.num_atoms == pdb3aid.num_atoms
assert mol.num_residues == pdb3aid.num_residues
assert mol.numchains == pdb3aid.num_chains
20 changes: 0 additions & 20 deletions moldesign/_tests/test_dynamics.py

This file was deleted.

1 change: 1 addition & 0 deletions moldesign/_tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys


@pytest.mark.tryfirst
def test_lazy_imports():
import moldesign

Expand Down
Loading

0 comments on commit 939ed29

Please sign in to comment.