deshaw / jupyterlab-execute-time

A JupyterLab extension for displaying cell timings
BSD 3-Clause "New" or "Revised" License
362 stars 48 forks source link

Read-only cells are not enforced if jupyterlab-execute-time is installed #107

Closed ianalis closed 7 months ago

ianalis commented 9 months ago

Cells can be made read-only by adding "editable": false to the cell metadata. The contents of the read-only cell can still be selected and the cursor can still be placed in it but the content cannot be modified or added:

image

However, if jupyterlab-execute-time is installed, the content of the read-only cell becomes editable:

image

The test system I used to generate the screenshots has the following (selected) installed packages:

    jupyter_client            8.6.0              pyhd8ed1ab_0    conda-forge
    jupyter_core              5.5.0           py310hbe9552e_0    conda-forge
    jupyter_server            2.12.1             pyhd8ed1ab_0    conda-forge
    jupyterlab                4.0.6              pyhd8ed1ab_0    conda-forge
    jupyterlab_execute_time   3.1.0              pyhd8ed1ab_0    conda-forge
    jupyterlab_server         2.25.2             pyhd8ed1ab_0    conda-forge
    python                    3.10.13         h2469fbe_0_cpython    conda-forge

The production system where I discovered the problem has the following (older) versions:

    jupyter_client            8.3.1              pyhd8ed1ab_0    conda-forge
    jupyter_core              5.3.2           py310hff52083_0    conda-forge
    jupyter_server            2.7.3              pyhd8ed1ab_1    conda-forge
    jupyterlab                3.6.6              pyhd8ed1ab_0    conda-forge
    jupyterlab_execute_time   2.3.1              pyhd8ed1ab_0    conda-forge
    jupyterlab_server         2.25.0             pyhd8ed1ab_0    conda-forge
    python                    3.10.12         hd12c33a_0_cpython    conda-forge
krassowski commented 9 months ago

I can reproduce. Changing editable status works well, but upon re-opening the notebook the cell is in fact editable.

reproducible-upon-reopening

krassowski commented 9 months ago

This is an interesting case. There is no obvious fault on jupyterlab-execute-time side. This can be traced to switching the recordTiming setting in line 61 here:

https://github.com/deshaw/jupyterlab-execute-time/blob/a28204670a3cb8428786ca46ab5ae88ef73472b5/src/ExecuteTimeWidget.ts#L57-L61

However, changing this setting manually does not lead to this side-effect.

Briefly, programatically changing a notebook tracker setting triggers refresh of editorConfig, which removes the readOnly flag because it has "special" handling (the read-only status come from the model rather than from the user settings).

I found a way to reproduce this in core JupyterLab (which also changes settings programatically in some code paths) and opened an issue over there: https://github.com/jupyterlab/jupyterlab/issues/15514

mlucool commented 7 months ago

Closing in favor of https://github.com/jupyterlab/jupyterlab/issues/15514.