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

Update to Jupyterlab 3.0 #551

Merged
merged 18 commits into from Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,6 +11,7 @@ MANIFEST
.coverage
.cache
.pytest_cache
.idea


.spyderproject
Expand Down
10 changes: 7 additions & 3 deletions docs/source/installing.rst
Expand Up @@ -89,10 +89,14 @@ Installing Jupyter extensions
If you want to use the development version of the notebook and lab extensions,
you will also have to run the following commands after the pip dev install::

jupyter serverextension enable --py nbdime [--sys-prefix/--user/--system]
> Note: only run one of the following two server commands, running both can cause issues in some cases

jupyter nbextension install --py nbdime [--sym-link] [--sys-prefix/--user/--system]
jupyter nbextension enable --py nbdime [--sys-prefix/--user/--system]
jupyter serverextension enable --py nbdime --sys-prefix # if developing for jupyter notebook

jupyter server extension enable nbdime # if developing for jupyter lab or nbclassic

jupyter nbextension install --py nbdime --sys-prefix [--sym-link]
jupyter nbextension enable --py nbdime --sys-prefix

jupyter labextension link ./packages/nbdime --no-build
jupyter labextension install ./packages/labextension
Expand Down
2 changes: 1 addition & 1 deletion docs/source/testing.rst
Expand Up @@ -11,7 +11,7 @@ Dependencies

Install the test dependencies::

pip install "nbdime[test]"
pip install .[test]

Running tests locally
---------------------
Expand Down
7 changes: 7 additions & 0 deletions jupyter-config/jupyter_server_config.d/nbdime.json
@@ -0,0 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"nbdime": true
}
}
}
7 changes: 7 additions & 0 deletions nbdime/__init__.py
Expand Up @@ -18,12 +18,18 @@ def load_jupyter_server_extension(nb_server_app):
_load_jupyter_server_extension(nb_server_app)


_load_jupyter_server_extension = load_jupyter_server_extension


def _jupyter_server_extension_paths():
return [{
"module": "nbdime"
}]


_jupyter_server_extension_points = _jupyter_server_extension_paths
vidartf marked this conversation as resolved.
Show resolved Hide resolved


def _jupyter_nbextension_paths():
return [dict(
section="notebook",
Expand All @@ -41,4 +47,5 @@ def _jupyter_nbextension_paths():
"patch", "patch_notebook",
"decide_merge", "merge_notebooks", "apply_decisions",
"load_jupyter_server_extension",
"_load_jupyter_server_extension",
]
2 changes: 1 addition & 1 deletion nbdime/_version.py
@@ -1,2 +1,2 @@
version_info = (2, 1, 1, 'dev')
version_info = (3, 0, 0, 'dev0')
__version__ = ".".join(map(str, version_info))
22 changes: 14 additions & 8 deletions nbdime/tests/conftest.py
Expand Up @@ -441,25 +441,31 @@ def _term():



def create_server_extension_config(tmpdir_factory):
def create_server_extension_config(tmpdir_factory, cmd):
appname = 'NotebookApp' if cmd == 'notebook' else 'ServerApp'
filename = 'jupyter_notebook_config.json' if cmd == 'notebook' else 'jupyter_server_config.json'
config_entry = 'nbserver_extensions' if cmd == 'notebook' else 'jpserver_extensions'
path = tmpdir_factory.mktemp('server-extension-config')
config = {
"NotebookApp": {
"nbserver_extensions": {
appname: {
config_entry: {
"nbdime": True
}
}
}
config_str = json.dumps(config)
if isinstance(config_str, bytes):
config_str = unicode(config_str)
path.join('jupyter_notebook_config.json').write_text(config_str, 'utf-8')
path.join(filename).write_text(config_str, 'utf-8')
return str(path)



@fixture(scope='module')
@fixture(scope='module', params=('notebook', 'jupyter_server'))
def server_extension_app(tmpdir_factory, request):
cmd = request.param

appname = 'NotebookApp' if cmd == 'notebook' else 'ServerApp'

def _kill_nb_app():
try:
Expand All @@ -469,7 +475,7 @@ def _kill_nb_app():
pass
popen_wait(process, 10)

config_dir = create_server_extension_config(tmpdir_factory)
config_dir = create_server_extension_config(tmpdir_factory, cmd)
env = os.environ.copy()
env.update({'JUPYTER_CONFIG_DIR': config_dir})

Expand All @@ -478,10 +484,10 @@ def _kill_nb_app():

os.chdir(root_dir)
process = Popen([
sys.executable, '-m', 'notebook',
sys.executable, '-m', cmd,
'--port=%i' % port,
'--ip=127.0.0.1',
'--no-browser', '--NotebookApp.token=%s' % TEST_TOKEN],
'--no-browser', '--%s.token=%s' % (appname, TEST_TOKEN)],
env=env)

request.addfinalizer(_kill_nb_app)
Expand Down
6 changes: 1 addition & 5 deletions nbdime/tests/test_git_filter_integration.py
Expand Up @@ -98,11 +98,7 @@ def test_apply_filter_invalid_filter(git_repo):


def test_apply_filter_valid_filter(git_repo):
try:
call('cat --help')
filter_cmd = 'cat'
except (CalledProcessError, FileNotFoundError):
filter_cmd = 'findstr x*'
filter_cmd = 'findstr x*' if os.name == 'nt' else 'cat'
path = pjoin(git_repo, 'diff.ipynb')
gitattr = locate_gitattributes()
with io.open(gitattr, 'a', encoding="utf8") as f:
Expand Down
7 changes: 4 additions & 3 deletions nbdime/tests/test_server_extension.py
Expand Up @@ -8,6 +8,7 @@
import re
import requests
import shutil
import uuid

import pytest

Expand Down Expand Up @@ -149,7 +150,6 @@ def test_diff_api_checkpoint(tmpdir, filespath, server_extension_app):
if os.sep == '\\':
url_path = url_path.replace('\\', '/')


# Create checkpoint
url = 'http://127.0.0.1:%i/api/contents/%s/checkpoints' % (
server_extension_app['port'],
Expand All @@ -164,7 +164,8 @@ def test_diff_api_checkpoint(tmpdir, filespath, server_extension_app):

url = 'http://127.0.0.1:%i/nbdime/api/diff' % server_extension_app['port']
r = requests.post(
url, headers=auth_header,
url,
headers=auth_header,
data=json.dumps({
'base': 'checkpoint:' + url_path,
}))
Expand All @@ -178,7 +179,7 @@ def test_diff_api_checkpoint(tmpdir, filespath, server_extension_app):
@pytest.mark.timeout(timeout=WEB_TEST_TIMEOUT)
def test_diff_api_symlink(git_repo2, server_extension_app, needs_symlink):
root = server_extension_app['path']
subdir = pjoin(root, 'has space', 'subdir')
subdir = pjoin(root, str(uuid.uuid4()), 'has space', 'subdir')
os.makedirs(subdir)
symlink = pjoin(subdir, 'link')
with pushd(subdir):
Expand Down
16 changes: 11 additions & 5 deletions nbdime/webapp/nb_server_extension.py
Expand Up @@ -8,9 +8,15 @@

from jinja2 import ChoiceLoader, FileSystemLoader

from notebook.utils import url_path_join, to_os_path
from notebook.services.contents.checkpoints import GenericCheckpointsMixin
from notebook.services.contents.filecheckpoints import FileCheckpoints
from jupyter_server.utils import url_path_join, to_os_path

from jupyter_server.services.contents.checkpoints import GenericCheckpointsMixin as jpserver_GenericCheckpointsMixin
from jupyter_server.services.contents.filecheckpoints import FileCheckpoints as jpserver_FileCheckpoints

from notebook.services.contents.checkpoints import GenericCheckpointsMixin as nbserver_GenericCheckpointsMixin
from notebook.services.contents.filecheckpoints import FileCheckpoints as nbserver_FileCheckpoints
vidartf marked this conversation as resolved.
Show resolved Hide resolved


from tornado.web import HTTPError, escape, authenticated, gen

from ..args import process_diff_flags
Expand Down Expand Up @@ -148,11 +154,11 @@ def _get_checkpoint_notebooks(self, base):
raise gen.Return((remote_nb, remote_nb))
self.log.debug('Checkpoints: %r', checkpoints)
checkpoint = checkpoints[0]
if isinstance(cm.checkpoints, GenericCheckpointsMixin):
if isinstance(cm.checkpoints, (jpserver_GenericCheckpointsMixin, nbserver_GenericCheckpointsMixin)):
checkpoint_model = yield gen.maybe_future(
cm.checkpoints.get_notebook_checkpoint(checkpoint, base))
base_nb = checkpoint_model['content']
elif isinstance(cm.checkpoints, FileCheckpoints):
elif isinstance(cm.checkpoints, (jpserver_FileCheckpoints, nbserver_FileCheckpoints)):
path = yield gen.maybe_future(
cm.checkpoints.checkpoint_path(checkpoint['id'], base))
base_nb = read_notebook(path, on_null='minimal')
Expand Down
10 changes: 5 additions & 5 deletions nbdime/webapp/nbdimeserver.py
Expand Up @@ -12,10 +12,10 @@

from jinja2 import FileSystemLoader, Environment
import nbformat
from notebook.base.handlers import IPythonHandler, APIHandler
from notebook import DEFAULT_STATIC_FILES_PATH
from notebook.utils import url_path_join
from notebook.log import log_request
from jupyter_server.base.handlers import JupyterHandler, APIHandler
from jupyter_server import DEFAULT_STATIC_FILES_PATH
from jupyter_server.utils import url_path_join
from jupyter_server.log import log_request
import requests
from six import string_types
from tornado import ioloop, web, escape, netutil, httpserver
Expand Down Expand Up @@ -43,7 +43,7 @@
template_path = os.path.join(here, 'templates')


class NbdimeHandler(IPythonHandler):
class NbdimeHandler(JupyterHandler):
def initialize(self, **params):
self.params = params

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -14,7 +14,7 @@
"watch": "tsc --build --watch"
},
"devDependencies": {
"@jupyterlab/buildutils": "^2.0.0",
"@jupyterlab/buildutils": "^3.0.0",
"lerna": "^3.14.1",
"rimraf": "^2.6.3"
}
Expand Down
30 changes: 15 additions & 15 deletions packages/labextension/package.json
@@ -1,6 +1,6 @@
{
"name": "nbdime-jupyterlab",
"version": "2.0.1",
"version": "3.0.0",
"description": "A JupyterLab extension for showing Notebook diffs.",
"keywords": [
"jupyter",
Expand Down Expand Up @@ -38,22 +38,22 @@
"watch": "tsc --build --watch"
},
"dependencies": {
"@jupyterlab/apputils": "^2.0.0",
"@jupyterlab/coreutils": "^4.0.0",
"@jupyterlab/nbformat": "^2.0.0",
"@jupyterlab/notebook": "^2.0.0",
"@jupyterlab/rendermime": "^2.0.0",
"@jupyterlab/services": "^5.0.0",
"@jupyterlab/settingregistry": "^2.0.0",
"@lumino/algorithm": "^1.1.2",
"@lumino/coreutils": "^1.3.0",
"@lumino/disposable": "^1.1.2",
"@lumino/widgets": "^1.6.0",
"nbdime": "^6.0.0"
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/nbformat": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"@jupyterlab/rendermime": "^3.0.0",
"@jupyterlab/services": "^6.0.0",
"@jupyterlab/settingregistry": "^3.0.0",
"@lumino/algorithm": "^1.3.3",
"@lumino/coreutils": "^1.5.3",
"@lumino/disposable": "^1.4.3",
"@lumino/widgets": "^1.16.0",
"nbdime": "^7.0.0"
},
"devDependencies": {
"@jupyterlab/application": "^2.0.0",
"@jupyterlab/docregistry": "^2.0.0",
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/docregistry": "^3.0.0",
"@lumino/commands": "^1.6.1",
"mkdirp": "^0.5.1",
"rimraf": "^2.6.3",
Expand Down
28 changes: 14 additions & 14 deletions packages/nbdime/package.json
@@ -1,6 +1,6 @@
{
"name": "nbdime",
"version": "6.0.0",
"version": "7.0.0",
"description": "Diff and merge of Jupyter Notebooks",
"repository": {
"type": "git",
Expand All @@ -23,22 +23,22 @@
"watch": "tsc --build --watch"
},
"dependencies": {
"@jupyterlab/codeeditor": "^2.0.0",
"@jupyterlab/codemirror": "^2.0.0",
"@jupyterlab/coreutils": "^4.0.0",
"@jupyterlab/nbformat": "^2.0.0",
"@jupyterlab/outputarea": "^2.0.0",
"@jupyterlab/rendermime": "^2.0.0",
"@jupyterlab/services": "^5.0.0",
"@lumino/algorithm": "^1.1.2",
"@lumino/coreutils": "^1.3.0",
"@lumino/dragdrop": "^1.3.0",
"@lumino/signaling": "^1.2.2",
"@lumino/widgets": "^1.6.0",
"@jupyterlab/codeeditor": "^3.0.0",
"@jupyterlab/codemirror": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/nbformat": "^3.0.0",
"@jupyterlab/outputarea": "^3.0.0",
"@jupyterlab/rendermime": "^3.0.0",
"@jupyterlab/services": "^6.0.0",
vidartf marked this conversation as resolved.
Show resolved Hide resolved
"@lumino/algorithm": "^1.3.3",
"@lumino/coreutils": "^1.5.3",
"@lumino/dragdrop": "^1.7.0",
"@lumino/signaling": "^1.4.3",
"@lumino/widgets": "^1.16.0",
"json-stable-stringify": "^1.0.1"
},
"devDependencies": {
"@jupyterlab/apputils": "^2.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@lumino/messaging": "^1.2.2",
"@types/expect.js": "^0.3.29",
"@types/json-stable-stringify": "^1.0.32",
Expand Down
26 changes: 13 additions & 13 deletions packages/webapp/package.json
Expand Up @@ -13,21 +13,21 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.12.0",
"@jupyterlab/application": "^2.0.0",
"@jupyterlab/apputils": "^2.0.0",
"@jupyterlab/cells": "^2.0.0",
"@jupyterlab/codemirror": "^2.0.0",
"@jupyterlab/coreutils": "^4.0.0",
"@jupyterlab/mathjax2": "^2.0.0",
"@jupyterlab/nbformat": "^2.0.0",
"@jupyterlab/notebook": "^2.0.0",
"@jupyterlab/rendermime": "^2.0.0",
"@jupyterlab/theme-light-extension": "^2.0.0",
"@lumino/dragdrop": "^1.3.0",
"@lumino/widgets": "^1.6.0",
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/cells": "^3.0.0",
"@jupyterlab/codemirror": "^3.0.0",
"@jupyterlab/coreutils": "^5.0.0",
"@jupyterlab/mathjax2": "^3.0.0",
"@jupyterlab/nbformat": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"@jupyterlab/rendermime": "^3.0.0",
"@jupyterlab/theme-light-extension": "^3.0.0",
"@lumino/dragdrop": "^1.7.0",
"@lumino/widgets": "^1.16.0",
"alertify.js": "^1.0.12",
"file-saver": "^2.0.1",
"nbdime": "^6.0.0"
"nbdime": "^7.0.0"
},
"devDependencies": {
"@types/file-saver": "^2.0.0",
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -116,6 +116,7 @@
'requests',
'GitPython!=2.1.4, !=2.1.5, !=2.1.6', # For difftool taking git refs
'notebook',
'jupyter_server',
'jinja2>=2.9',
]

Expand All @@ -125,6 +126,7 @@
'pytest-cov',
'pytest-timeout',
'pytest-tornado',
'jupyter_server[test]',
'jsonschema',
'mock',
'requests',
Expand Down