diff --git a/.readthedocs.yml b/.readthedocs.yml index db03a79..fa754ea 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,15 +1,16 @@ version: 2 build: - image: latest + os: ubuntu-22.04 + tools: + python: "3.10" python: - version: 3.7 install: - method: pip path: . extra_requirements: - docs -# Don't build any extra formats -formats: [] +sphinx: + configuration: docs/conf.py diff --git a/README.md b/README.md index d2dc323..180d099 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ [wwt_kernel_data_relay] is a [Jupyter server extension][ext] that enables [Jupyter kernels][kernels] to publish some of their data files to the Web; that is, to request that the Jupyter HTTP server make them accessible at a -predictable URL. This functionality is used by [pywwt], the [AAS] [WorldWide +predictable URL. This functionality is used by [pywwt], the [WorldWide Telescope] Python library, to expose kernel-side data assets for visualization inside the WWT [research app][rapp]. [wwt_kernel_data_relay]: https://github.com/WorldWideTelescope/wwt_kernel_data_relay/ -[ext]: https://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html +[ext]: https://jupyter-server.readthedocs.io/en/stable/developers/extensions.html [kernels]: https://jupyter.readthedocs.io/en/latest/projects/kernels.html [pywwt]: https://pywwt.readthedocs.io/ [AAS]: https://aas.org/ @@ -56,7 +56,11 @@ maintained by ## Dependencies [wwt_kernel_data_relay] is a [Jupyter server extension][ext] so it is only -useful if the Jupyter [notebook] package is installed. +useful if the Jupyter [jupyter_server] package is installed. + +[jupyter_server]: https://jupyter-server.readthedocs.io/ + +It also is compatible with the older (version <= 6) [notebook] server package. [notebook]: https://jupyter-notebook.readthedocs.io/ @@ -69,10 +73,10 @@ useful if the Jupyter [notebook] package is installed. ## Acknowledgments -[wwt_kernel_data_relay] is part of the AAS WorldWide Telescope system, a [.NET -Foundation] project managed by the non-profit [American Astronomical Society] -(AAS). Work on WWT has been supported by the AAS, the US [National Science -Foundation], and other partners. See [the WWT user website][acks] for details. +[wwt_kernel_data_relay] is part of the WorldWide Telescope system, a [.NET +Foundation] project. Work on WWT has been supported by the [American +Astronomical Society] (AAS), the US [National Science Foundation], and other +partners. See [the WWT user website][acks] for details. [.NET Foundation]: https://dotnetfoundation.org/ [American Astronomical Society]: https://aas.org/ diff --git a/ci/azure-build-and-test.yml b/ci/azure-build-and-test.yml index 2396fbd..00b6d63 100644 --- a/ci/azure-build-and-test.yml +++ b/ci/azure-build-and-test.yml @@ -6,17 +6,17 @@ parameters: default: - name: linux_39 - vmImage: ubuntu-20.04 + vmImage: ubuntu-22.04 vars: PYTHON_SERIES: "3.9" - name: macos_39 - vmImage: macos-10.15 + vmImage: macos-12 vars: PYTHON_SERIES: "3.9" - name: windows_39 - vmImage: windows-2019 + vmImage: windows-2022 vars: PYTHON_SERIES: "3.9" @@ -54,7 +54,7 @@ jobs: - job: docs pool: - vmImage: ubuntu-20.04 + vmImage: ubuntu-latest steps: - template: azure-job-setup.yml parameters: diff --git a/ci/azure-deployment.yml b/ci/azure-deployment.yml index fe8d6c5..1d9be78 100644 --- a/ci/azure-deployment.yml +++ b/ci/azure-deployment.yml @@ -18,14 +18,14 @@ jobs: - ${{ if parameters.isMainDev }}: - job: dummy_setup_only pool: - vmImage: ubuntu-20.04 + vmImage: ubuntu-latest steps: - template: azure-job-setup.yml - ${{ if parameters.isRelease }}: - job: branch_and_tag pool: - vmImage: ubuntu-20.04 + vmImage: ubuntu-latest variables: - group: Deployment Credentials steps: @@ -44,7 +44,7 @@ jobs: - job: github_releases dependsOn: branch_and_tag # otherwise, GitHub creates the tag itself pool: - vmImage: ubuntu-20.04 + vmImage: ubuntu-latest variables: - group: Deployment Credentials steps: @@ -61,7 +61,7 @@ jobs: - job: python_publish pool: - vmImage: ubuntu-20.04 + vmImage: ubuntu-latest variables: - group: Deployment Credentials steps: diff --git a/ci/azure-sdist.yml b/ci/azure-sdist.yml index f4e3d3c..aa7e388 100644 --- a/ci/azure-sdist.yml +++ b/ci/azure-sdist.yml @@ -7,7 +7,7 @@ jobs: - job: sdist pool: - vmImage: ubuntu-20.04 + vmImage: ubuntu-latest steps: @@ -53,8 +53,8 @@ jobs: conda config --add channels conda-forge conda install -y \ jupyter_client \ + jupyter_server \ jupyter-packaging \ - notebook \ tornado \ traitlets displayName: Set up dependencies diff --git a/docs/conf.py b/docs/conf.py index a675027..0f719e7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- project = 'wwt_kernel_data_relay' -author = 'The AAS WorldWide Telescope Team' -copyright = '2019-2021 the .NET Foundation' +author = 'The WorldWide Telescope Team' +copyright = '2019-2023 the .NET Foundation' release = '0.dev0' # cranko project-version version = '.'.join(release.split('.')[:2]) @@ -21,7 +21,7 @@ extensions = [ templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' -language = None +language = 'en' exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] pygments_style = 'sphinx' todo_include_todos = False diff --git a/docs/index.rst b/docs/index.rst index 4a79fb0..7c94973 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,7 +9,7 @@ functionality is used by `pywwt`_ to expose kernel-side data assets for visualization inside the `WWT research app`_. .. _wwt_kernel_data_relay: https://github.com/WorldWideTelescope/wwt_kernel_data_relay/ -.. _Jupyter server extension: https://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html +.. _Jupyter server extension: https://jupyter-server.readthedocs.io/en/stable/developers/extensions.html .. _Jupyter kernels: https://jupyter.readthedocs.io/en/latest/projects/kernels.html .. _pywwt: https://pywwt.readthedocs.io/ .. _WWT research app: https://docs.worldwidetelescope.org/research-app/latest/ @@ -37,14 +37,12 @@ issue `on its GitHub repository Acknowledgments =============== -`wwt_kernel_data_relay`_ is part of the `AAS`_ `WorldWide Telescope`_ system, a -`.NET Foundation`_ project managed by the non-profit `American Astronomical -Society`_ (AAS). Work on WWT has been supported by the AAS, the US `National -Science Foundation`_, and other partners. See `the WWT user website`_ for -details. +`wwt_kernel_data_relay`_ is part of the `WorldWide Telescope`_ system, a `.NET +Foundation`_ project. Work on WWT has been supported by the `American +Astronomical Society`_ (AAS), the US `National Science Foundation`_, and other +partners. See `the WWT user website`_ for details. .. _.NET Foundation: https://dotnetfoundation.org/ -.. _AAS: https://aas.org/ .. _WorldWide Telescope: https://worldwidetelescope.org/home/ .. _American Astronomical Society: https://aas.org/ .. _National Science Foundation: https://www.nsf.gov/ diff --git a/docs/specification.rst b/docs/specification.rst index b44a38c..2de6037 100644 --- a/docs/specification.rst +++ b/docs/specification.rst @@ -20,7 +20,7 @@ The URLs that are ultimately provided by the KDR have the form: {base-url}/wwtkdr/{key}/{entry...} -Here, ``base-url`` is the base URL of the Jupyter notebook server, which is +Here, ``base-url`` is the base URL of the Jupyter server, which is easily determined on the server side and is not-so-easily determined on the kernel side. The base URL is not necessarily absolute, however, and there may be different kinds of proxies or redirectors in place that prevent either the @@ -115,7 +115,7 @@ JSON content, the *first* reply message must contain additional fields (analogous to HTTP header data). Every reply message, except for the last one, must also be associated with one or more byte buffers, which contain the resource binary content to be returned to the client that has connected to the -notebook server. The final reply message is allowed to arrive without any +server. The final reply message is allowed to arrive without any associated buffers. The JSON content of the *every* reply message should contain the following fields: diff --git a/pyproject.toml b/pyproject.toml index 73960d6..5d19c8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,6 @@ [build-system] -requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"] +requires = ["jupyter_packaging~=0.10,<2"] build-backend = "jupyter_packaging.build_api" [tool.cranko] -extra_python_rewrite_files = [ - "docs/conf.py" -] +extra_python_rewrite_files = ["docs/conf.py"] diff --git a/setup.py b/setup.py index b18c763..32750eb 100644 --- a/setup.py +++ b/setup.py @@ -57,8 +57,8 @@ setup_args = dict( url="https://github.com/WorldWideTelescope/wwt_kernel_data_relay/", license="MIT", platforms="Linux, Mac OS X, Windows", - author="AAS WorldWide Telescope Team", - author_email="wwt@aas.org", + author="WorldWide Telescope Team", + author_email="hello@worldwidetelescope.org", classifiers=[ "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", @@ -71,12 +71,11 @@ setup_args = dict( ], packages=[ "wwt_kernel_data_relay", - #'wwt_kernel_data_relay.tests', ], include_package_data=True, install_requires=[ "jupyter-client>=7", - "notebook>=6", + "jupyter-server>=2", "tornado>=6", "traitlets>=5", ], diff --git a/wwt_kernel_data_relay/__init__.py b/wwt_kernel_data_relay/__init__.py index 0aa4d44..f7294d1 100644 --- a/wwt_kernel_data_relay/__init__.py +++ b/wwt_kernel_data_relay/__init__.py @@ -9,6 +9,9 @@ It contains no nontrivial functionality of its own. from .serverextension import load_jupyter_server_extension # noqa -# See: https://jupyter-notebook.readthedocs.io/en/stable/examples/Notebook/Distributing%20Jupyter%20Extensions%20as%20Python%20Packages.html -def _jupyter_server_extension_paths(): +# See: https://jupyter.readthedocs.io/en/latest/projects/kernels.html +def _jupyter_server_extension_points(): return [{"module": "wwt_kernel_data_relay.serverextension"}] + +# Backwards compatibility +_jupyter_server_extension_paths = _jupyter_server_extension_points \ No newline at end of file diff --git a/wwt_kernel_data_relay/serverextension.py b/wwt_kernel_data_relay/serverextension.py index 7d81aeb..6722c32 100644 --- a/wwt_kernel_data_relay/serverextension.py +++ b/wwt_kernel_data_relay/serverextension.py @@ -1,4 +1,4 @@ -# Copyright 2021 the .NET Foundation +# Copyright 2021-2023 the .NET Foundation # Licensed under the MIT License """ @@ -8,11 +8,18 @@ The WWT kernel data relay Jupyter notebook server extension. import json from queue import Empty -from tornado import gen, web +from tornado import web from jupyter_client.session import Session -from notebook.utils import url_path_join -from notebook.base.handlers import IPythonHandler + +try: + from jupyter_server.utils import url_path_join + from jupyter_server.base.handlers import JupyterHandler +except ImportError: + # `notebook` <= 6 + from notebook.utils import url_path_join + from notebook.base.handlers import IPythonHandler as JupyterHandler + from traitlets.config.configurable import LoggingConfigurable __all__ = ["load_jupyter_server_extension"] @@ -75,7 +82,7 @@ class Registry(LoggingConfigurable): self.log_debug("watching kernel %s in session %s", kernel_id, session.session) def watch_iopubs(msg_list): - idents, fed_msg_list = session.feed_identities(msg_list) + _idents, fed_msg_list = session.feed_identities(msg_list) msg = session.deserialize(fed_msg_list) msg_type = msg["header"]["msg_type"] @@ -184,7 +191,7 @@ class Registry(LoggingConfigurable): pass -class DataRequestHandler(IPythonHandler): +class DataRequestHandler(JupyterHandler): def initialize(self, registry): self.registry = registry @@ -301,7 +308,7 @@ class DataRequestHandler(IPythonHandler): self.finish() -class ProbeRequestHandler(IPythonHandler): +class ProbeRequestHandler(JupyterHandler): @web.authenticated def get(self): info = {"status": "ok"} @@ -312,7 +319,7 @@ class ProbeRequestHandler(IPythonHandler): self.finish() -def load_jupyter_server_extension(nb_server_app): +def _load_jupyter_server_extension(nb_server_app): """ Initialize the server extension. @@ -356,3 +363,7 @@ def load_jupyter_server_extension(nb_server_app): registry.watch_new_kernel(kernel_id, km) app_km.start_watching_activity = shimmed_start_watching_activity + + +# Backwards compatibility +load_jupyter_server_extension = _load_jupyter_server_extension \ No newline at end of file