From b7aad78b82bc7dc67150fa8f1f2821968cfd00a0 Mon Sep 17 00:00:00 2001 From: romainx Date: Fri, 8 Jan 2021 09:13:01 +0100 Subject: [PATCH] Switch to JupyterLab by default --- base-notebook/start-notebook.sh | 10 +++++-- base-notebook/test/test_start_script.py | 37 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 base-notebook/test/test_start_script.py diff --git a/base-notebook/start-notebook.sh b/base-notebook/start-notebook.sh index f893af16..3b0f2057 100755 --- a/base-notebook/start-notebook.sh +++ b/base-notebook/start-notebook.sh @@ -12,8 +12,12 @@ fi if [[ ! -z "${JUPYTERHUB_API_TOKEN}" ]]; then # launched by JupyterHub, use single-user entrypoint exec /usr/local/bin/start-singleuser.sh "$@" -elif [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then - . /usr/local/bin/start.sh $wrapper jupyter lab "$@" -else +elif [[ ! -z "${JUPYTER_ENABLE_NB}" ]]; then + echo "WARN: We encourage users to transition to JupyterLab, Notebook support could be removed" . /usr/local/bin/start.sh $wrapper jupyter notebook "$@" +else + if [[ ! -z "${JUPYTER_ENABLE_LAB}" ]]; then + echo "WARN: The JUPYTER_ENABLE_LAB environment variable is not required anymore" + fi + . /usr/local/bin/start.sh $wrapper jupyter lab "$@" fi diff --git a/base-notebook/test/test_start_script.py b/base-notebook/test/test_start_script.py new file mode 100644 index 00000000..4697bfb1 --- /dev/null +++ b/base-notebook/test/test_start_script.py @@ -0,0 +1,37 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +import logging +import pytest + +LOGGER = logging.getLogger(__name__) + + +@pytest.mark.parametrize( + "env,expected_server", + [ + (["JUPYTER_ENABLE_NB=yes"], "notebook"), + (["JUPYTER_ENABLE_LAB=yes"], "lab"), + (None, "lab"), + ], +) +def test_start_notebook(container, http_client, env, expected_server): + """Test the notebook start-notebook script""" + LOGGER.info( + f"Test that the start-notebook launches the {expected_server} server from the env {env} ..." + ) + c = container.run(tty=True, environment=env, command=["start-notebook.sh"]) + resp = http_client.get("http://localhost:8888") + assert resp.status_code == 200, "Server is not listening" + logs = c.logs(stdout=True).decode("utf-8") + LOGGER.debug(logs) + assert ( + f"Executing the command: jupyter {expected_server}" in logs + ), f"Not the expected command (jupyter {expected_server}) was launched" + if env: + # Checking warning messages + if "JUPYTER_ENABLE_LAB=yes" in env: + msg = "WARN: The JUPYTER_ENABLE_LAB environment variable is not required anymore" + elif "JUPYTER_ENABLE_NB=yes" in env: + msg = "WARN: We encourage users to transition to JupyterLab, Notebook support could be removed" + assert msg in logs, f"Expected warning message {msg} not printed"