Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 61f75d8

Browse files
committed
first pass jupyter js test on CI:
- add node.js to CI machine - add PLOTLY_JUPYTER_TEST_DIR env variable - make sure to `npm i` there - add jupyter and ipykernel to optional requirements - make sure to add kernel to jupyter list - preprocess NB using that kernel
1 parent 67d405a commit 61f75d8

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

circle.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ machine:
77
PLOTLY_PYTHON_VERSIONS: 2.7.8 3.3.3 3.4.1
88
PLOTLY_CORE_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/requirements.txt
99
PLOTLY_OPTIONAL_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/optional-requirements.txt
10+
PLOTLY_JUPYTER_TEST_DIR: ${PLOTLY_PACKAGE_ROOT}/plotly/tests/test_core/test_jupyter
11+
12+
node:
13+
version: 4.2.1
1014

1115
dependencies:
1216

@@ -22,6 +26,10 @@ dependencies:
2226
# we need to cd out of the project root to ensure the install worked
2327
- cd ~ && python -c "import plotly"
2428

29+
# install jupyter test JS requirements
30+
- cd ${PLOTLY_JUPYTER_TEST_DIR} && npm i
31+
32+
2533
cache_directories:
2634

2735
- "~/.pyenv/versions" # attempt to just cache installed pyenv things

circle/setup.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
3939
pip install -r ${PLOTLY_OPTIONAL_REQUIREMENTS_FILE} ||
4040
error_exit "${SIG} ${LINENO}: can't install optional for Python ${version}."
4141

42+
# add python version to available jupyter kernel list
43+
python -m ipykernel install --user --name ${version}
44+
echo "${SIG} jupyter kernelspec list"
45+
jupyter kernelspec list
4246
done

optional-requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ pandas
2424
## scipy deps for some FigureFactory functions ##
2525
scipy
2626

27+
## jupyter ##
28+
jupyter
29+
ipykernel

plotly/tests/test_core/test_jupyter/test_jupyter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@
77
from nbconvert.preprocessors import ExecutePreprocessor
88

99
from unittest import TestCase
10-
from os import path
10+
from os import path, environ
1111
import subprocess
1212

1313
PATH_ROOT = path.dirname(__file__)
1414
PATH_FIXTURES = path.join(PATH_ROOT, 'fixtures')
1515
PATH_TEST_NB = path.join(PATH_FIXTURES, 'test.ipynb')
1616
PATH_TEST_HTML = path.join(PATH_FIXTURES, 'test.html')
17+
PYENV_VERSION = environ['PYENV_VERSION']
1718

1819

1920
class PlotlyJupyterTestCase(TestCase):
2021
def setUp(self):
2122
with open(PATH_TEST_NB, 'r') as f:
2223
self.nb = nbformat.read(f, as_version=4)
2324

24-
self.ep = ExecutePreprocessor(timeout=600)
25+
if PYENV_VERSION:
26+
self.ep = ExecutePreprocessor(timeout=600, kernel_name=PYENV_VERSION)
27+
else:
28+
self.ep = ExecutePreprocessor(timeout=600)
29+
2530
self.html_exporter = HTMLExporter()
2631

2732
self.ep.preprocess(self.nb, {'metadata': {'path': '.'}})

0 commit comments

Comments
 (0)