From 88f4a77a3d1b1f2b09372efae2a4b57f24d92f89 Mon Sep 17 00:00:00 2001 From: Jon Carifio Date: Thu, 20 Jul 2023 12:45:34 -0400 Subject: [PATCH 1/3] Update ecliptic grid color default to match engine --- pywwt/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pywwt/core.py b/pywwt/core.py index 9caad63f..cc29fd7e 100644 --- a/pywwt/core.py +++ b/pywwt/core.py @@ -680,7 +680,7 @@ def instruments(self): ).tag(wwt="showEclipticGrid", wwt_reset=True) ecliptic_grid_color = Color( - "blue", help="The color of the ecliptic grid " "(`str` or `tuple`)" + "green", help="The color of the ecliptic grid " "(`str` or `tuple`)" ).tag(wwt="eclipticGridColor", wwt_reset=True) ecliptic_text = Bool( From 977652a085c5264cf4ad69a7a8b1f98e93cd6ca6 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sun, 23 Jul 2023 16:39:15 -0400 Subject: [PATCH 2/3] Fix compatibility with `notebook` 7.x --- .check_enabled.py | 22 ++++++++++++++++------ pywwt/jupyter_relay.py | 7 ++++++- pywwt/jupyter_server.py | 17 +++++++++++++---- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/.check_enabled.py b/.check_enabled.py index e943869b..05eddc24 100644 --- a/.check_enabled.py +++ b/.check_enabled.py @@ -2,22 +2,32 @@ import sys from jupyterlab.commands import get_app_info -from notebook.nbextensions import validate_nbextension -from notebook.serverextensions import validate_serverextension + +try: + from nbclassic.nbextensions import validate_nbextension +except ImportError: + # `notebook` <= 6 + from notebook.nbextensions import validate_nbextension + +try: + from nbclassic.serverextensions import validate_serverextension +except ImportError: + # `notebook` <= 6 + from notebook.serverextensions import validate_serverextension # If there's a problem and we don't provide this, the validate function crashes :-( -logger = logging.getLogger('') +logger = logging.getLogger("") -if validate_nbextension('pywwt/extension', logger=logger) != []: +if validate_nbextension("pywwt/extension", logger=logger) != []: print("Issue detected with nbextension") sys.exit(1) info = get_app_info() -if 'pywwt' not in info['extensions'] or 'pywwt' in info['disabled']: +if "pywwt" not in info["extensions"] or "pywwt" in info["disabled"]: print("Issue detected with labextension") sys.exit(1) -if validate_serverextension('pywwt', logger=logger) != []: +if validate_serverextension("pywwt", logger=logger) != []: print("Issue detected with serverextension") sys.exit(1) diff --git a/pywwt/jupyter_relay.py b/pywwt/jupyter_relay.py index fc60c76e..1573b31a 100644 --- a/pywwt/jupyter_relay.py +++ b/pywwt/jupyter_relay.py @@ -519,11 +519,16 @@ def get_relay_hub(kernel=None): def _list_running_servers_jl3(): import io import json - from notebook.utils import check_pid from jupyter_core.paths import jupyter_runtime_dir import os.path import re + try: + from jupyter_server.utils import check_pid + except ImportError: + # `notebook` <= 6 + from notebook.utils import check_pid + runtime_dir = jupyter_runtime_dir() if not os.path.isdir(runtime_dir): diff --git a/pywwt/jupyter_server.py b/pywwt/jupyter_server.py index 053009c9..a89c60df 100644 --- a/pywwt/jupyter_server.py +++ b/pywwt/jupyter_server.py @@ -19,12 +19,21 @@ # so let's try to fail gracefully if Jupyter modules are missing. `tornado` is a # hard requirement appearing in setup.py. try: - from notebook.utils import url_path_join - from notebook.base.handlers import IPythonHandler + try: + from jupyter_server.utils import url_path_join + except ImportError: + # `notebook` <= 6 + from notebook.utils import url_path_join + + try: + from jupyter_server.base.handlers import JupyterHandler + except ImportError: + # `notebook` <= 6 + from notebook.base.handlers import IPythonHandler as JupyterHandler HAVE_NOTEBOOK = True except ImportError: - IPythonHandler = object + JupyterHandler = object HAVE_NOTEBOOK = False __all__ = [ @@ -35,7 +44,7 @@ STATIC_DIR = os.path.join(os.path.dirname(__file__), "web_static") -class WWTStaticFileHandler(IPythonHandler): +class WWTStaticFileHandler(JupyterHandler): def get(self, filename): static_path = os.path.join(STATIC_DIR, filename) From fe5691fcc83ba09adca39ce453e5e5b4357005c9 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Wed, 26 Jul 2023 22:04:27 -0400 Subject: [PATCH 3/3] More updates to work with Notebook 7 --- .readthedocs_env.yml | 1 + ci/azure-build-and-test.yml | 6 +++--- docs/installation.rst | 19 ++++++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.readthedocs_env.yml b/.readthedocs_env.yml index 5f5ade13..72ca5299 100644 --- a/.readthedocs_env.yml +++ b/.readthedocs_env.yml @@ -14,6 +14,7 @@ dependencies: - krb5 - lxml - matplotlib + - nbclassic - nodejs - notebook - numpydoc diff --git a/ci/azure-build-and-test.yml b/ci/azure-build-and-test.yml index 3b0ad53f..b3504e92 100644 --- a/ci/azure-build-and-test.yml +++ b/ci/azure-build-and-test.yml @@ -144,9 +144,9 @@ jobs: source activate-conda.sh conda activate build set -x - \conda install -y jupyterlab jupyter_contrib_nbextensions - jupyter nbextension list - jupyter serverextension list + \conda install -y jupyterlab nbclassic + jupyter nbclassic-extension list + jupyter nbclassic-serverextension list jupyter labextension list displayName: Print Jupyter extension status diff --git a/docs/installation.rst b/docs/installation.rst index 09023323..e4d4d070 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -244,13 +244,18 @@ this repository and install the package manually (note that this requires `npm cd pywwt pip install -e . -If you want to use the Jupyter widget, you will also need to run:: - - jupyter nbextension install --py --symlink --sys-prefix pywwt - jupyter nbextension enable --py --sys-prefix pywwt - jupyter nbextension list # check that the output shows pywwt as enabled and OK - jupyter serverextension enable --py --sys-prefix pywwt - jupyter serverextension list # check that the output shows pywwt as enabled and OK +If you want to use the Jupyter widget with a recent installation of the Jupyter +stack, you will also need to run:: + + jupyter nbclassic-extension install --py --symlink --sys-prefix pywwt + jupyter nbclassic-extension enable --py --sys-prefix pywwt + jupyter nbclassic-extension list # check that the output shows pywwt as enabled and OK + jupyter nbclassic-serverextension enable --py --sys-prefix pywwt + jupyter nbclassic-serverextension list # check that the output shows pywwt as enabled and OK + +On older versions of Jupyter, use the ``nbextension`` subcommand instead of +``nbclassic-extension``, and use just ``serverextension`` instead of +``nbclassic-serverextension``. And if you additionally want to use the widget in JupyterLab, run::