jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.57k stars 4.85k forks source link

cell metadata evaluable == false #3308

Open haraldschilly opened 6 years ago

haraldschilly commented 6 years ago

Originally motivated by reading up on nbgrader and then some work for CoCalc, I've came across the metadata fields "deletable": false and "editable":false. (reference: nbgrader test_lockcells.py)

However, I was wondering if there are also plans for a third "evaluable":false metadata flag? If that's set, the cell can't be evaluated and the stored cell output stays as it is.

takluyver commented 6 years ago

No plans yet, but it probably makes sense in combination with editable.

I have some minor concerns that someone would try to use it as a security measure to prevent users running some code, but so long as our messaging is clear, that's not a big deal.

williamstein commented 5 years ago

I would call it {"evaluatable":false}. Also, what is the use case?

psychemedia commented 5 years ago

I was wondering what a use case might be too... One example might be in a grading situation (I learned about runnable and editable from nbgrader too) where you want to give a code hint as a non-runnable code fragment, in a code cell, that a learner might find useful as part of their own answer.

FWIW, I'd probably opt for {'runnable':false} based on the UI prompt that allows users to Run a cell.

It's perhaps also worth noting the freeze behaviour of the freeze extension which supports unlock, read-only and frozen modes with behaviours:

For code-cells: read-only: it can be executed, but its input cannot be changed. frozen: It cannot be either altered or executed.

For markdown-cells: read-only: It's input can be viewed by double-clicking on it, but cannot be changed. frozen: Input cannot be viewed by double-clicking.

and where:

[t]he read-only state is stored in the cell.metadata.editable attribute [and t]he frozen state is stored in the cell.metadata.run_control.frozen attribute.

haraldschilly commented 5 years ago

oh wow, never heard of freeze. We/Someone should really collect and tabulate these attributes (in the nbformat repo, where the specification is) and also define all of their interactions. i.e. if I understand this correctly this is actually {editable: true | false | 'read-only' | 'frozen'}? and so on....

and yes, runnable sound good as well. Giving students a code snippet as an example is exactly my thought. e.g. a fragment of a block of code or function, in order to to guide students to the answer, but they shouldn't edit or run that cell (because it's not valid python). The task is to write the function on their own and while they write it they fill in the missing parts.

psychemedia commented 5 years ago

@haraldschilly freeze is one of the "official" "unofficial" extensions. The cell.metadata.editable and cell.metadata.deletable are handled by the notebook, I think, but cell.metadata.run_control.frozen looks like it's custom metadata created and consumed (eg here) by the extension.