Skip to content

Commit

Permalink
Merge pull request #297 from choderalab/fix-warnings
Browse files Browse the repository at this point in the history
Fix warnings with bondtype
  • Loading branch information
jchodera committed Feb 15, 2020
2 parents d536e14 + 675521a commit 50be07a
Show file tree
Hide file tree
Showing 11 changed files with 279 additions and 98 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: CI

on:
pull_request:
schedule:
# nightly tests
- cron: '0 0 * * *'

jobs:
test:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
cfg:
- {python-version: 3.6, openmm: "latest"}
- {python-version: 3.7, openmm: "latest"}
- {python-version: 3.7, openmm: "beta"}
- {python-version: 3.7, openmm: "nightly"}
- {python-version: 3.7, openmm: "conda-forge"}

env:
ORGNAME: omnia
PACKAGENAME: openmoltools
OE_LICENSE: $HOME/oe_license.txt
CI_OS: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
- name: Configure conda
shell: bash
run: |
. devtools/github-actions/initialize_conda.sh
conda activate
conda config --set always_yes True
conda config --add channels conda-forge
conda config --add channels omnia
conda config --add channels openeye
conda update --quiet --all
conda install --quiet conda conda-build jinja2 anaconda-client
conda info
conda list
- name: Decrypt OpenEye license
shell: bash
env:
ENC_OE_LICENSE: ${{ secrets.ENC_OE_LICENSE }}
run: |
echo "${ENC_OE_LICENSE}" > $HOME/oe_license.txt
- name: Create environment for package
shell: bash
run: |
. devtools/github-actions/initialize_conda.sh
conda activate
conda info
python devtools/scripts/create_conda_env.py -n=test -p=$PYVER devtools/conda-envs/test_env.yaml
- name: Install package
shell: bash
run: |
. devtools/github-actions/initialize_conda.sh
conda activate test
python -m pip install . --no-deps
conda list --show-channel-urls
- name: Prepare test environment
shell: bash
run: |
. devtools/github-actions/initialize_conda.sh
conda activate test
case ${{ matrix.cfg.openmm }} in
latest)
echo "Using latest release OpenMM."
conda install --quiet -c omnia openmm;;
beta)
echo "Using OpenMM beta"
conda install --quiet -c omnia/label/beta openmm;;
nightly)
echo "Using OpenMM nightly dev build."
conda install --quiet -c omnia-dev openmm;;
conda-forge)
echo "Using OpenMM conda-forge testing build."
conda install --quiet -c conda-forge/label/testing openmm;;
esac
- name: Test the package
shell: bash
run: |
. devtools/github-actions/initialize_conda.sh
conda activate test
export OE_LICENSE="$HOME/oe_license.txt"
export TRAVIS=true
pushd .
nosetests ${PACKAGENAME}/tests/test_forcefield_generators.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_amber.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_utils.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_gromacs.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_openeye.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_freesolv.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_drugs.py --nocapture --verbosity=3 --with-timer -a '!advanced'
nosetests ${PACKAGENAME}/tests/test_common_molecules.py --nocapture --verbosity=3 --with-timer -a '!advanced'
popd
- name: Deploy
shell: bash
if: false
run: |
echo "Deployment has not been implemented yet"
75 changes: 0 additions & 75 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://travis-ci.org/choderalab/openmoltools.svg?branch=master)](https://travis-ci.org/choderalab/openmoltools)
[![GH Actions Status](https://github.com/choderalab/perses/workflows/CI/badge.svg)](https://github.com/choderalab/perses/actions?query=branch%3Amaster)

## openmoltools: Tools for Small Molecules, Antechamber, OpenMM, and More.

Expand Down Expand Up @@ -40,8 +41,7 @@ nosetests openmoltools -v --exe
## Python 2.7 builds are deprecated

Version 0.8.3 will be the last version of this package to build with Python 2.7.
With the OpenEye toolkits no longer being depolyed on Python 2.7 as of 2018.2.1,
we have decided to deprecate support for that Python version as well.
Version 0.8.3 was tested against the 2017.10.1 version of the OpenEye Toolkits for
With the OpenEye toolkits no longer being depolyed on Python 2.7 as of 2018.2.1,
we have decided to deprecate support for that Python version as well.
Version 0.8.3 was tested against the 2017.10.1 version of the OpenEye Toolkits for
compatibility.

34 changes: 34 additions & 0 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: test
channels:
- conda-forge
- omnia
- openeye
dependencies:
# Base depends
- python
- pip
- setuptools
- pandas
- six
- mdtraj
- lxml
- pymbar
- numpy
- numpydoc
- scipy
- openmm
- ambertools >=19.0
- pytables
- openmmtools
- packmol
- rdkit # optional dependency
- openeye-toolkits # optional dependency

# Testing
- nose
- nose-timer
- pytest
- pytest-cov
# Pip-only installs
- pip:
- codecov
19 changes: 12 additions & 7 deletions devtools/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ requirements:
- pandas
- six
- mdtraj
- lxml
- pymbar
- numpy
- numpydoc
- scipy
- openmm
- ambermini
- ambertools >=19
- pytables
- parmed
- rdkit # rdkit is an optional dependency, may want to comment this out for the release version.
- openmmtools
- packmol
- rdkit # optional dependency
- openeye-toolkits # optional dependency
run:
- python
- setuptools
Expand All @@ -36,15 +40,16 @@ requirements:
- numpydoc
- scipy
- openmm
- ambermini
- ambertools >=19
- pytables
- parmed
- rdkit # rdkit is an optional dependency, may want to comment this out for the release version.
- openmmtools
- packmol
- rdkit # optional dependency
- openeye-toolkits # optional dependency

test:
requires:
- nose
- openmmtools
imports:
- openmoltools
#commands:
Expand Down
8 changes: 8 additions & 0 deletions devtools/github-actions/initialize_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# $CI_OS is $matrix.os, as exported in GHA *.yaml
# $CONDA (miniconda installation path) is always defined in the GHA virtual environments
case ${CI_OS} in
windows*)
eval "$(${CONDA}/condabin/conda.bat shell.bash hook)";;
*)
eval "$(${CONDA}/condabin/conda shell.bash hook)";;
esac
95 changes: 95 additions & 0 deletions devtools/scripts/create_conda_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import argparse
import os
import re
import glob
import shutil
import subprocess as sp
from tempfile import TemporaryDirectory
from contextlib import contextmanager
# YAML imports
try:
import yaml # PyYAML
loader = yaml.load
except ImportError:
try:
import ruamel_yaml as yaml # Ruamel YAML
except ImportError:
try:
# Load Ruamel YAML from the base conda environment
from importlib import util as import_util
CONDA_BIN = os.path.dirname(os.environ['CONDA_EXE'])
ruamel_yaml_path = glob.glob(os.path.join(CONDA_BIN, '..',
'lib', 'python*.*', 'site-packages',
'ruamel_yaml', '__init__.py'))[0]
# Based on importlib example, but only needs to load_module since its the whole package, not just
# a module
spec = import_util.spec_from_file_location('ruamel_yaml', ruamel_yaml_path)
yaml = spec.loader.load_module()
except (KeyError, ImportError, IndexError):
raise ImportError("No YAML parser could be found in this or the conda environment. "
"Could not find PyYAML or Ruamel YAML in the current environment, "
"AND could not find Ruamel YAML in the base conda environment through CONDA_EXE path. "
"Environment not created!")
loader = yaml.YAML(typ="safe").load # typ="safe" avoids odd typing on output


@contextmanager
def temp_cd():
"""Temporary CD Helper"""
cwd = os.getcwd()
with TemporaryDirectory() as td:
try:
os.chdir(td)
yield
finally:
os.chdir(cwd)


# Args
parser = argparse.ArgumentParser(description='Creates a conda environment from file for a given Python version.')
parser.add_argument('-n', '--name', type=str,
help='The name of the created Python environment')
parser.add_argument('-p', '--python', type=str,
help='The version of the created Python environment')
parser.add_argument('conda_file',
help='The file for the created Python environment')

args = parser.parse_args()

# Open the base file
with open(args.conda_file, "r") as handle:
yaml_script = loader(handle.read())

python_replacement_string = "python {}*".format(args.python)

try:
for dep_index, dep_value in enumerate(yaml_script['dependencies']):
if re.match('python([ ><=*]+[0-9.*]*)?$', dep_value): # Match explicitly 'python' and its formats
yaml_script['dependencies'].pop(dep_index)
break # Making the assumption there is only one Python entry, also avoids need to enumerate in reverse
except (KeyError, TypeError):
# Case of no dependencies key, or dependencies: None
yaml_script['dependencies'] = []
finally:
# Ensure the python version is added in. Even if the code does not need it, we assume the env does
yaml_script['dependencies'].insert(0, python_replacement_string)

# Figure out conda path
if "CONDA_EXE" in os.environ:
conda_path = os.environ["CONDA_EXE"]
else:
conda_path = shutil.which("conda")
if conda_path is None:
raise RuntimeError("Could not find a conda binary in CONDA_EXE variable or in executable search path")

print("CONDA ENV NAME {}".format(args.name))
print("PYTHON VERSION {}".format(args.python))
print("CONDA FILE NAME {}".format(args.conda_file))
print("CONDA PATH {}".format(conda_path))

# Write to a temp directory which will always be cleaned up
with temp_cd():
temp_file_name = "temp_script.yaml"
with open(temp_file_name, 'w') as f:
f.write(yaml.dump(yaml_script))
sp.call("{} env create --quiet -n {} -f {}".format(conda_path, args.name, temp_file_name), shell=True)
Loading

0 comments on commit 50be07a

Please sign in to comment.