Skip to content

Commit

Permalink
Add conda enviornment. Swith Travis to use environment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dhimmel committed May 3, 2018
1 parent 0e880f6 commit 2161e25
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 70 deletions.
49 changes: 16 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@

dist: trusty
sudo: false # to use container-based infra, see: http://docs.travis-ci.com/user/migrating-from-legacy/

language:
- python
python:
- "2.7"
- "3.6"
language: generic
env:
matrix:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.6
jdk:
- oraclejdk8

cache:
directories:
- download
- $HOME/.cache/pip
- $HOME/miniconda/envs/test # to avoid repetitively setting up Ana/Miniconda environment
- parser # to avoid repetitively downloading CoreNLP

addons:
Expand All @@ -30,20 +27,14 @@ addons:
# See: https://github.com/Theano/Theano/blob/master/.travis.yml (for caching)
# See: http://conda.pydata.org/docs/travis.html
before_install:
- deactivate # leaving Travis' virtualenv first since otherwise Jupyter/IPython gets confused with conda inside a virtualenv (See: https://github.com/ipython/ipython/issues/8898)
- mkdir -p download
- cd download
- rm -rf ~/miniconda
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
travis_retry wget -c https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
travis_retry wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- chmod +x miniconda.sh
- bash miniconda.sh -b -f -p ~/miniconda
- cd ..
- export PATH=~/miniconda/bin:$PATH
- conda update --yes conda
- travis_retry
wget https://repo.continuum.io/miniconda/Miniconda3-4.5.1-Linux-x86_64.sh
--output-document=miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- source $HOME/miniconda/etc/profile.d/conda.sh
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda info --all

# Make sure Java 8 is used
- export PATH="/usr/lib/jvm/java-8-oracle/bin:$PATH"
Expand All @@ -54,22 +45,14 @@ before_install:
- source set_env.sh

install:
# Install binary distribution of scientific python modules
- test -e ~/miniconda/envs/test/bin/activate || ( rm -rf ~/miniconda/envs/test; conda create --yes -n test python=$TRAVIS_PYTHON_VERSION )
- source activate test
- conda install --yes numpy scipy matplotlib pip

# Install Numba
- conda install --yes numba
- sed --in-place 's/- python/- python='"$PYTHON_VERSION"'/' environment.yml
- conda env create --quiet --file=environment.yml
- conda activate snorkel

# Install all remaining dependencies as per our README
- pip install --requirement python-package-requirement.txt
- pip install .
- test -e parser/corenlp.sh || ./install-parser.sh

# Use runipy to run Jupyter/IPython notebooks from command-line
- pip install runipy

script:

# Run test modules
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,31 @@ source activate py2Env

### Installing dependencies

First install [NUMBA](https://numba.pydata.org/), a package for high-performance numeric computing in Python via Conda:
This repository uses [conda](http://conda.pydata.org/docs/) to manage its environment as specified in [`environment.yml`](environment.yml).
For Snorkel development, clone this repository and install the environment using:

```bash
conda install numba
```
```sh
# From the root direcectory of this repo run the following command.
conda env create --file=environment.yml

# Activate the conda environment (if using a version of conda below 4.4, use "source" instead of "conda")
conda activate snorkel

Then install the remaining package requirements:
# Install snorkel in development mode
pip install --editable .
```

```bash
# Install requirements
pip install --requirement python-package-requirement.txt
TODO reconcile below

```
# Install snorkel from GitHub
pip install git+https://github.com/HazyResearch/treedlib@master
pip install git+https://github.com/HazyResearch/snorkel@master
# Alternatively, you can install snorkel for development, by running the
# following command from within a snorkel repo clone
pip install --editable .
```

Finally, enable `ipywidgets`:

```bash
jupyter nbextension enable --py widgetsnbextension --sys-prefix
```

_Note: If you are using conda and experience issues with `lxml`, try running `conda install libxml2`._

_Note: Currently the `Viewer` is supported on the following versions:_
Expand Down
27 changes: 27 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: snorkel
channels:
- conda-forge
dependencies:
- beautifulsoup4
- ipywidgets>=7.0
- jupyter
- lxml
- matplotlib
- nltk
- numba
- numpy>=1.11
- pandas
- psycopg2
- py4j
- python
- requests
- runipy
- scipy
- six
- sqlalchemy>=1.0.14
- tensorflow>=1.0
- tika
- pip:
- git+https://github.com/HazyResearch/numbskull@master
- git+https://github.com/HazyResearch/treedlib@master
- spacy==1.10.0
22 changes: 0 additions & 22 deletions python-package-requirement.txt

This file was deleted.

0 comments on commit 2161e25

Please sign in to comment.