New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support server-side execution #15448
Conversation
Thanks for making a pull request to jupyterlab! |
ddd29cf
to
21cc49a
Compare
This is really great David! So cool to follow your progress on this. 🙂 |
Here is a demo: Peek.2023-11-28.16-25.mp4 |
While I see why you named it "server-side-execution", I wonder if naming it "server-side-composition" could potentially avoid confusion with the execution which happens in kernels? It feels like the fact that execution is triggered from server (well, really proxied) is an implementation detail and what users care about is where the execution results are composed into the document. |
I agree that "server-side-execution" is not great, because kernels always execute code in the server. The main difference here is that:
But I'm not sure about "server-side-composition" either. Maybe "server-side-outputs"? |
Curious if this could be implemented in |
The execution command is done through an HTTP POST instead of using the kernel protocol, so there are changes to be done in JupyterLab: jupyterlab/packages/notebook/src/actions.tsx Lines 2480 to 2500 in 21cc49a
But I'm not sure it's the right place. |
21cc49a
to
b569000
Compare
Here is a way to try it out: mkdir jupyterlab
cd jupyterlab
git clone https://github.com/davidbrochart/jupyterlab.git
git clone https://github.com/davidbrochart/jupyverse.git
pixi init
pixi add nodejs pip "python<3.12"
pixi shell
cd jupyterlab
git checkout server-side-execution
pip install -e .
cd ..
cd jupyverse
git checkout ywidget-subdoc
pip install -e jupyverse_api
pip install -e plugins/noauth
pip install -e plugins/contents
pip install -e plugins/frontend
pip install -e plugins/lab
pip install -e plugins/jupyterlab
pip install -e plugins/kernels
pip install -e plugins/yjs
pip install -e plugins/nbconvert
pip install -e plugins/terminals
pip install -e .
cd ..
pip install ypywidgets==0.6.3
pip install jupyter-collaboration
mkdir tmp
cd tmp
jupyverse --set jupyterlab.dev_mode=true --set jupyterlab.server_side_execution=true --set kernels.require_yjs=true Open a browser window at http://127.0.0.1:8000, it should open JupyterLab. from time import sleep
for i in range(1000000):
print(i)
sleep(2) Close your browser window and open a new one at http://127.0.0.1:8000. Open the notebook, you should see the live outputs. |
b569000
to
d1b3a34
Compare
Actually, this PR only needs jupyter-server/jupyverse#364. Since having jupyter-server support this execution mode will require a significant amount of work and time, I think I could make a release of Jupyverse and we could merge this PR, what do you think? |
d1b3a34
to
e7f2178
Compare
I will have a look next week at that amount of work and time to get that feature in jupyter-server and will report back. This will also be useful to asses that this PR would also work with jupyter-server. In the meantime, I propose to wait before merging. |
Also still curious if this could be implemented in |
There are changes not only in jupyter-server, but also in jupyter-client. I'm estimating at least one month of work.
This PR is just replacing the kernel |
No it cannot, as I said JupyterLab must do an HTTP POST instead of using the kernel protocol.
Where would this extension point be? |
Let me look at that, I will report asap. |
60c6f8c
to
9d282a9
Compare
Currently there is no such extension point, as the notebook execution logic seems to be living in a |
Yes I was looking for something like that, but eventually took a shortcut. What I like in the current solution is that it's simple and it also doesn't drop the connection to the kernel through the kernel protocol over WebSocket, which means that the kernel busy indicator still works, and widgets should also still work (although they won't be recovered from the notebook state). |
Yes, in order to execute a cell of a notebook, the notebook document ID and the notebook cell ID are needed. |
c3fd1cf
to
2d3d26f
Compare
What were your conclusions @echarles ? |
FYI @fcollonval just opened a PR to allow for something like this: #15830. Thanks Fred! |
Does anything still need to be done to merge this? I can give some time as this is critical and still the top 👍 issue after many years In the meantime until the next release, can we just build locally and run this to get the functionality? |
I'm sorry this is taking so long, I'd love it to be released in JupyterLab 4.2. |
#15830 is likely the way forward with this, with |
Sure, #15830 is the right solution long-term, but maybe we could live with the shortcut provided by this PR in the meantime? |
@davidbrochart FYI #15830 is now merged. |
Thanks, I'll update this PR. |
@davidbrochart is the plan to add a new implementation of |
You're right, I think a new implementation of |
Closing in favor of jupyterlab/jupyter-collaboration#279. |
References
Closes #2833.
Closes #12867.
Needs:
Set file ID on document state jupyter-collaboration#217Add optional file ID to document state jupyter-server/jupyter_ydoc#198Change notebook code cell stream output schema jupyter-server/jupyter_ydoc#201jupyter-collaboration >=2.0
jupyverse >=0.4.0
Currently, the only Jupyter server that supports this execution mode is Jupyverse.
Code changes
A new
server-side-execution
flag allows to execute a notebook server-side (false by default). In this execution mode, the frontend doesn't use the kernel protocol over WebSocket, but interacts with the notebook only through its shared model. Thus, this mode needs jupyter-collaboration.User-facing changes
The user can close their JupyterLab browser window, reopen it later and recover the notebook state, including (live) cell outputs.
Backwards-incompatible changes
None.