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

Jupyter Notebook deprecation -> default to JupyterLab #1575

Merged
merged 10 commits into from
Jan 20, 2022
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ cont-rm-all: ## remove all containers



dev/%: DARGS?=-e JUPYTER_ENABLE_LAB=yes
dev/%: PORT?=8888
dev/%: ## run a foreground container for a stack
docker run -it --rm -p $(PORT):8888 $(DARGS) $(OWNER)/$(notdir $@)
Expand Down
12 changes: 7 additions & 5 deletions base-notebook/start-notebook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

set -e

# The Jupyter command to launch
# JupyterLab by default
JUPYTER_CMD="${JUPYTER_CMD:=lab}"

if [[ -n "${JUPYTERHUB_API_TOKEN}" ]]; then
echo "WARNING: using start-singleuser.sh instead of start-notebook.sh to start a server associated with JupyterHub."
exec /usr/local/bin/start-singleuser.sh "$@"
Expand All @@ -15,10 +19,8 @@ if [[ "${RESTARTABLE}" == "yes" ]]; then
fi

if [[ -n "${JUPYTER_ENABLE_LAB}" ]]; then
romainx marked this conversation as resolved.
Show resolved Hide resolved
# shellcheck disable=SC1091,SC2086
exec /usr/local/bin/start.sh ${wrapper} jupyter lab ${NOTEBOOK_ARGS} "$@"
else
echo "WARNING: Jupyter Notebook deprecation notice https://github.com/jupyter/docker-stacks#jupyter-notebook-deprecation-notice."
# shellcheck disable=SC1091,SC2086
exec /usr/local/bin/start.sh ${wrapper} jupyter notebook ${NOTEBOOK_ARGS} "$@"
fi

# shellcheck disable=SC1091,SC2086
exec /usr/local/bin/start.sh ${wrapper} jupyter ${JUPYTER_CMD} ${NOTEBOOK_ARGS} "$@"
6 changes: 2 additions & 4 deletions base-notebook/test/test_container_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def test_cli_args(container: TrackedContainer, http_client: requests.Session) ->
warnings = [
warning for warning in logs.split("\n") if warning.startswith("WARNING")
]
assert len(warnings) == 1
assert warnings[0].startswith("WARNING: Jupyter Notebook deprecation notice")
assert not warnings
assert "login_submit" not in resp.text


Expand All @@ -49,8 +48,7 @@ def test_unsigned_ssl(
warnings = [
warning for warning in logs.split("\n") if warning.startswith("WARNING")
]
assert len(warnings) == 1
assert warnings[0].startswith("WARNING: Jupyter Notebook deprecation notice")
assert not warnings


def test_uid_change(container: TrackedContainer) -> None:
Expand Down
42 changes: 25 additions & 17 deletions base-notebook/test/test_start_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,37 @@
# Distributed under the terms of the Modified BSD License.

import logging
from typing import Optional
import pytest
import requests
import re

from conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)


@pytest.mark.parametrize(
"env,expected_server",
"env,expected_server,expected_warnings",
[
(["JUPYTER_ENABLE_LAB=yes"], "lab"),
(None, "notebook"),
(
["JUPYTER_ENABLE_LAB=yes"],
"lab",
["WARNING: Jupyter Notebook deprecation notice"],
),
(None, "lab", []),
(["JUPYTER_CMD=lab"], "lab", []),
(["JUPYTER_CMD=notebook"], "notebook", []),
(["JUPYTER_CMD=server"], "server", []),
(["JUPYTER_CMD=nbclassic"], "nbclassic", []),
],
)
def test_start_notebook(
romainx marked this conversation as resolved.
Show resolved Hide resolved
container: TrackedContainer,
http_client: requests.Session,
env,
env: Optional[list[str]],
expected_server: str,
expected_warnings: list[str],
) -> None:
"""Test the notebook start-notebook script"""
LOGGER.info(
Expand All @@ -33,25 +44,22 @@ def test_start_notebook(
command=["start-notebook.sh"],
)
resp = http_client.get("http://localhost:8888")
# checking errors and warnings in logs
logs = c.logs(stdout=True).decode("utf-8")
LOGGER.debug(logs)
assert "ERROR" not in logs
if expected_server != "notebook":
assert "WARNING" not in logs
else:
warnings = [
warning for warning in logs.split("\n") if warning.startswith("WARNING")
]
assert len(warnings) == 1
assert warnings[0].startswith("WARNING: Jupyter Notebook deprecation notice")
assert "ERROR" not in logs, "ERROR(s) found in logs"
for exp_warning in expected_warnings:
assert exp_warning in logs, f"Expected warning {exp_warning} not found in logs"
warnings = re.findall(r"^WARNING", logs, flags=re.MULTILINE)
assert len(expected_warnings) == len(
warnings
), "Not found the number of expected warnings in logs"

# checking if the server is listening
assert resp.status_code == 200, "Server is not listening"
assert (
f"Executing the command: jupyter {expected_server}" in logs
), f"Not the expected command (jupyter {expected_server}) was launched"
# Checking warning messages
if not env:
msg = "WARNING: Jupyter Notebook deprecation notice"
assert msg in logs, f"Expected warning message {msg} not printed"


def test_tini_entrypoint(
Expand Down