-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/openforcefield/smirnoff99…
…Frosst into hydrogen_typo
- Loading branch information
Showing
19 changed files
with
2,774 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
language: python | ||
|
||
# Run jobs on container-based infrastructure, can be overridden per job | ||
|
||
matrix: | ||
include: | ||
# Extra includes for OSX since python language is not available by default on OSX | ||
- os: osx | ||
language: generic | ||
env: PYTHON_VER=3.6 | ||
- os: osx | ||
language: generic | ||
env: PYTHON_VER=3.7 | ||
|
||
|
||
- os: linux | ||
language: generic # No need to set Python version since its conda | ||
env: PYTHON_VER=3.6 | ||
- os: linux | ||
language: generic | ||
env: PYTHON_VER=3.7 | ||
|
||
|
||
before_install: | ||
# Additional info about the build | ||
- uname -a | ||
- df -h | ||
- ulimit -a | ||
|
||
# Install the Python environment | ||
- source devtools/travis-ci/before_install.sh | ||
- python -V | ||
|
||
install: | ||
|
||
# Create test environment for package | ||
- python devtools/scripts/create_conda_env.py -n=test -p=$PYTHON_VER devtools/conda-envs/test_env.yaml | ||
# Activate the test environment | ||
- conda activate test | ||
# Build and install package | ||
- python setup.py develop --no-deps | ||
|
||
|
||
script: | ||
- pytest -v smirnoff99Frosst/tests/ | ||
|
||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Development, testing, and deployment tools | ||
|
||
This directory contains a collection of tools for running Continuous Integration (CI) tests, | ||
conda installation, and other development tools not directly related to the coding process. | ||
|
||
|
||
## Manifest | ||
|
||
### Continuous Integration | ||
|
||
* `travis-ci`: Linux and OSX based testing through [Travis-CI](https://about.travis-ci.com/) | ||
* `before_install.sh`: Pip/Miniconda pre-package installation script for Travis | ||
|
||
### Conda Environment: | ||
|
||
This directory contains the files to setup the Conda environment for testing purposes | ||
|
||
* `conda-envs`: directory containing the YAML file(s) which fully describe Conda Environments, their dependencies, and those dependency provenance's | ||
* `test_env.yaml`: Simple test environment file with base dependencies. Channels are not specified here and therefore respect global Conda configuration | ||
|
||
### Additional Scripts: | ||
|
||
This directory contains OS agnostic helper scripts which don't fall in any of the previous categories | ||
* `scripts` | ||
* `create_conda_env.py`: Helper program for spinning up new conda environments based on a starter file with Python Version and Env. Name command-line options | ||
|
||
|
||
## How to contribute changes | ||
- Clone the repository if you have write access to the main repo, fork the repository if you are a collaborator. | ||
- Make a new branch with `git checkout -b {your branch name}` | ||
- Make changes and test your code | ||
- Ensure that the test environment dependencies (`conda-envs`) line up with the build and deploy dependencies (`conda-recipe/meta.yaml`) | ||
- Push the branch to the repo (either the main or your fork) with `git push -u origin {your branch name}` | ||
* Note that `origin` is the default name assigned to the remote, yours may be different | ||
- Make a PR on GitHub with your changes | ||
- We'll review the changes and get your code into the repo after lively discussion! | ||
|
||
|
||
## Checklist for updates | ||
- [ ] Make sure there is an/are issue(s) opened for your specific update | ||
- [ ] Create the PR, referencing the issue | ||
- [ ] Debug the PR as needed until tests pass | ||
- [ ] Tag the final, debugged version | ||
* `git tag -a X.Y.Z [latest pushed commit] && git push --follow-tags` | ||
- [ ] Get the PR merged in | ||
|
||
## Versioneer Auto-version | ||
[Versioneer](https://github.com/warner/python-versioneer) will automatically infer what version | ||
is installed by looking at the `git` tags and how many commits ahead this version is. The format follows | ||
[PEP 440](https://www.python.org/dev/peps/pep-0440/) and has the regular expression of: | ||
```regexp | ||
\d+.\d+.\d+(?\+\d+-[a-z0-9]+) | ||
``` | ||
If the version of this commit is the same as a `git` tag, the installed version is the same as the tag, | ||
e.g. `smirnoff99Frosst-0.1.2`, otherwise it will be appended with `+X` where `X` is the number of commits | ||
ahead from the last tag, and then `-YYYYYY` where the `Y`'s are replaced with the `git` commit hash. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: test | ||
|
||
channels: | ||
- conda-forge | ||
- omnia | ||
|
||
dependencies: | ||
# Base depends | ||
- python | ||
- pip | ||
|
||
# Testing | ||
- pytest | ||
|
||
# Standard dependencies | ||
- openforcefield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 -n {} -f {}".format(conda_path, args.name, temp_file_name), shell=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Temporarily change directory to $HOME to install software | ||
pushd . | ||
cd $HOME | ||
# Make sure some level of pip is installed | ||
python -m ensurepip | ||
|
||
# Install Miniconda | ||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then | ||
# Make OSX md5 mimic md5sum from linux, alias does not work | ||
md5sum () { | ||
command md5 -r "$@" | ||
} | ||
MINICONDA=Miniconda3-latest-MacOSX-x86_64.sh | ||
else | ||
MINICONDA=Miniconda3-latest-Linux-x86_64.sh | ||
fi | ||
MINICONDA_HOME=$HOME/miniconda | ||
MINICONDA_MD5=$(curl -s https://repo.continuum.io/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *<td>\(.*\)<\/td> */\1/p') | ||
wget -q https://repo.continuum.io/miniconda/$MINICONDA | ||
if [[ $MINICONDA_MD5 != $(md5sum $MINICONDA | cut -d ' ' -f 1) ]]; then | ||
echo "Miniconda MD5 mismatch" | ||
exit 1 | ||
fi | ||
bash $MINICONDA -b -p $MINICONDA_HOME | ||
|
||
# Configure miniconda | ||
export PIP_ARGS="-U" | ||
# New to conda >=4.4 | ||
echo ". $MINICONDA_HOME/etc/profile.d/conda.sh" >> ~/.bashrc # Source the profile.d file | ||
echo "conda activate" >> ~/.bashrc # Activate conda | ||
source ~/.bashrc # source file to get new commands | ||
#export PATH=$MINICONDA_HOME/bin:$PATH # Old way, should not be needed anymore | ||
|
||
conda config --add channels omnia --add channels conda-forge | ||
|
||
conda config --set always_yes yes | ||
conda install conda conda-build jinja2 anaconda-client | ||
conda update --quiet --all | ||
|
||
# Restore original directory | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Helper file to handle all configs | ||
|
||
[coverage:run] | ||
# .coveragerc to control coverage.py and pytest-cov | ||
omit = | ||
# Omit the tests | ||
*/tests/* | ||
# Omit generated versioneer | ||
smirnoff99Frosst/_version.py | ||
|
||
[yapf] | ||
# YAPF, in .style.yapf files this shows up as "[style]" header | ||
COLUMN_LIMIT = 119 | ||
INDENT_WIDTH = 4 | ||
USE_TABS = False | ||
|
||
[flake8] | ||
# Flake8, PyFlakes, etc | ||
max-line-length = 119 | ||
|
||
[versioneer] | ||
# Automatic version numbering scheme | ||
VCS = git | ||
style = pep440 | ||
versionfile_source = smirnoff99Frosst/_version.py | ||
versionfile_build = smirnoff99Frosst/_version.py | ||
tag_prefix = '' | ||
|
||
[aliases] | ||
test = pytest |
Oops, something went wrong.