Skip to content

Commit

Permalink
Merge pull request #187 from ocefpaf/R_env
Browse files Browse the repository at this point in the history
Single env for Python and R kernels
  • Loading branch information
ocefpaf authored Feb 19, 2017
2 parents 29f3f50 + 784fa0a commit a76c0c0
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 123 deletions.
24 changes: 12 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ matrix:
env: TEST_TARGET=notebooks_python3 ENV_NAME="IOOS3" ENV="environment.yml"

before_install:
- if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then
- if [ $TRAVIS_PULL_REQUEST == 'false' ]; then
openssl aes-256-cbc -K $encrypted_2ed57bb9ae7e_key -iv $encrypted_2ed57bb9ae7e_iv -in deploy_key.enc -out deploy_key -d ;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" ; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" ; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" ; fi
# GUI (R png figures).
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0 ; sh -e /etc/init.d/xvfb start ; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export DISPLAY=:99.0 ; sh -e /etc/init.d/xvfb start ; fi
- wget $URL -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
Expand All @@ -53,23 +53,23 @@ script:
# E226: missing whitespace around arithmetic operator (not enforced by PEP 8)
# E402: module level import not at top of file (in notebooks it is clearer to import in the first cell the module is used.)
# In addition the magic cells are skipped with `grep -v '^get_ipython'` b/c they are not compliant when converted to script.
- if [[ $TEST_TARGET == 'coding_standards' ]]; then
- if [ $TEST_TARGET == 'coding_standards' ]; then
find . -type f -name "*.py" ! -name "conf.py" | xargs flake8 --max-line-length=100 ;
for file in $(find . -type f -name "*.ipynb" ! -name "2017-01-23-R-notebook.ipynb" ); do jupyter nbconvert --template=tests/strip_markdown.tpl --stdout --to python $file | grep -v '^get_ipython' | flake8 - --ignore=W391,E226,E402 --max-line-length=100 --show-source ; done ;
fi
# The notebook test runs the blog notebooks.
- if [[ $TEST_TARGET == 'notebooks_python3' ]]; then
# Test the blog notebook.
- if [ $TEST_TARGET == 'notebooks_python3' ]; then
cd tests && python test_notebooks.py ;
fi
- if [[ $TEST_TARGET == 'notebooks_python2' ]]; then
- if [ $TEST_TARGET == 'notebooks_python2' ]; then
cd tests && python test_notebooks.py ;
fi
# Staged notebooks are the notebooks that are not in the blog yet.
- if [[ $TEST_TARGET == 'staged_notebooks' ]]; then
# Test the staged notebooks.
- if [ $TEST_TARGET == 'staged_notebooks' ]; then
cd tests && python test_staged_notebooks.py ;
fi
# Publish the converted notebooks.
- if [[ $TEST_TARGET == 'publish' ]]; then
# Publish the notebooks.
- if [ $TEST_TARGET == 'publish' ]; then
cd webpage && python make_index.py && cd ..;
find notebooks/ -maxdepth 1 -name \*.ipynb -print0 | xargs -0 -n1 jupyter nbconvert --to=markdown --template="jupyter-jekyll.tpl" --output-dir=webpage/_notebooks ;
bash webpage/deploy.sh ;
Expand Down
4 changes: 4 additions & 0 deletions environment-python-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ dependencies:
- thredds_crawler
- xarray
- xlrd
# R packages.
- r-irkernel
- r-oce
- r-gsw
11 changes: 0 additions & 11 deletions environment-r.yml

This file was deleted.

4 changes: 4 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ dependencies:
- thredds_crawler
- xarray
- xlrd
# R packages.
- r-irkernel
- r-oce
- r-gsw
114 changes: 34 additions & 80 deletions notebooks/2016-12-22-boston_light_swim.ipynb

Large diffs are not rendered by default.

62 changes: 46 additions & 16 deletions notebooks/2017-01-23-R-notebook.ipynb

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions tests/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from nbconvert.exporters import Exporter, HTMLExporter


def notebook_tester(fname):
def notebook_tester(fname, kernelspec='python'):
raw_nb = Exporter().from_filename(fname)
raw_nb[0].metadata.setdefault('kernelspec', {})['name'] = 'python'
raw_nb[0].metadata.setdefault('kernelspec', {})['name'] = kernelspec
preproc = ExecutePreprocessor(timeout=-1)
try:
exec_nb = preproc.preprocess(*raw_nb)
Expand All @@ -39,8 +39,12 @@ def notebook_tester(fname):
for ipynb in sorted(nblist):
print('[Running notebook]: {}'.format(ipynb))
if '2017-01-23-R-notebook.ipynb' in ipynb:
continue
ret = notebook_tester(ipynb)
kernelspec = 'ir'
print('Kernel: R')
else:
kernelspec = 'python'
print('Kernel: python')
ret = notebook_tester(ipynb, kernelspec=kernelspec )
if 'Failed' in ret:
fail = True
print('{}\n'.format(ret))
Expand Down

0 comments on commit a76c0c0

Please sign in to comment.