From 0c07b8d930ec52b0c4b45a574abc5aa3876f447f Mon Sep 17 00:00:00 2001 From: David Brochart Date: Tue, 9 Apr 2024 18:03:40 +0200 Subject: [PATCH] Replace RetroLab with Notebook (#396) --- .github/workflows/check-release.yml | 2 +- .github/workflows/test.yml | 6 +- CONTRIBUTING.md | 2 +- README.md | 4 +- binder/jupyter_notebook_config.py | 24 ++--- binder/postBuild | 2 +- config.yaml | 4 +- docs/install.md | 18 ++-- docs/plugins/lab.md | 2 +- docs/plugins/notebook.md | 1 + docs/plugins/retrolab.md | 1 - docs/usage/single_user.md | 2 +- .../{retrolab => notebook}/__init__.py | 12 +-- mkdocs.yml | 2 +- plugins/jupyterlab/fps_jupyterlab/routes.py | 4 +- plugins/lab/README.md | 2 +- plugins/lab/fps_lab/routes.py | 2 +- plugins/lab/pyproject.toml | 2 +- plugins/{retrolab => notebook}/COPYING.md | 0 plugins/{retrolab => notebook}/MANIFEST.in | 0 plugins/notebook/README.md | 3 + .../fps_notebook}/__init__.py | 0 .../fps_notebook}/main.py | 10 +- .../fps_notebook}/routes.py | 93 ++++++++++--------- plugins/{retrolab => notebook}/pyproject.toml | 12 +-- plugins/retrolab/README.md | 3 - pyproject.toml | 29 ++++-- 27 files changed, 126 insertions(+), 116 deletions(-) create mode 100644 docs/plugins/notebook.md delete mode 100644 docs/plugins/retrolab.md rename jupyverse_api/jupyverse_api/{retrolab => notebook}/__init__.py (81%) rename plugins/{retrolab => notebook}/COPYING.md (100%) rename plugins/{retrolab => notebook}/MANIFEST.in (100%) create mode 100644 plugins/notebook/README.md rename plugins/{retrolab/fps_retrolab => notebook/fps_notebook}/__init__.py (100%) rename plugins/{retrolab/fps_retrolab => notebook/fps_notebook}/main.py (69%) rename plugins/{retrolab/fps_retrolab => notebook/fps_notebook}/routes.py (69%) rename plugins/{retrolab => notebook}/pyproject.toml (71%) delete mode 100644 plugins/retrolab/README.md diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index 3183c2bf..25ce7d04 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -47,7 +47,7 @@ jobs: pip install -e jupyverse_api pip install -e plugins/frontend pip install -e plugins/jupyterlab - pip install -e plugins/retrolab + pip install -e plugins/notebook pip install -e plugins/contents pip install -e plugins/kernels pip install -e plugins/terminals diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 451d7276..ce82a606 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,9 +32,9 @@ jobs: hatch run dev.jupyterlab-noauth:typecheck hatch run dev.jupyterlab-auth:typecheck hatch run dev.jupyterlab-auth_fief:typecheck - hatch run dev.retrolab-noauth:typecheck - hatch run dev.retrolab-auth:typecheck - hatch run dev.retrolab-auth_fief:typecheck + hatch run dev.notebook-noauth:typecheck + hatch run dev.notebook-auth:typecheck + hatch run dev.notebook-auth_fief:typecheck test: name: Tests diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 868ab27f..6fcd5760 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ cd plugins/auth ; rm -rf dist && python setup.py sdist bdist_wheel ; cp di cd plugins/contents ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. cd plugins/lab ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. cd plugins/jupyterlab ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. -cd plugins/retrolab ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. +cd plugins/notebook ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. cd plugins/kernels ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. cd plugins/nbconvert ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. cd plugins/terminals ; rm -rf dist && python setup.py sdist bdist_wheel ; cp dist/* ../../dist/ ; cd ../.. diff --git a/README.md b/README.md index 1b58da9a..1f351627 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ A set of [Asphalt](https://asphalt.readthedocs.io) components implementing a Jupyter server. Try it online: -- JupyterLab frontend: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyter-server/jupyverse/HEAD?urlpath=jupyverse-jlab) -- RetroLab frontend: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyter-server/jupyverse/HEAD?urlpath=jupyverse-rlab) +- JupyterLab frontend: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyter-server/jupyverse/HEAD?urlpath=jupyverse-jupyterlab) +- Jupyter Notebook frontend: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyter-server/jupyverse/HEAD?urlpath=jupyverse-notebook) Documentation is available [here](https://davidbrochart.github.io/jupyverse). diff --git a/binder/jupyter_notebook_config.py b/binder/jupyter_notebook_config.py index 21f2cea2..ac9e186b 100644 --- a/binder/jupyter_notebook_config.py +++ b/binder/jupyter_notebook_config.py @@ -1,43 +1,43 @@ -jupyverse_jlab_command = " ".join( +jupyverse_jupyterlab_command = " ".join( [ "jupyverse", "--set auth.mode=noauth", "--set frontend.collaborative=true", - "--set frontend.base_url={base_url}jupyverse-jlab/", - "--disable retrolab", + "--set frontend.base_url={base_url}jupyverse-jupyterlab/", + "--disable notebook", "--port={port}", ] - + [">jupyverse_jlab.log 2>&1"] + + [">jupyverse_jupyterlab.log 2>&1"] ) -jupyverse_rlab_command = " ".join( +jupyverse_notebook_command = " ".join( [ "jupyverse", "--set auth.mode=noauth", "--set frontend.collaborative=true", - "--set frontend.base_url={base_url}jupyverse-rlab/", + "--set frontend.base_url={base_url}jupyverse-notebook/", "--disable jupyterlab", "--port={port}", ] - + [">jupyverse_rlab.log 2>&1"] + + [">jupyverse_notebook.log 2>&1"] ) c.ServerProxy.servers = { - "jupyverse-jlab": { - "command": ["/bin/bash", "-c", jupyverse_jlab_command], + "jupyverse-jupyterlab": { + "command": ["/bin/bash", "-c", jupyverse_jupyterlab_command], "timeout": 60, "absolute_url": False, }, - "jupyverse-rlab": { - "command": ["/bin/bash", "-c", jupyverse_rlab_command], + "jupyverse-notebook": { + "command": ["/bin/bash", "-c", jupyverse_notebook_command], "timeout": 60, "absolute_url": False, }, } -c.NotebookApp.default_url = "/jupyverse-jlab" +c.NotebookApp.default_url = "/jupyverse-jupyterlab" import logging diff --git a/binder/postBuild b/binder/postBuild index 7868238d..804bf5b1 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -2,7 +2,7 @@ python -m pip install -e plugins/lab python -m pip install -e plugins/jupyterlab -python -m pip install -e plugins/retrolab +python -m pip install -e plugins/notebook python -m pip install -e plugins/contents python -m pip install -e plugins/kernels python -m pip install -e plugins/terminals diff --git a/config.yaml b/config.yaml index 7a53db6b..1470400f 100644 --- a/config.yaml +++ b/config.yaml @@ -27,8 +27,8 @@ component: resource_usage: type: resource_usage track_cpu_percent: true - #retrolab: - # type: retrolab + #notebook: + # type: notebook terminals: type: terminals yjs: diff --git a/docs/install.md b/docs/install.md index c03d10b1..df09eeee 100644 --- a/docs/install.md +++ b/docs/install.md @@ -1,4 +1,4 @@ -Jupyverse can be installed to run either [JupyterLab](https://jupyterlab.readthedocs.io) or [RetroLab](https://github.com/jupyterlab/retrolab). +Jupyverse can be installed to run either [JupyterLab](https://jupyterlab.readthedocs.io) or [Jupyter Notebook](https://jupyter-notebook.readthedocs.io). ## With `pip` @@ -6,9 +6,9 @@ For the JupyterLab frontend: ```bash pip install "jupyverse[jupyterlab,auth]" ``` -Or for the RetroLab frontend: +Or for the Jupyter Notebook frontend: ```bash -pip install "jupyverse[retrolab,auth]" +pip install "jupyverse[notebook,auth]" ``` ## With `micromamba` @@ -27,9 +27,9 @@ For the JupyterLab frontend: ```bash micromamba install -c conda-forge jupyverse fps-jupyterlab fps-auth ``` -Or for the RetroLab frontend: +Or for the Jupyter Notebook frontend: ```bash -micromamba install -c conda-forge jupyverse fps-retrolab fps-auth +micromamba install -c conda-forge jupyverse fps-notebook fps-auth ``` ## Development install @@ -69,9 +69,9 @@ Entering `hatch env show` will show the available environments: │ dev │ virtual │ dev.jupyterlab-noauth │ test │ lint │ │ │ │ dev.jupyterlab-auth │ │ test │ │ │ │ dev.jupyterlab-auth_fief │ │ typecheck │ -│ │ │ dev.retrolab-noauth │ │ │ -│ │ │ dev.retrolab-auth │ │ │ -│ │ │ dev.retrolab-auth_fief │ │ │ +│ │ │ dev.notebook-noauth │ │ │ +│ │ │ dev.notebook-auth │ │ │ +│ │ │ dev.notebook-auth_fief │ │ │ └──────┴─────────┴──────────────────────────┴──────────┴───────────┘ ``` !!! note @@ -80,7 +80,7 @@ Entering `hatch env show` will show the available environments: from your local repository. So you want to use the `dev` environment. Currently, the `dev` environment matrix consists of all combinations of frontends -(`jupyterlab`, `retrolab`) and authentication methods (`noauth`, `auth`, `auth_fief`), +(`jupyterlab`, `notebook`) and authentication methods (`noauth`, `auth`, `auth_fief`), which leads to six environments. A number of scripts are available in the `dev` environments. They can be diff --git a/docs/plugins/lab.md b/docs/plugins/lab.md index 9f6df062..2b82a5a8 100644 --- a/docs/plugins/lab.md +++ b/docs/plugins/lab.md @@ -1 +1 @@ -`fps-lab` implements everything that is common to JupyterLab and RetroLab. +`fps-lab` implements everything that is common to JupyterLab and Jupyter Notebook. diff --git a/docs/plugins/notebook.md b/docs/plugins/notebook.md new file mode 100644 index 00000000..5a739bc2 --- /dev/null +++ b/docs/plugins/notebook.md @@ -0,0 +1 @@ +`fps-notebook` implements the Notebook API. diff --git a/docs/plugins/retrolab.md b/docs/plugins/retrolab.md deleted file mode 100644 index 12f16872..00000000 --- a/docs/plugins/retrolab.md +++ /dev/null @@ -1 +0,0 @@ -`fps-retrolab` implements the RetroLab API. diff --git a/docs/usage/single_user.md b/docs/usage/single_user.md index fbe947cd..7584bad4 100644 --- a/docs/usage/single_user.md +++ b/docs/usage/single_user.md @@ -11,7 +11,7 @@ This is the default mode when launching Jupyverse, just enter in a terminal: jupyverse --open-browser # same as: jupyverse --set auth.mode=token --open-browser ``` -This should open a new window in a browser, and load JupyterLab or RetroLab, depending on the front-end you chose to install (see [Install](../../install)). +This should open a new window in a browser, and load JupyterLab or Jupyter Notebook, depending on the front-end you chose to install (see [Install](../../install)). If you look at the terminal, you should see among other things: ``` diff --git a/jupyverse_api/jupyverse_api/retrolab/__init__.py b/jupyverse_api/jupyverse_api/notebook/__init__.py similarity index 81% rename from jupyverse_api/jupyverse_api/retrolab/__init__.py rename to jupyverse_api/jupyverse_api/notebook/__init__.py index 113f91ed..bd01049e 100644 --- a/jupyverse_api/jupyverse_api/retrolab/__init__.py +++ b/jupyverse_api/jupyverse_api/notebook/__init__.py @@ -10,40 +10,40 @@ from ..lab import Lab -class RetroLab(Router, ABC): +class Notebook(Router, ABC): def __init__(self, app: App, auth: Auth, lab: Lab): super().__init__(app=app) router = APIRouter() - @router.get("/retro/tree", response_class=HTMLResponse) + @router.get("/tree", response_class=HTMLResponse) async def get_tree( user: User = Depends(auth.current_user()), ): return await self.get_tree(user) - @router.get("/retro/notebooks/{path:path}", response_class=HTMLResponse) + @router.get("/notebooks/{path:path}", response_class=HTMLResponse) async def get_notebook( path, user: User = Depends(auth.current_user()), ): return await self.get_notebook(path, user) - @router.get("/retro/edit/{path:path}", response_class=HTMLResponse) + @router.get("/edit/{path:path}", response_class=HTMLResponse) async def edit_file( path, user: User = Depends(auth.current_user()), ): return await self.edit_file(path, user) - @router.get("/retro/consoles/{path:path}", response_class=HTMLResponse) + @router.get("/consoles/{path:path}", response_class=HTMLResponse) async def get_console( path, user: User = Depends(auth.current_user()), ): return await self.get_console(path, user) - @router.get("/retro/terminals/{name}", response_class=HTMLResponse) + @router.get("/terminals/{name}", response_class=HTMLResponse) async def get_terminal( name: str, user: User = Depends(auth.current_user()), diff --git a/mkdocs.yml b/mkdocs.yml index 58033abe..25a5f5d5 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -44,7 +44,7 @@ nav: - 'frontend': plugins/frontend.md - 'lab': plugins/lab.md - 'jupyterlab': plugins/jupyterlab.md - - 'retrolab': plugins/retrolab.md + - 'notebook': plugins/notebook.md - 'nbconvert': plugins/nbconvert.md - 'login': plugins/login.md - 'kernels': plugins/kernels.md diff --git a/plugins/jupyterlab/fps_jupyterlab/routes.py b/plugins/jupyterlab/fps_jupyterlab/routes.py index 6f600d22..1e8229df 100644 --- a/plugins/jupyterlab/fps_jupyterlab/routes.py +++ b/plugins/jupyterlab/fps_jupyterlab/routes.py @@ -34,7 +34,7 @@ def __init__( lab.redirect_after_root = "lab" extensions_dir = lab.prefix_dir / "share" / "jupyter" / "labextensions" - self.federated_extensions, self.disabled_extension = lab.get_federated_extensions( + self.federated_extensions, self.disabled_extensions = lab.get_federated_extensions( extensions_dir ) jupyterlab_dir = Path(jupyterlab_module.__file__).parents[1] @@ -126,7 +126,7 @@ def get_index(self, workspace, collaborative, server_side_execution, dev_mode, b "collaborative": collaborative, "serverSideExecution": server_side_execution, "devMode": dev_mode, - "disabledExtensions": self.disabled_extension, + "disabledExtensions": self.disabled_extensions, "exposeAppInBrowser": False, "extraLabextensionsPath": [], "federated_extensions": self.federated_extensions, diff --git a/plugins/lab/README.md b/plugins/lab/README.md index a5f0813a..63ea4d65 100644 --- a/plugins/lab/README.md +++ b/plugins/lab/README.md @@ -1,3 +1,3 @@ # fps-lab -An FPS plugin for the JupyterLab/RetroLab API. +An FPS plugin for the JupyterLab/Notebook API. diff --git a/plugins/lab/fps_lab/routes.py b/plugins/lab/fps_lab/routes.py index 2fb98aa9..339579e9 100644 --- a/plugins/lab/fps_lab/routes.py +++ b/plugins/lab/fps_lab/routes.py @@ -120,7 +120,7 @@ async def get_setting( ): with open(self.jlab_dir / "static" / "package.json") as f: package = json.load(f) - if name0 in ["@jupyterlab", "@retrolab"]: + if name0 in ["@jupyterlab", "@notebook"]: schemas_parent = self.jlab_dir else: schemas_parent = self.extensions_dir / name0 / name1 diff --git a/plugins/lab/pyproject.toml b/plugins/lab/pyproject.toml index a68240be..094eecff 100644 --- a/plugins/lab/pyproject.toml +++ b/plugins/lab/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "fps_lab" -description = "An FPS plugin for the JupyterLab/RetroLab API" +description = "An FPS plugin for the JupyterLab/Notebook API" keywords = ["jupyter", "server", "fastapi", "plugins"] requires-python = ">=3.8" dependencies = [ diff --git a/plugins/retrolab/COPYING.md b/plugins/notebook/COPYING.md similarity index 100% rename from plugins/retrolab/COPYING.md rename to plugins/notebook/COPYING.md diff --git a/plugins/retrolab/MANIFEST.in b/plugins/notebook/MANIFEST.in similarity index 100% rename from plugins/retrolab/MANIFEST.in rename to plugins/notebook/MANIFEST.in diff --git a/plugins/notebook/README.md b/plugins/notebook/README.md new file mode 100644 index 00000000..48accb0d --- /dev/null +++ b/plugins/notebook/README.md @@ -0,0 +1,3 @@ +# fps-notebook + +An FPS plugin for the Notebook API. diff --git a/plugins/retrolab/fps_retrolab/__init__.py b/plugins/notebook/fps_notebook/__init__.py similarity index 100% rename from plugins/retrolab/fps_retrolab/__init__.py rename to plugins/notebook/fps_notebook/__init__.py diff --git a/plugins/retrolab/fps_retrolab/main.py b/plugins/notebook/fps_notebook/main.py similarity index 69% rename from plugins/retrolab/fps_retrolab/main.py rename to plugins/notebook/fps_notebook/main.py index 38b4d342..31521a06 100644 --- a/plugins/retrolab/fps_retrolab/main.py +++ b/plugins/notebook/fps_notebook/main.py @@ -4,12 +4,12 @@ from jupyverse_api.auth import Auth from jupyverse_api.frontend import FrontendConfig from jupyverse_api.lab import Lab -from jupyverse_api.retrolab import RetroLab +from jupyverse_api.notebook import Notebook -from .routes import _RetroLab +from .routes import _Notebook -class RetroLabComponent(Component): +class NotebookComponent(Component): async def start( self, ctx: Context, @@ -19,5 +19,5 @@ async def start( frontend_config = await ctx.request_resource(FrontendConfig) lab = await ctx.request_resource(Lab) # type: ignore - retrolab = _RetroLab(app, auth, frontend_config, lab) - ctx.add_resource(retrolab, types=RetroLab) + notebook = _Notebook(app, auth, frontend_config, lab) + ctx.add_resource(notebook, types=Notebook) diff --git a/plugins/retrolab/fps_retrolab/routes.py b/plugins/notebook/fps_notebook/routes.py similarity index 69% rename from plugins/retrolab/fps_retrolab/routes.py rename to plugins/notebook/fps_notebook/routes.py index b35ba971..b93a98e4 100644 --- a/plugins/retrolab/fps_retrolab/routes.py +++ b/plugins/notebook/fps_notebook/routes.py @@ -1,52 +1,44 @@ import json from pathlib import Path -import retrolab # type: ignore +import notebook # type: ignore from fastapi.staticfiles import StaticFiles from jupyverse_api.app import App from jupyverse_api.auth import Auth, User from jupyverse_api.frontend import FrontendConfig from jupyverse_api.lab import Lab -from jupyverse_api.retrolab import RetroLab +from jupyverse_api.notebook import Notebook -class _RetroLab(RetroLab): +class _Notebook(Notebook): def __init__(self, app: App, auth: Auth, frontend_config: FrontendConfig, lab: Lab) -> None: super().__init__(app, auth, lab) self.frontend_config = frontend_config self.lab = lab - self.lab.redirect_after_root = "retro/tree" + self.lab.redirect_after_root = "tree" - self.retrolab_dir = Path(retrolab.__file__).parent + extensions_dir = lab.prefix_dir / "share" / "jupyter" / "labextensions" + self.federated_extensions, self.disabled_extensions = lab.get_federated_extensions( + extensions_dir + ) + self.notebook_dir = Path(notebook.__file__).parent self.mount( - "/static/retro", - StaticFiles(directory=self.retrolab_dir / "static"), + "/static/notebook", + StaticFiles(directory=self.notebook_dir / "static"), name="static", ) - for path in (self.retrolab_dir / "labextension" / "static").glob("remoteEntry.*.js"): - load = f"static/{path.name}" - break - - self.retro_federated_extensions = [ - { - "extension": "./extension", - "load": load, - "name": "@retrolab/lab-extension", - "style": "./style", - } - ] - async def get_tree( self, user: User, ): return get_index( self.lab, - self.retrolab_dir, - self.retro_federated_extensions, + self.notebook_dir, + self.federated_extensions, + self.disabled_extensions, "Tree", "tree", self.frontend_config.collaborative, @@ -60,8 +52,9 @@ async def get_notebook( ): return get_index( self.lab, - self.retrolab_dir, - self.retro_federated_extensions, + self.notebook_dir, + self.federated_extensions, + self.disabled_extensions, path, "notebooks", self.frontend_config.collaborative, @@ -75,8 +68,9 @@ async def edit_file( ): return get_index( self.lab, - self.retrolab_dir, - self.retro_federated_extensions, + self.notebook_dir, + self.federated_extensions, + self.disabled_extensions, path, "edit", self.frontend_config.collaborative, @@ -90,8 +84,9 @@ async def get_console( ): return get_index( self.lab, - self.retrolab_dir, - self.retro_federated_extensions, + self.notebook_dir, + self.federated_extensions, + self.disabled_extensions, path, "consoles", self.frontend_config.collaborative, @@ -105,8 +100,9 @@ async def get_terminal( ): return get_index( self.lab, - self.retrolab_dir, - self.retro_federated_extensions, + self.notebook_dir, + self.federated_extensions, + self.disabled_extensions, name, "terminals", self.frontend_config.collaborative, @@ -120,7 +116,7 @@ async def get_terminal( - RetroLab - DOC_NAME + Notebook - DOC_NAME @@ -128,7 +124,7 @@ async def get_terminal( - +