From 178a0ee4a19545f1661257f2f6b185812a7d19a2 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Mon, 28 Mar 2022 16:10:21 +0000 Subject: [PATCH 1/2] Install latest version of nbconvert to fix Jinja issue. The latest version of Jinja changed the import for `Markup`. The import was fixed in the latest version of `nbconvert`: https://github.com/jupyter/nbconvert/issues/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 --- Dockerfile.tmpl | 3 ++- tests/test_jupyter_nbconvert.py | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Dockerfile.tmpl b/Dockerfile.tmpl index 4a1012b7..8e764e8b 100644 --- a/Dockerfile.tmpl +++ b/Dockerfile.tmpl @@ -396,7 +396,8 @@ RUN pip install bleach && \ 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 && \ pip install nbformat && \ pip install notebook && \ pip install papermill && \ diff --git a/tests/test_jupyter_nbconvert.py b/tests/test_jupyter_nbconvert.py index b3925993..f2549a50 100644 --- a/tests/test_jupyter_nbconvert.py +++ b/tests/test_jupyter_nbconvert.py @@ -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', @@ -17,4 +17,20 @@ def test_nbconvert(self): ], stdout=subprocess.PIPE) self.assertEqual(0, result.returncode) - self.assertTrue(b'999' in result.stdout) \ No newline at end of file + 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) From 6ef2ea113a6292613677ba5ed97aa0a517431d77 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Mon, 28 Mar 2022 17:36:09 +0000 Subject: [PATCH 2/2] Install latest version of Jinja --- Dockerfile.tmpl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile.tmpl b/Dockerfile.tmpl index 8e764e8b..483402e4 100644 --- a/Dockerfile.tmpl +++ b/Dockerfile.tmpl @@ -389,7 +389,6 @@ 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 && \ @@ -397,7 +396,7 @@ RUN pip install bleach && \ pip install MarkupSafe && \ pip install mistune && \ # b/227194111 install latest version of nbconvert until the base image includes nbconvert >= 6.4.5 - pip install --upgrade nbconvert && \ + pip install --upgrade nbconvert Jinja2 && \ pip install nbformat && \ pip install notebook && \ pip install papermill && \