lydian / jupyterlab_hubshare

jupyterlab extension to help share jupyter notebook in jupyterhub
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

Copy Sharable Link error when using this extension in The Littlest JupyterHub(TLJH) #1

Closed Comee closed 3 years ago

Comee commented 3 years ago

config this extension using case 2: User have their own work space but can still access others workspace

image

jupyter-shaozl@xl-Standard-PC-i440FX-PIIX-1996:~$ jupyter server extension list
Config dir: /home/jupyter-shaozl/.jupyter

Config dir: /opt/tljh/user/etc/jupyter
    jupyter_lsp enabled
    - Validating jupyter_lsp...
      jupyter_lsp 1.1.4 OK
    jupyter_server_proxy enabled
    - Validating jupyter_server_proxy...
      jupyter_server_proxy  OK
    jupyter_resource_usage enabled
    - Validating jupyter_resource_usage...
      jupyter_resource_usage  OK
    jupyter_server_mathjax enabled
    - Validating jupyter_server_mathjax...
      jupyter_server_mathjax  OK
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.0.14 OK
    jupyterlab_git enabled
    - Validating jupyterlab_git...
      jupyterlab_git 0.30.0 OK
    jupyterlab_hubshare enabled
    - Validating jupyterlab_hubshare...
      jupyterlab_hubshare 0.2.0 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK
    nbdime enabled
    - Validating nbdime...
      nbdime 3.0.0 OK

Config dir: /usr/local/etc/jupyter

jupyter-shaozl@xl-Standard-PC-i440FX-PIIX-1996:~$ 
lydian commented 3 years ago

the error looks like the server extension is not successfully installed. That's why you're seeing the 404. Would you be able to find any logs on your server to see why the server extension is not successfully activated?

Comee commented 3 years ago

server extension validating failed.

- Validating...
      X is jupyterlab_hubshare importable?
jupyter-shaozl@xl-Standard-PC-i440FX-PIIX-1996:~$ sudo -E jupyter serverextension list
config dir: /opt/tljh/user/etc/jupyter
    jupyter_lsp  enabled 
    - Validating...
      jupyter_lsp 1.1.4 OK
    jupyter_server_proxy  enabled 
    - Validating...
      jupyter_server_proxy  OK
    jupyter_resource_usage  enabled 
    - Validating...
      jupyter_resource_usage  OK
    jupyterlab  enabled 
    - Validating...
      jupyterlab 3.0.14 OK
    jupyterlab_git  enabled 
    - Validating...
      jupyterlab_git 0.30.0 OK
    nbdime  enabled 
    - Validating...
      nbdime 3.0.0 OK
    nbgitpuller  enabled 
    - Validating...
      nbgitpuller 0.9.0 OK
    nteract_on_jupyter  enabled 
    - Validating...
      nteract_on_jupyter 2.1.3 OK
    jupyter_nbextensions_configurator  enabled 
    - Validating...
      jupyter_nbextensions_configurator 0.4.1 OK
    jupyterlab_hubshare  enabled 
    - Validating...
      X is jupyterlab_hubshare importable?
jupyter-shaozl@xl-Standard-PC-i440FX-PIIX-1996:~$ 
Comee commented 3 years ago

After this method

https://github.com/lydian/jupyterlab_hubshare/blob/182c2f48f91e06a633cc6c6d715148796b832d00/jupyterlab_hubshare/__init__.py#L21

I added follow line, then it worked

# For backward compatibility
load_jupyter_server_extension = _load_jupyter_server_extension

before (not work in TLJH)

from .handlers import setup_handlers
import json
from pathlib import Path

from ._version import __version__  # noqa

HERE = Path(__file__).parent.resolve()

with (HERE / "labextension" / "package.json").open() as fid:
    data = json.load(fid)

def _jupyter_labextension_paths():
    return [{"src": "labextension", "dest": data["name"]}]

def _jupyter_server_extension_points():
    return [{"module": "jupyterlab_hubshare"}]

def _load_jupyter_server_extension(server_app):
    """Registers the API handler to receive HTTP requests from the frontend extension.
    Parameters
    ----------
    server_app: jupyterlab.labapp.LabApp
        JupyterLab application instance
    """
    setup_handlers(server_app.web_app)
    server_app.log.info(
        "Registered Jupytelab_hubshare extension at URL path /jupyterlab_hubshare"
    )

after (work in TLJH)

from .handlers import setup_handlers
import json
from pathlib import Path

from ._version import __version__  # noqa

HERE = Path(__file__).parent.resolve()

with (HERE / "labextension" / "package.json").open() as fid:
    data = json.load(fid)

def _jupyter_labextension_paths():
    return [{"src": "labextension", "dest": data["name"]}]

def _jupyter_server_extension_points():
    return [{"module": "jupyterlab_hubshare"}]

def _load_jupyter_server_extension(server_app):
    """Registers the API handler to receive HTTP requests from the frontend extension.
    Parameters
    ----------
    server_app: jupyterlab.labapp.LabApp
        JupyterLab application instance
    """
    setup_handlers(server_app.web_app)
    server_app.log.info(
        "Registered Jupytelab_hubshare extension at URL path /jupyterlab_hubshare"
    )

# For backward compatibility
load_jupyter_server_extension = _load_jupyter_server_extension
lydian commented 3 years ago

ah thanks! would you mind send a pull request directly?