Skip to content

Commit a76c0c0

Browse files
authored
Merge pull request #187 from ocefpaf/R_env
Single env for Python and R kernels
2 parents 29f3f50 + 784fa0a commit a76c0c0

File tree

7 files changed

+108
-123
lines changed

7 files changed

+108
-123
lines changed

.travis.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ matrix:
2424
env: TEST_TARGET=notebooks_python3 ENV_NAME="IOOS3" ENV="environment.yml"
2525

2626
before_install:
27-
- if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then
27+
- if [ $TRAVIS_PULL_REQUEST == 'false' ]; then
2828
openssl aes-256-cbc -K $encrypted_2ed57bb9ae7e_key -iv $encrypted_2ed57bb9ae7e_iv -in deploy_key.enc -out deploy_key -d ;
2929
fi
30-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" ; fi
31-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" ; fi
30+
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh" ; fi
31+
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then URL="https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" ; fi
3232
# GUI (R png figures).
33-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0 ; sh -e /etc/init.d/xvfb start ; fi
33+
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export DISPLAY=:99.0 ; sh -e /etc/init.d/xvfb start ; fi
3434
- wget $URL -O miniconda.sh
3535
- bash miniconda.sh -b -p $HOME/miniconda
3636
- export PATH="$HOME/miniconda/bin:$PATH"
@@ -53,23 +53,23 @@ script:
5353
# E226: missing whitespace around arithmetic operator (not enforced by PEP 8)
5454
# E402: module level import not at top of file (in notebooks it is clearer to import in the first cell the module is used.)
5555
# In addition the magic cells are skipped with `grep -v '^get_ipython'` b/c they are not compliant when converted to script.
56-
- if [[ $TEST_TARGET == 'coding_standards' ]]; then
56+
- if [ $TEST_TARGET == 'coding_standards' ]; then
5757
find . -type f -name "*.py" ! -name "conf.py" | xargs flake8 --max-line-length=100 ;
5858
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 ;
5959
fi
60-
# The notebook test runs the blog notebooks.
61-
- if [[ $TEST_TARGET == 'notebooks_python3' ]]; then
60+
# Test the blog notebook.
61+
- if [ $TEST_TARGET == 'notebooks_python3' ]; then
6262
cd tests && python test_notebooks.py ;
6363
fi
64-
- if [[ $TEST_TARGET == 'notebooks_python2' ]]; then
64+
- if [ $TEST_TARGET == 'notebooks_python2' ]; then
6565
cd tests && python test_notebooks.py ;
6666
fi
67-
# Staged notebooks are the notebooks that are not in the blog yet.
68-
- if [[ $TEST_TARGET == 'staged_notebooks' ]]; then
67+
# Test the staged notebooks.
68+
- if [ $TEST_TARGET == 'staged_notebooks' ]; then
6969
cd tests && python test_staged_notebooks.py ;
7070
fi
71-
# Publish the converted notebooks.
72-
- if [[ $TEST_TARGET == 'publish' ]]; then
71+
# Publish the notebooks.
72+
- if [ $TEST_TARGET == 'publish' ]; then
7373
cd webpage && python make_index.py && cd ..;
7474
find notebooks/ -maxdepth 1 -name \*.ipynb -print0 | xargs -0 -n1 jupyter nbconvert --to=markdown --template="jupyter-jekyll.tpl" --output-dir=webpage/_notebooks ;
7575
bash webpage/deploy.sh ;

environment-python-2.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ dependencies:
7070
- thredds_crawler
7171
- xarray
7272
- xlrd
73+
# R packages.
74+
- r-irkernel
75+
- r-oce
76+
- r-gsw

environment-r.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

environment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ dependencies:
7070
- thredds_crawler
7171
- xarray
7272
- xlrd
73+
# R packages.
74+
- r-irkernel
75+
- r-oce
76+
- r-gsw

notebooks/2016-12-22-boston_light_swim.ipynb

Lines changed: 34 additions & 80 deletions
Large diffs are not rendered by default.

notebooks/2017-01-23-R-notebook.ipynb

Lines changed: 46 additions & 16 deletions
Large diffs are not rendered by default.

tests/test_notebooks.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from nbconvert.exporters import Exporter, HTMLExporter
1212

1313

14-
def notebook_tester(fname):
14+
def notebook_tester(fname, kernelspec='python'):
1515
raw_nb = Exporter().from_filename(fname)
16-
raw_nb[0].metadata.setdefault('kernelspec', {})['name'] = 'python'
16+
raw_nb[0].metadata.setdefault('kernelspec', {})['name'] = kernelspec
1717
preproc = ExecutePreprocessor(timeout=-1)
1818
try:
1919
exec_nb = preproc.preprocess(*raw_nb)
@@ -39,8 +39,12 @@ def notebook_tester(fname):
3939
for ipynb in sorted(nblist):
4040
print('[Running notebook]: {}'.format(ipynb))
4141
if '2017-01-23-R-notebook.ipynb' in ipynb:
42-
continue
43-
ret = notebook_tester(ipynb)
42+
kernelspec = 'ir'
43+
print('Kernel: R')
44+
else:
45+
kernelspec = 'python'
46+
print('Kernel: python')
47+
ret = notebook_tester(ipynb, kernelspec=kernelspec )
4448
if 'Failed' in ret:
4549
fail = True
4650
print('{}\n'.format(ret))

0 commit comments

Comments
 (0)