Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade nbconvert #1015

Merged
merged 42 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
091dd3b
Added nbconvert fix for #958 and a small flake8 issue
robindebois Oct 4, 2020
11205bd
Fix typos reported in #947
robindebois Oct 4, 2020
5428e40
have dev requirements requires normal files
Carreau Mar 15, 2022
eaa612d
Merge remote-tracking branch 'origin/pull/959'
Carreau Mar 15, 2022
e0da640
requirements
Carreau Mar 15, 2022
e7cad49
in prorgess
Carreau Mar 15, 2022
aef3d9e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 15, 2022
14731bc
Upgrade nbconvert
martinRenou Aug 11, 2022
fc413a4
Re-generate requirements
martinRenou Aug 11, 2022
9b2ebeb
restore missing index.html files
minrk Aug 22, 2022
b719c0a
add missing requirements.txt to Dockerfile
minrk Aug 22, 2022
8de92ca
remove outdated slides_reveal template
minrk Aug 22, 2022
76e227b
switch tests to pytest
minrk Aug 22, 2022
5556d13
need libcurl-dev for pycurl
minrk Aug 22, 2022
3a56973
requirements-dev shouldn't depend on pinned requirements.txt
minrk Aug 22, 2022
78c0099
missing raw-string prefix on regex
minrk Aug 22, 2022
ecbf8cf
monor making it work
Carreau Oct 31, 2022
9a49c77
test
Carreau Oct 31, 2022
a4ab0cc
Revert "test"
Carreau Oct 31, 2022
92f0a80
Minimal style update to confirm with previous
Carreau Oct 31, 2022
25d4dbe
bump minimal python version
Carreau Oct 31, 2022
54a9091
bump some version
Carreau Oct 31, 2022
987fb56
fix unbound
Carreau Oct 31, 2022
aa08341
Debug and typing
Carreau Oct 31, 2022
142d690
more fixes
Carreau Oct 31, 2022
23b023a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 31, 2022
df9154c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 31, 2022
f3f82d5
debug
Carreau Oct 31, 2022
9251d8a
debug
Carreau Oct 31, 2022
345ec8c
remove assert
Carreau Oct 31, 2022
5ed7c43
debug
Carreau Oct 31, 2022
b22880b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 31, 2022
1298325
debug log
Carreau Oct 31, 2022
1052ba6
Merge remote-tracking branch 'martinRenou/upgrade-nbconvert' into upg…
Carreau Oct 31, 2022
892cc8f
More cleanup, + mypy
Carreau Oct 31, 2022
f571358
cleanup
Carreau Nov 1, 2022
4545153
reformat with black
Carreau Nov 1, 2022
9fcd1ff
remove reveal block, it now comes from nbconvert directly
Carreau Nov 1, 2022
fc85656
track down test failure
Carreau Nov 1, 2022
f08008d
Autofix is annoying as you can't keep pushing
Carreau Nov 1, 2022
bedbc93
please linter
Carreau Nov 1, 2022
b46085a
Update nbviewer/providers/github/handlers.py
Carreau Nov 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: test

on:
push:
branches:
pull_request:

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: install apt packages
# pycurl build requirements
run: |
sudo apt-get update && sudo apt-get -y install \
libcurl4-gnutls-dev \
libgnutls28-dev

- name: install
run: |
python3 -m pip install -r requirements.in -r requirements-dev.txt

- name: pip freeze
run: |
python3 -m pip freeze

- name: run tests
run: |
pytest -v nbviewer/tests
17 changes: 11 additions & 6 deletions nbviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import markdown
from jinja2 import Environment
from jinja2 import FileSystemLoader
from nbconvert.exporters.export import exporter_map
from nbconvert import get_exporter
from nbconvert.exporters.templateexporter import ExtensionTolerantLoader
from tornado import httpserver
from tornado import ioloop
from tornado import web
Expand Down Expand Up @@ -468,7 +469,11 @@ def default_endpoint(self):

@cached_property
def env(self):
env = Environment(loader=FileSystemLoader(self.template_paths), autoescape=True)
loader = ExtensionTolerantLoader(FileSystemLoader(self.template_paths), ".j2")
env = Environment(
loader=loader,
autoescape=True,
)
env.filters["markdown"] = markdown.markdown
try:
git_data = git_info(here)
Expand Down Expand Up @@ -594,15 +599,15 @@ def configure_formats(self, formats=None):
formats = default_formats()

# This would be better defined in a class
self.config.HTMLExporter.template_file = "basic"
self.config.SlidesExporter.template_file = "slides_reveal"
# self.config.HTMLExporter.template_file = "base"
# self.config.SlidesExporter.template_file = "slides_reveal"

self.config.TemplateExporter.template_path = [
self.config.TemplateExporter.extra_template_basedirs = [
os.path.join(os.path.dirname(__file__), "templates", "nbconvert")
]

for key, format in formats.items():
exporter_cls = format.get("exporter", exporter_map[key])
exporter_cls = format.get("exporter", get_exporter(key))
if self.processes:
# can't pickle exporter instances,
formats[key]["exporter"] = exporter_cls
Expand Down
4 changes: 2 additions & 2 deletions nbviewer/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def test_slides(nb, json):
return False

return {
"html": {"nbconvert_template": "basic", "label": "Notebook", "icon": "book"},
"html": {"nbconvert_template": "lab", "label": "Notebook", "icon": "book"},
"slides": {
"nbconvert_template": "slides_reveal",
# "nbconvert_template": "slides_reveal",
Carreau marked this conversation as resolved.
Show resolved Hide resolved
"label": "Slides",
"icon": "gift",
"test": test_slides,
Expand Down
2 changes: 1 addition & 1 deletion nbviewer/providers/github/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async def get(self, user, repo, ref, path):
# See: https://github.com/jupyter/nbviewer/issues/324
example_file_url = contents[0]["html_url"]
user, repo = re.match(
r"^" + self.github_url + "(?P<user>[^\/]+)/(?P<repo>[^\/]+)/.*",
r"^" + self.github_url + r"(?P<user>[^\/]+)/(?P<repo>[^\/]+)/.*",
example_file_url,
).group("user", "repo")

Expand Down
42 changes: 0 additions & 42 deletions nbviewer/templates/nbconvert/slides_reveal.tpl

This file was deleted.

7 changes: 2 additions & 5 deletions nbviewer/templates/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,9 @@


{% block body %}
BREAKCRUMB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEBUG ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, debugging

{{ link_breadcrumbs(breadcrumbs) }}
<div id="notebook">
<div id="notebook-container">
{{ body | safe}}
</div>
</div>
{{ body | safe}}
{% endblock %}


Expand Down
3 changes: 0 additions & 3 deletions nbviewer/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import sys
import time
from contextlib import contextmanager
from subprocess import DEVNULL as devnull
from subprocess import Popen
from unittest import skipIf
from unittest import TestCase
Expand Down Expand Up @@ -73,8 +72,6 @@ def setup_class(cls):
server_cmd = cls.get_server_cmd()
cls.server = Popen(
server_cmd,
stdout=devnull,
stderr=devnull,
# Set environment variables if any
env=dict(os.environ, **cls.environment_variables),
)
Expand Down
6 changes: 2 additions & 4 deletions nbviewer/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
# -----------------------------------------------------------------------------
import nose.tools as nt

from nbviewer import utils
from nbviewer.providers import default_rewrites
from nbviewer.providers import provider_uri_rewrites
Expand Down Expand Up @@ -64,10 +62,10 @@ def test_transform_ipynb_uri():
uri_rewrite_list = provider_uri_rewrites(default_rewrites)
for ipynb_uri, expected_output in test_data:
output = utils.transform_ipynb_uri(ipynb_uri, uri_rewrite_list)
nt.assert_equal(
assert output == expected_output, "%s => %s != %s" % (
ipynb_uri,
output,
expected_output,
"%s => %s != %s" % (ipynb_uri, output, expected_output),
)


Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coverage
invoke>=0.13.0
mock>=1.3.0 # python34 and older versions of mock do not play well together.
nose
pre-commit
pytest
requests
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ipython
jupyter_client
jupyter_server>=0.2.0
markdown>=3.0,==3.1.1 # pin until we workaround #909, which is a regression in 3.2
nbconvert>=5.4,<6.0.0 # pin to fix #958
nbconvert>=6.5.2
nbformat>=4.2
newrelic!=2.80.0.60
pycurl
Expand Down
32 changes: 26 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ attrs==21.4.0
# via jsonschema
backcall==0.2.0
# via ipython
beautifulsoup4==4.11.1
# via nbconvert
black==21.12b0
# via ipython
bleach==4.1.0
Expand Down Expand Up @@ -58,6 +60,7 @@ jupyter-client==7.1.2
# via
# -r requirements.in
# jupyter-server
# nbclient
jupyter-core==4.9.1
# via
# jupyter-client
Expand All @@ -66,33 +69,45 @@ jupyter-core==4.9.1
# nbformat
jupyter-server==1.13.4
# via -r requirements.in
jupyterlab-pygments==0.2.2
# via nbconvert
lxml==4.9.1
# via nbconvert
markdown==3.1.1
# via -r requirements.in
markupsafe==2.0.1
# via jinja2
# via
# jinja2
# nbconvert
matplotlib-inline==0.1.3
# via ipython
mistune==0.8.4
# via nbconvert
mypy-extensions==0.4.3
# via black
nbconvert==5.6.1
nbclient==0.6.6
# via nbconvert
nbconvert==6.5.2
# via
# -r requirements.in
# jupyter-server
nbformat==5.1.3
# via
# -r requirements.in
# jupyter-server
# nbclient
# nbconvert
nest-asyncio==1.5.4
# via jupyter-client
# via
# jupyter-client
# nbclient
newrelic==7.4.0.172
# via -r requirements.in
packaging==21.3
# via
# bleach
# jupyter-server
# nbconvert
pandocfilters==1.5.0
# via nbconvert
parso==0.8.3
Expand Down Expand Up @@ -144,13 +159,15 @@ six==1.16.0
# python-dateutil
sniffio==1.2.0
# via anyio
soupsieve==2.3.2.post1
# via beautifulsoup4
stack-data==0.1.4
# via ipython
statsd==3.3.0
# via -r requirements.in
terminado==0.13.1
# via jupyter-server
testpath==0.5.0
tinycss2==1.1.1
# via nbconvert
tomli==1.2.3
# via black
Expand All @@ -160,13 +177,14 @@ tornado==6.1
# jupyter-client
# jupyter-server
# terminado
traitlets==5.1.1
traitlets==5.3.0
# via
# ipython
# jupyter-client
# jupyter-core
# jupyter-server
# matplotlib-inline
# nbclient
# nbconvert
# nbformat
typing-extensions==4.0.1
Expand All @@ -176,7 +194,9 @@ urllib3==1.26.8
wcwidth==0.2.5
# via prompt-toolkit
webencodings==0.5.1
# via bleach
# via
# bleach
# tinycss2
websocket-client==1.2.3
# via jupyter-server

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def walk_subpkg(name):
classifiers=[
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.7",
],
test_suite="nose.collector",
python_requires=">=3.7",
cmdclass=cmdclass,
)

Expand Down