jyio / jupyter-marimo-proxy

Jupyter + Marimo = ❤️
Apache License 2.0
22 stars 5 forks source link

marimo icon doesn't appear in JupyterHub #2

Closed s-celles closed 5 months ago

s-celles commented 5 months ago

Hello,

Following https://github.com/marimo-team/marimo/issues/905

Thanks @jyio for the great work on this JupyterHub / Marimo proxy.

I tried to install it on my own install (a VPS where JupyterHub is running behind a Traefik reverse proxy).

My install is just a bit more complex than the minimal demo you provided.

After trying to install proxy I can't see marimo icon on the hub (when I spawn container)

Here is my docker-compose.yml

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

# JupyterHub docker compose configuration file
version: "3"

services:
  hub:
    build:
      context: .
      dockerfile: Dockerfile.jupyterhub
      args:
        JUPYTERHUB_VERSION: latest
    restart: always
    image: jupyterhub
    container_name: jupyterhub
    networks:
      - web
    volumes:
      # The JupyterHub configuration file
      - "./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py:ro"
      # Bind Docker socket on the host so we can connect to the daemon from
      # within the container
      - "/var/run/docker.sock:/var/run/docker.sock:rw"
      # Bind Docker volume on host for JupyterHub database and cookie secrets
      - "jupyterhub-data:/data"
      # - "~/data:/data/shared_data:ro"  # scls: should be on spawn image
    #ports:
    #  - "8000:8000"
    environment:
      # This username will be a JupyterHub admin
      JUPYTERHUB_ADMIN: ${JUPYTERHUB_ADMIN}
      # All containers will join this network
      DOCKER_NETWORK_NAME: web
      # JupyterHub will spawn this Notebook image for users
      #DOCKER_NOTEBOOK_IMAGE: quay.io/jupyter/base-notebook:latest
      #DOCKER_NOTEBOOK_IMAGE: quay.io/jupyter/julia-notebook:2024-03-06
      DOCKER_NOTEBOOK_IMAGE: custom-scls-notebook
      # Notebook directory inside user image
      DOCKER_NOTEBOOK_DIR: /home/jovyan/work

    labels:
      - "traefik.enable=true"
      - "traefik.http.services.jupyterhub.loadbalancer.server.port=8000"
      - "traefik.http.routers.jupyterhub.rule=Host(`${JUPYTERHUB_URL}`)"
      - "traefik.http.routers.jupyterhub.entrypoints=websecure"
      - "traefik.http.routers.jupyterhub.service=jupyterhub"
      - "traefik.http.routers.jupyterhub.tls=true"
      - "traefik.http.routers.jupyterhub.tls.certresolver=default"

volumes:
  jupyterhub-data:
  jupyterhub-user-scelles:
    external: true

networks:
  web:
    external: true

I have two Dockerfiles (one for the Hub and one for spawn containers)

Dockerfile.jupyterhub

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG JUPYTERHUB_VERSION
FROM quay.io/jupyterhub/jupyterhub:$JUPYTERHUB_VERSION

# Install dockerspawner, nativeauthenticator
# hadolint ignore=DL3013
RUN python3 -m pip install --no-cache-dir \
    dockerspawner \
    jupyterhub-nativeauthenticator && \
    pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip

CMD ["jupyterhub", "-f", "/srv/jupyterhub/jupyterhub_config.py"]

I added the line

pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip

but I'm not sure that it should be done there... but on

Dockerfile.custom-scls-notebook

FROM quay.io/jupyter/julia-notebook:2024-03-06

#USER root
#RUN apt-get update
#RUN apt install -f -y \
#    postgresql \
#    python3-pytest
#
#
USER $NB_UID
COPY environment.yml /tmp/environment.yml
ARG env_name=condaenv

RUN mamba env create -f /tmp/environment.yml -n $env_name && \
    mamba clean -qafy && \
    mamba run -n $env_name python -m ipykernel install --user --name=$env_name

ENV PATH /opt/conda/envs/$env_name/bin:$PATH  # added by scls

#RUN python3 -m pip install --no-cache-dir \
#    pipx \
#    nbdev \
#    python-dotenv \
#    pandas \
#    psycopg2-binary

#RUN pipx install \
#    python-dotenv \
#    poetry \
#    #nbdev

RUN pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip

Any idea why I don't see marimo icon in the spawn container?

Kind regards

jyio commented 5 months ago

Hey, thank you for trying this out. I do have an idea. If I understand correctly, you've got a JupyterHub container that uses dockerspawner to launch single-user containers. This is the type of setup that I use, with a slight difference:

I see that you're using mamba in your single-user containers for Python package management. If mamba is anything like conda, I imagine it'd install its own distribution of Python, which would take precedence because of your $PATH.

I'm not sure what happens if you then used pip to install more packages -- if this pip is part of your base system, it'd probably install packages into the base system, which would be invisible to your mamba environment.

So, is there any way to install marimo and jupyter-marimo-proxy using mamba?

(I'm not sure how you'd use mamba to install a package directly from GitHub, but if you could use mamba to install pip, then mamba's pip should install stuff into the mamba environment)

s-celles commented 5 months ago

What I can say is that marimo command line is available in terminal of spawn container.

See

image

and

image

jyio commented 5 months ago

Well, let's find out who your pip belongs to:

$ which pip

If it's not the one that's part of the mamba environment, you might want to try installing it into the mamba environment (but beware, this would override your system pip until you uninstalled it from your mamba environment):

$ mamba install pip
$ which pip

Then you could do

$ pip install https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip
s-celles commented 5 months ago

Here are results

(base) jovyan@014bf5a5c49d:~$ which pip
/opt/conda/bin/pip
(base) jovyan@014bf5a5c49d:~$ mamba install pip

Looking for: ['pip']

conda-forge/noarch                                  15.1MB @  10.1MB/s  1.5s
conda-forge/linux-64                                35.5MB @  12.4MB/s  2.9s

Pinned packages:
  - python 3.11.*
  - python 3.11.*

Transaction

  Prefix: /opt/conda

  Updating specs:

   - pip
   - ca-certificates
   - certifi
   - openssl

  Package             Version  Build         Channel          Size
────────────────────────────────────────────────────────────────────
  Upgrade:
────────────────────────────────────────────────────────────────────

  - ca-certificates  2024.2.2  hbcca054_0    conda-forge     155kB
  + ca-certificates  2024.6.2  hbcca054_0    conda-forge     156kB
  - openssl             3.2.1  hd590300_0    conda-forge       3MB
  + openssl             3.3.1  h4ab18f5_0    conda-forge       3MB
  - certifi          2024.2.2  pyhd8ed1ab_0  conda-forge     161kB
  + certifi          2024.6.2  pyhd8ed1ab_0  conda-forge     161kB

  Summary:

  Upgrade: 3 packages

  Total download: 3MB

────────────────────────────────────────────────────────────────────

Confirm changes: [Y/n] y
ca-certificates                                    156.0kB @   1.6MB/s  0.1s
openssl                                              2.9MB @  22.3MB/s  0.1s
certifi                                            160.5kB @   1.2MB/s  0.1s

Downloading and Extracting Packages:

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) jovyan@014bf5a5c49d:~$ which pip
/opt/conda/bin/pip
(base) jovyan@014bf5a5c49d:~$ pip install https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip
Collecting https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip
  Downloading https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip
     - 12.5 kB 54.2 MB/s 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: jupyter-server-proxy in /opt/conda/lib/python3.11/site-packages (from jupyter-marimo-proxy==0.0.0) (4.1.0)
Requirement already satisfied: aiohttp in /opt/conda/lib/python3.11/site-packages (from jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (3.9.3)
Requirement already satisfied: jupyter-server>=1.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.13.0)
Requirement already satisfied: simpervisor>=1.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.0.0)
Requirement already satisfied: anyio>=3.1.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (4.3.0)
Requirement already satisfied: argon2-cffi in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (23.1.0)
Requirement already satisfied: jinja2 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (3.1.3)
Requirement already satisfied: jupyter-client>=7.4.4 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (8.6.0)
Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (5.7.1)
Requirement already satisfied: jupyter-events>=0.9.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.9.0)
Requirement already satisfied: jupyter-server-terminals in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.5.2)
Requirement already satisfied: nbconvert>=6.4.4 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (7.16.2)
Requirement already satisfied: nbformat>=5.3.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (5.9.2)
Requirement already satisfied: overrides in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (7.7.0)
Requirement already satisfied: packaging in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (23.2)
Requirement already satisfied: prometheus-client in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.20.0)
Requirement already satisfied: pyzmq>=24 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (25.1.2)
Requirement already satisfied: send2trash>=1.8.2 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.8.2)
Requirement already satisfied: terminado>=0.8.3 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.18.0)
Requirement already satisfied: tornado>=6.2.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (6.4)
Requirement already satisfied: traitlets>=5.6.0 in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (5.14.1)
Requirement already satisfied: websocket-client in /opt/conda/lib/python3.11/site-packages (from jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.7.0)
Requirement already satisfied: aiosignal>=1.1.2 in /opt/conda/lib/python3.11/site-packages (from aiohttp->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.3.1)
Requirement already satisfied: attrs>=17.3.0 in /opt/conda/lib/python3.11/site-packages (from aiohttp->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (23.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in /opt/conda/lib/python3.11/site-packages (from aiohttp->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.4.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /opt/conda/lib/python3.11/site-packages (from aiohttp->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (6.0.5)
Requirement already satisfied: yarl<2.0,>=1.0 in /opt/conda/lib/python3.11/site-packages (from aiohttp->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.9.4)
Requirement already satisfied: idna>=2.8 in /opt/conda/lib/python3.11/site-packages (from anyio>=3.1.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (3.6)
Requirement already satisfied: sniffio>=1.1 in /opt/conda/lib/python3.11/site-packages (from anyio>=3.1.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.3.1)
Requirement already satisfied: python-dateutil>=2.8.2 in /opt/conda/lib/python3.11/site-packages (from jupyter-client>=7.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.9.0)
Requirement already satisfied: platformdirs>=2.5 in /opt/conda/lib/python3.11/site-packages (from jupyter-core!=5.0.*,>=4.12->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (4.2.0)
Requirement already satisfied: jsonschema>=4.18.0 in /opt/conda/lib/python3.11/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (4.21.1)
Requirement already satisfied: python-json-logger>=2.0.4 in /opt/conda/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.0.7)
Requirement already satisfied: pyyaml>=5.3 in /opt/conda/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (6.0.1)
Requirement already satisfied: referencing in /opt/conda/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.33.0)
Requirement already satisfied: rfc3339-validator in /opt/conda/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.1.4)
Requirement already satisfied: rfc3986-validator>=0.1.1 in /opt/conda/lib/python3.11/site-packages (from jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.1.1)
Requirement already satisfied: beautifulsoup4 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (4.12.3)
Requirement already satisfied: bleach!=5.0.0 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (6.1.0)
Requirement already satisfied: defusedxml in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.7.1)
Requirement already satisfied: jupyterlab-pygments in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.3.0)
Requirement already satisfied: markupsafe>=2.0 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.1.5)
Requirement already satisfied: mistune<4,>=2.0.3 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (3.0.2)
Requirement already satisfied: nbclient>=0.5.0 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.8.0)
Requirement already satisfied: pandocfilters>=1.4.1 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.5.0)
Requirement already satisfied: pygments>=2.4.1 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.17.2)
Requirement already satisfied: tinycss2 in /opt/conda/lib/python3.11/site-packages (from nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.2.1)
Requirement already satisfied: fastjsonschema in /opt/conda/lib/python3.11/site-packages (from nbformat>=5.3.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.19.1)
Requirement already satisfied: ptyprocess in /opt/conda/lib/python3.11/site-packages (from terminado>=0.8.3->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.7.0)
Requirement already satisfied: argon2-cffi-bindings in /opt/conda/lib/python3.11/site-packages (from argon2-cffi->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (21.2.0)
Requirement already satisfied: six>=1.9.0 in /opt/conda/lib/python3.11/site-packages (from bleach!=5.0.0->nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.16.0)
Requirement already satisfied: webencodings in /opt/conda/lib/python3.11/site-packages (from bleach!=5.0.0->nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.5.1)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /opt/conda/lib/python3.11/site-packages (from jsonschema>=4.18.0->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2023.12.1)
Requirement already satisfied: rpds-py>=0.7.1 in /opt/conda/lib/python3.11/site-packages (from jsonschema>=4.18.0->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (0.18.0)
Requirement already satisfied: fqdn in /opt/conda/lib/python3.11/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.5.1)
Requirement already satisfied: isoduration in /opt/conda/lib/python3.11/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (20.11.0)
Requirement already satisfied: jsonpointer>1.13 in /opt/conda/lib/python3.11/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.4)
Requirement already satisfied: uri-template in /opt/conda/lib/python3.11/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.3.0)
Requirement already satisfied: webcolors>=1.11 in /opt/conda/lib/python3.11/site-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.13)
Requirement already satisfied: cffi>=1.0.1 in /opt/conda/lib/python3.11/site-packages (from argon2-cffi-bindings->argon2-cffi->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.16.0)
Requirement already satisfied: soupsieve>1.2 in /opt/conda/lib/python3.11/site-packages (from beautifulsoup4->nbconvert>=6.4.4->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.5)
Requirement already satisfied: pycparser in /opt/conda/lib/python3.11/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.21)
Requirement already satisfied: arrow>=0.15.0 in /opt/conda/lib/python3.11/site-packages (from isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (1.3.0)
Requirement already satisfied: types-python-dateutil>=2.8.10 in /opt/conda/lib/python3.11/site-packages (from arrow>=0.15.0->isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.9.0->jupyter-server>=1.0->jupyter-server-proxy->jupyter-marimo-proxy==0.0.0) (2.8.19.20240106)
Building wheels for collected packages: jupyter-marimo-proxy
  Building wheel for jupyter-marimo-proxy (setup.py) ... done
  Created wheel for jupyter-marimo-proxy: filename=jupyter_marimo_proxy-0.0.0-py3-none-any.whl size=11277 sha256=72bf9aff7a17d1178b03c6c89a01b92446509ff61eefb849f78d143a59cf9183
  Stored in directory: /tmp/pip-ephem-wheel-cache-3wjw2rpe/wheels/4a/d7/9c/0c22385b7ffd1d5c492bfe6b51bc634fb96337d437ee7e27e5
Successfully built jupyter-marimo-proxy
Installing collected packages: jupyter-marimo-proxy
Successfully installed jupyter-marimo-proxy-0.0.0
jyio commented 5 months ago

Thank you for experimenting with this. I tried to distill your setup down to the bare minimum (JupyterHub, vanilla process spawner, dummy authenticator, and Mamba).

After tinkering with this a little bit, I realized that I got it wrong: JupyterLab (from the quay.io/jupyter namespace) is run using the operating system's Python and would only work with packages installed using the operating system's pip. Packages installed using Mamba's or Conda's pip are essentially invisible to Jupyter. To tell Jupyter about your Mamba/Conda environment, you had to do a little dance with mamba run ... python -m ipykernel install ...

So this Dockerfile that uses pip from $PATH (which resolves to the Mamba/Conda environment) to install jupyter-marimo-proxy fails.

But tweak line 18 slightly to use pip from the operating system, and it works. What do you think?


So, in your spawn container Dockerfile, we should try changing the new addition...

RUN pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip

... to the following:

RUN /usr/bin/pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip

Btw, you don't need marimo or jupyter-marimo-proxy in the main hub 😉

s-celles commented 5 months ago
RUN /usr/bin/pip install ...

doesn't work when buiding custom-scls-notebook image

$ docker build -t custom-scls-notebook . -f Dockerfile.custom-scls-notebook

raises

[+] Building 0.3s (8/8) FINISHED                                                                                                                                                                                              docker:default
 => [internal] load build definition from Dockerfile.custom-scls-notebook                                                                                                                                                               0.0s
 => => transferring dockerfile: 1.05kB                                                                                                                                                                                                  0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                       0.0s
 => => transferring context: 67B                                                                                                                                                                                                        0.0s
 => [internal] load metadata for quay.io/jupyter/julia-notebook:2024-03-06                                                                                                                                                              0.1s
 => [internal] load build context                                                                                                                                                                                                       0.0s
 => => transferring context: 37B                                                                                                                                                                                                        0.0s
 => [1/4] FROM quay.io/jupyter/julia-notebook:2024-03-06@sha256:40b80d273818925ed38c4c8c4a04cba9b80b38ca74bf9e15138bb7aaa4e95de2                                                                                                        0.0s
 => CACHED [2/4] COPY environment.yml /tmp/environment.yml                                                                                                                                                                              0.0s
 => CACHED [3/4] RUN mamba env create -f /tmp/environment.yml -n condaenv &&     mamba clean -qafy &&     mamba run -n condaenv python -m ipykernel install --user --name=condaenv                                                      0.0s
 => ERROR [4/4] RUN /usr/bin/pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip                                                                                         0.2s
------
 > [4/4] RUN /usr/bin/pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip:
0.177 /bin/bash: line 1: /usr/bin/pip: No such file or directory
------
Dockerfile.custom-scls-notebook:40
--------------------
  38 |     #    #nbdev
  39 |
  40 | >>> RUN /usr/bin/pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip
  41 |
  42 |
--------------------
ERROR: failed to solve: process "/bin/bash -o pipefail -c /usr/bin/pip install --no-cache-dir notebook 'marimo>=0.6.21' https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip" did not complete successfully: exit code: 127
jyio commented 5 months ago
RUN /usr/bin/pip install ...

doesn't work when buiding custom-scls-notebook image

Sorry, my mistake. I forgot that quay.io/jupyter/julia-notebook starts with Mamba/Conda pre-installed (so the "system" pip is actually /opt/conda/bin/pip).

Instead, make that

RUN /opt/conda/bin/pip install ...

Alternatively, we could move that bit before you change the PATH, and just write

RUN pip install ...
s-celles commented 5 months ago

Thanks @jyio. It's working fine now.

image

image

jyio commented 5 months ago

Nice to see it working! But before you let this one rest, let me make one more suggestion.

You see, this installs Marimo and jupyter-marimo-proxy both within /opt/conda. You might notice that your Marimo installation isn't aware of all the things you've installed into /opt/conda/envs/condaenv, and that's because Marimo is installed into the top-level environment /opt/conda. To fix this, you'd want to install Marimo into /opt/conda/envs/condaenv like so (but keep jupyter-marimo-proxy where JupyterLab could find it):

RUN pip install --no-cache-dir 'marimo>=0.6.21'
RUN /opt/conda/bin/pip install --no-cache-dir https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip

Btw, there's no need to pip install notebook again, since it apparently comes with jupyter/julia-notebook...

s-celles commented 5 months ago

Great @jyio my mamba installed packages are also in Marimo now! Thanks for your help

PS: Here is my Dockerfile.custom-scls-notebook

USER $NB_UID
COPY environment.yml /tmp/environment.yml
ARG env_name=condaenv

RUN mamba env create -f /tmp/environment.yml -n $env_name && \
    mamba clean -qafy && \
    mamba run -n $env_name python -m ipykernel install --user --name=$env_name

ENV PATH /opt/conda/envs/$env_name/bin:$PATH  # added by scls

#RUN python3 -m pip install --no-cache-dir \
#    pipx \
#    nbdev \
#    python-dotenv \
#    pandas \
#    psycopg2-binary

#RUN pipx install \
#    python-dotenv \
#    poetry \
#    #nbdev

RUN pip install --no-cache-dir 'marimo>=0.6.21'
RUN /opt/conda/bin/pip install https://github.com/jyio/jupyter-marimo-proxy/archive/main.zip