jupyterlab
jupyterlab copied to clipboard
Add a right-click menu option to disable evaluating a cell or cells?
I have run into a number of times recently where it would be extremely helpful to be able to, right-click them, and tell JupyterLab that they should not be evaluated until I say otherwise. Sometimes you just need a convenient block of code that is a placeholder that you're reworking, or reference, or that you simply need to get back to later but bits after that in the notebook need to be focused on right now.
Thanks! That indeed does sound useful. We would also need to figure out a UI to make these non-executable cells visible in some different way. And we probably wouldn't save the nonexecutable part (there's no notion in the notebook format for this, unless we introduced new metadata), so we'd need a way to help the user not be confused about that.
The intuitive and obvious way to make them look different would be to slightly change the background behind the frame which contains that code and maybe even change the color of the selection bar from blue to red or yellow when that cell is selected. Pretty straightforward from a UI design perspective, really.
Though not saving them is probably a bad idea, and if there's not a notion of "this cell is different in a persistent way" currently, maybe that's something that needs to be thought about in the context of JupyterLab. It's probably not the only time someone is going to want some sort of persistency for state change – and I can think of one obvious place where this would be the solution: all of the issues around output cells which should remember whether or not they've been set to be scrollable or not. Just allowing that to be set as a persistent cell trait so that it is remembered on reload would definitely not suck.
On Tue, Mar 20, 2018 at 12:01 PM Jason Grout [email protected] wrote:
Thanks! That indeed does sound useful. We would also need to figure out a UI to make these non-executable cells visible in some different way. And we probably wouldn't save them (there's no notion in the notebook format for this), so we'd need a way to help the user not be confused about that.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jupyterlab/jupyterlab/issues/4213#issuecomment-374653424, or mute the thread https://github.com/notifications/unsubscribe-auth/ADVB4_Llp5Rmr_PAhE1qiVnssLDWNkw0ks5tgSfPgaJpZM4SyFpi .
I think an implementation of the freeze extension would be really nice! I've been creating a really long notebook that takes a long time to run -- yes, I want to continue to see the output of some of the cells, but no, I don't necessarily need to re-execute them (and, it'd be better if I didn't have to, since they are fairly compute intensive). The Freeze extension from the classic notebook does exactly what I need, but, AFAIK, it hasn't been implemented for JupyterLab yet ... :(
Is there any news on this issue ? This would be a really nice feature to have !
No news that I'm aware of. I still think it's an interesting extension idea that someone could explore.
That would be very useful for me too ! Do you know of any workaround to be able to do this ?
If anyone else is looking for functionality equivalent to the read-only cells offered by the freeze extension linked above, it is possible to change the metadata of a cell in jupyterlab like so (it will still be executable):
{
"editable": false
}
This issue has been mentioned on Jupyter Community Forum. There might be relevant details there:
https://discourse.jupyter.org/t/freeze-cell-extension/6696/2
Hi - I'd like to point out one use case that may have interest all over the community. If I have a teaching notebook, I'd like to leave a few cells with errors in them and then fix the error in the next cell. I've seen it pointed out in Notebook discussions that you can freeze the cell and its output with an extension. This would be great for restarting a kernel, executing everything, and having the error output persist for the student, while continuing execution to the bottom or current cell. I'm trying to stick with Lab over Notebook for teaching because Lab seems have a stronger future. Thanks!
As noted in the documentation, JupyterLab currently support different Cell Metadata: https://nbformat.readthedocs.io/en/latest/format_description.html#cell-metadata
Is there an opportunity to completly "lock" a cell including the features:
- Not editable (Metadata existing)
- Not deletable (Metadata existing)
- Not draggable => should be able to add / delete cells before or after this locked cell
- Not movable => should be able to add / delete cells before or after this locked cell
- Not executable
Furthermore is it possible to change the background colour of such a cell? To show students that this is a not changeable cell?
When adding the metadata editable and deletable to false, the css classes jp-mod-readOnly and jp-mod-active are added to this cell. Nevertheless, I can not find where exactly the events for these cells are disabled.
Where are these features disabled and how could we stop a cell from being drag and dropped around and moved up/down?
This would come in super handy for a lot of the work I do where I'll explore a REST API or any other sort of http requests where it is handy to store the output. However I don't want to rerun those cells when I restart the kernel (especially when some of these requests cost money like calling the openai API). Instead I have to run the first few import block cells, then find my class and functions cells of interest, and then pick back up where I was rather than pressing the "Run all" button.
as mentioned, the legacy freeze extension is not only able to lock the cell (not editable or executable) but also highlight the cell with customizable background color. it's super handy compared to edit the metadata directly in notebook7+
It looks that the legacy freeze extension is a Jupyter Notebook extension and not a JupyterLab extension, therefore it can not be installed for a JupyterLab environment
JupyterLab >= 4.0.0
pip install jupyterlab_freeze
JupyterLab >= 4.0.0
pip install jupyterlab_freeze
i installed it, but i can not find anything related in ui or settings
JupyterLab >= 4.0.0
pip install jupyterlab_freezei installed it, but i can not find anything related in ui or settings
After installing jupyterlab_freeze, three icons appeared in the top right corner: unlock, lock and freeze
JupyterLab >= 4.0.0
pip install jupyterlab_freezei installed it, but i can not find anything related in ui or settings
After installing
jupyterlab_freeze, three icons appeared in the top right corner: unlock, lock and freeze
they are not there...i have refreshed the page, reopened the browser and restarted the jupyter server
Did you restart and reload JupyterLab after installation of the extension? Are there any errors in the console?
Did you restart and reload JupyterLab after installation of the extension? Are there any errors in the console?
some errors occurred, but i am not sure they are related
[I 2024-02-22 21:13:28.464 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2024-02-22 21:13:28.466 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2024-02-22 21:13:28.467 ServerApp] jupyterlab | extension was successfully linked.
[I 2024-02-22 21:13:28.600 ServerApp] notebook_shim | extension was successfully linked.
[I 2024-02-22 21:13:28.623 ServerApp] notebook_shim | extension was successfully loaded.
[I 2024-02-22 21:13:28.624 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2024-02-22 21:13:28.624 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2024-02-22 21:13:28.625 LabApp] JupyterLab extension loaded from /home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyterlab
[I 2024-02-22 21:13:28.625 LabApp] JupyterLab application directory is /home/htao_ubuntu/WizardsInCouch/rsrh/.env/share/jupyter/lab
[I 2024-02-22 21:13:28.625 LabApp] Extension Manager is 'pypi'.
[I 2024-02-22 21:13:28.642 ServerApp] jupyterlab | extension was successfully loaded.
[I 2024-02-22 21:13:28.643 ServerApp] Serving notebooks from local directory: /home/htao_ubuntu/WizardsInCouch/rsrh
[I 2024-02-22 21:13:28.643 ServerApp] Jupyter Server 2.12.5 is running at:
[I 2024-02-22 21:13:28.643 ServerApp] http://localhost:8888/lab?token=96248c42922bb04c5673a5b56142721e00936df5bc2f9fb3
[I 2024-02-22 21:13:28.643 ServerApp] http://127.0.0.1:8888/lab?token=96248c42922bb04c5673a5b56142721e00936df5bc2f9fb3
[I 2024-02-22 21:13:28.643 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2024-02-22 21:13:28.657 ServerApp]
To access the server, open this file in a browser:
file:///home/htao_ubuntu/.local/share/jupyter/runtime/jpserver-5191-open.html
Or copy and paste one of these URLs:
http://localhost:8888/lab?token=96248c42922bb04c5673a5b56142721e00936df5bc2f9fb3
http://127.0.0.1:8888/lab?token=96248c42922bb04c5673a5b56142721e00936df5bc2f9fb3
[I 2024-02-22 21:13:28.662 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[W 2024-02-22 21:13:30.216 LabApp] Could not determine jupyterlab build status without nodejs
[W 2024-02-22 21:13:30.533 ServerApp] Notebook data/test_for_baostock_daily.ipynb is not trusted
[W 2024-02-22 21:13:30.556 ServerApp] 404 GET /api/contents/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py?content=0&hash=0&1708607610554 ([email protected]) 0.28ms referer=http://localhost:8888/lab
[I 2024-02-22 21:13:30.556 ServerApp] Refusing to serve hidden file or directory '/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py', via 404 Error
[E 2024-02-22 21:13:30.557 ServerApp] Uncaught exception GET /api/contents/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py?content=0&hash=0&1708607610554 (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/contents/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py?content=0&hash=0&1708607610554', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/handlers.py", line 153, in get
model = await ensure_async(
^^^^^^^^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_core/utils/__init__.py", line 198, in ensure_async
result = await obj
^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/filemanager.py", line 922, in get
model = await self._file_model(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/filemanager.py", line 823, in _file_model
model = self._base_model(path)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/filemanager.py", line 235, in _base_model
raise web.HTTPError(404, four_o_four)
tornado.web.HTTPError: HTTP 404: Not Found (file or directory does not exist: '.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/tornado/web.py", line 1790, in _execute
result = await result
^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
return await out
^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/handlers.py", line 179, in get
await self._finish_error(
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/handlers.py", line 113, in _finish_error
self.write(message)
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/tornado/web.py", line 914, in write
raise RuntimeError("Cannot write() after finish()")
RuntimeError: Cannot write() after finish()
[W 2024-02-22 21:13:30.615 ServerApp] 404 GET /api/contents/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py?content=0&hash=0&1708607610614 ([email protected]) 0.63ms referer=http://localhost:8888/lab
[I 2024-02-22 21:13:30.616 ServerApp] Refusing to serve hidden file or directory '/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py', via 404 Error
[E 2024-02-22 21:13:30.616 ServerApp] Uncaught exception GET /api/contents/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py?content=0&hash=0&1708607610614 (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/contents/.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py?content=0&hash=0&1708607610614', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/handlers.py", line 153, in get
model = await ensure_async(
^^^^^^^^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_core/utils/__init__.py", line 198, in ensure_async
result = await obj
^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/filemanager.py", line 922, in get
model = await self._file_model(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/filemanager.py", line 823, in _file_model
model = self._base_model(path)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/filemanager.py", line 235, in _base_model
raise web.HTTPError(404, four_o_four)
tornado.web.HTTPError: HTTP 404: Not Found (file or directory does not exist: '.env/lib/python3.11/site-packages/IPython/extensions/autoreload.py')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/tornado/web.py", line 1790, in _execute
result = await result
^^^^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/auth/decorator.py", line 73, in inner
return await out
^^^^^^^^^
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/handlers.py", line 179, in get
await self._finish_error(
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/jupyter_server/services/contents/handlers.py", line 113, in _finish_error
self.write(message)
File "/home/htao_ubuntu/WizardsInCouch/rsrh/.env/lib/python3.11/site-packages/tornado/web.py", line 914, in write
raise RuntimeError("Cannot write() after finish()")
RuntimeError: Cannot write() after finish()
[I 2024-02-22 21:13:30.775 ServerApp] Kernel started: d970c309-9bb8-4fa6-8a46-5a04fdbe7dca
[I 2024-02-22 21:13:30.776 ServerApp] Kernel started: 3ed013e0-4896-4bea-8032-3db72d2bf071
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[I 2024-02-22 21:13:30.979 ServerApp] Connecting to kernel 3ed013e0-4896-4bea-8032-3db72d2bf071.
[I 2024-02-22 21:13:30.993 ServerApp] Connecting to kernel d970c309-9bb8-4fa6-8a46-5a04fdbe7dca.
[I 2024-02-22 21:13:31.004 ServerApp] Connecting to kernel 3ed013e0-4896-4bea-8032-3db72d2bf071.
[I 2024-02-22 21:13:31.015 ServerApp] Connecting to kernel 3ed013e0-4896-4bea-8032-3db72d2bf071.
