jupyterlab / jupyter-collaboration

A Jupyter Server Extension Providing Support for Y Documents
https://jupyterlab-realtime-collaboration.readthedocs.io/en/latest/
Other
169 stars 31 forks source link

Cell output not preserved even when server-side execution is enabled #339

Closed francesco-ballarin closed 2 months ago

francesco-ballarin commented 3 months ago

Description

Hi, I saw https://github.com/jupyterlab/jupyter-collaboration/pull/279, and was eager to use it on my system with motivations similar to the one in https://github.com/jupyterlab/jupyterlab/issues/2833. However, cell output does not get preserved even when following the instructions in the PR.

I show below how to replicate with a docker container, but I actually have the same issue on my host machine (without docker).

Reproduce

Open a new docker image with docker run -it --rm -p 80:80 debian:testing and run the following

apt -y update
apt -y upgrade
apt -y dist-upgrade
apt install -y python3-pip

rm /usr/lib/python3.12/EXTERNALLY-MANAGED
rm -rf /usr/local/lib/python3.12/dist-packages

pip install jupyterlab
pip install "jupyverse[jupyterlab, auth]"

# I need the following patch
sed -i 's|self.prefix_dir = Path(sys.prefix)|self.prefix_dir = Path(sys.prefix) / "local"|g' /usr/local/lib/python3.12/dist-packages/jupyverse_api/lab/__init__.py
# because python3 comes from /usr (installed via apt), while jupyter is installed in /usr/local (via pip).

# In my actual system I also need to run
# sed -i 's|for d1 in s.iterdir():|for d1 in s.iterdir():\n                if (d1 / "package.json.orig").exists():\n                    continue|g' /usr/local/lib/python3.12/dist-packages/fps_lab/routes.py
# because I have folders where package.json.orig is in the d1 rather than its subdirectory d2
# (for instance, created by ipyparallel). For simplicity, we do not install those packages here.

jupyverse --host 0.0.0.0 --port 80 --set kernels.require_yjs=true --set jupyterlab.server_side_execution=true

Got to the jupyter URL, create a new notebook with content

from time import sleep
i = 1
while True:
    print(i)
    i+=1
    sleep(1)

and run the cell. Save, close and re-open the tab. The output is not updated after opening the new tab.

It may not be relevant, but I also noted that the html output is not exactly the same as in the video in https://github.com/jupyterlab/jupyter-collaboration/pull/279:

Expected behavior

Something similar to the video in https://github.com/jupyterlab/jupyter-collaboration/pull/279

Context

# pip list | grep jupy
fps_jupyterlab              0.6.0
jupyter_client              8.6.2
jupyter_core                5.7.2
jupyter-events              0.10.0
jupyter-lsp                 2.2.5
jupyter_server              2.14.2
jupyter_server_terminals    0.5.3
jupyterlab                  4.2.4
jupyterlab_pygments         0.3.0
jupyterlab_server           2.27.3
jupyverse                   0.6.0
jupyverse_api               0.6.0
krassowski commented 3 months ago

It looks like you do not have the latest jupyter-collaboration packages installed. You would need v3 which is in beta currently.

krassowski commented 3 months ago

There is also https://github.com/datalayer/jupyter-server-nbmodel as an alternative. You do not need to install all of jupyter-collaboration, just "jupyter-docprovider>=1.0.0b1" and "jupyter-server-ydoc>=1.0.0b1".

francesco-ballarin commented 3 months ago

It looks like you do not have the latest jupyter-collaboration packages installed. You would need v3 which is in beta currently.

Well, how silly of me ;)

However, pip install "jupyter-server-ydoc>=1.0.0b1" results in

Installing collected packages: pycrdt, sqlite-anyio, jupyter-ydoc, pycrdt-websocket, jupyter-server-fileid, jupyter-server-ydoc
  Attempting uninstall: pycrdt
    Found existing installation: pycrdt 0.8.31
    Uninstalling pycrdt-0.8.31:
      Successfully uninstalled pycrdt-0.8.31
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
fps-yjs 0.6.0 requires pycrdt<0.9.0,>=0.8.16, but you have pycrdt 0.9.8 which is incompatible.
Successfully installed jupyter-server-fileid-0.9.2 jupyter-server-ydoc-1.0.0b2 jupyter-ydoc-2.1.1 pycrdt-0.9.8 pycrdt-websocket-0.14.1 sqlite-anyio-0.2.3

Should I be installing some other dependencies with --pre? Adding --pre to the installation of jupyterlab didn't help, and upgrading jupyter-ydoc with --pre didn't help either.

Thanks for the super fast reply!

krassowski commented 3 months ago

fps-yjs sounds like something from jupyverse, maybe the jupyverse version you are installing does not yet support newer pycrdt?

davidbrochart commented 3 months ago

Indeed, I'll have to update jupyverse to support latest pycrdt.

francesco-ballarin commented 2 months ago

Indeed, I'll have to update jupyverse to support latest pycrdt.

Fixed in the most recent jupyverse release. Closing.