Skip to content

Commit

Permalink
Install latest version of nbconvert to fix Jinja issue. (#1141)
Browse files Browse the repository at this point in the history
The latest version of Jinja changed the import for `Markup`.

The import was fixed in the latest version of `nbconvert`: jupyter/nbconvert#1736

We include the version of `nbconvert` from the DLVM base image which is
released every ~2 weeks. However, the `nbconvert` fix was released only
6 hours ago.

Temporarily install thel latest version of `nbconvert`.

Add a test to prevent regression.

http://b/227194111
  • Loading branch information
rosbo authored Mar 28, 2022
1 parent 59d6b8a commit 66a12ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,14 @@ RUN pip install bleach && \
pip install ipywidgets && \
pip install isoweek && \
pip install jedi && \
pip install Jinja2 && \
pip install jsonschema && \
pip install jupyter-client && \
pip install jupyter-console && \
pip install jupyter-core && \
pip install MarkupSafe && \
pip install mistune && \
pip install nbconvert && \
# b/227194111 install latest version of nbconvert until the base image includes nbconvert >= 6.4.5
pip install --upgrade nbconvert Jinja2 && \
pip install nbformat && \
pip install notebook && \
pip install papermill && \
Expand Down
20 changes: 18 additions & 2 deletions tests/test_jupyter_nbconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess

class TestJupyterNbconvert(unittest.TestCase):
def test_nbconvert(self):
def test_nbconvert_to_notebook(self):
result = subprocess.run([
'jupyter',
'nbconvert',
Expand All @@ -17,4 +17,20 @@ def test_nbconvert(self):
], stdout=subprocess.PIPE)

self.assertEqual(0, result.returncode)
self.assertTrue(b'999' in result.stdout)
self.assertTrue(b'999' in result.stdout)

def test_nbconvert_to_html(self):
result = subprocess.run([
'jupyter',
'nbconvert',
'--to',
'html',
'--template',
'/opt/kaggle/nbconvert-extensions.tpl',
'--execute',
'--stdout',
'/input/tests/data/notebook.ipynb',
], stdout=subprocess.PIPE)

self.assertEqual(0, result.returncode)
self.assertTrue(b'999' in result.stdout)

0 comments on commit 66a12ac

Please sign in to comment.