jupyter / enhancement-proposals

Enhancement proposals for the Jupyter Ecosystem
https://jupyter.org/enhancement-proposals
BSD 3-Clause "New" or "Revised" License
115 stars 65 forks source link

pre-proposal: allow for persistence of user expression result data in the notebook #94

Open stevejpurves opened 1 year ago

stevejpurves commented 1 year ago

This proposal was developed during Jupyter Community Workshop on the Notebook format (Paris, 28 Feb - 2 Mar).

"user expressions" are a well defined mechanism where a jupyter client can send a dict of expressions as part of any execute request made to the kernel. These expressions are executed as a side effect of the call, such that if an error occurs during the execution of a user expression if will not interrupt the main execution flow. Expressions are sent along with the request using the user_expressions field.

There are many possible use cases for user expressions, some of which could benefit from serialization within the notebook itself.

The user case in point being where user expressions are used to implement inline execution of code in Markdown cells, performing string interpolation and/or providing rich views of variable state or even ipywidgets. In such a use case, persisting the results of expression evaluation enables a client to render the Markdown cells correctly without requiring a kernel connection or the notebook code cells to be executed.

An example of a Jupyter Lab extension that uses user expressions in such a way is jupyterlab/myst which relies of storing these values in cell metadata.

This intent of this proposal is to extend the notebook cell format to include first class support for serialization of the user expression results from any cell execution.

The proposal is still a work in progress, and we hope to be able to submit a draft JEP PR soon. The working document supporting this effort is available here.

Contributors: @fcollonval, @vvnkr, @davidbrochart, @stevejpurves

willingc commented 1 year ago

Thanks for sharing the notes. FYI @MSeal @rgbkrk

MatsWallden commented 1 year ago

Yes! This! This! This! 100% This -> "The user case in point being where user expressions are used to implement inline execution of code in Markdown cells, performing string interpolation and/or providing rich views of variable state or even ipywidgets. In such a use case, persisting the results of expression evaluation enables a client to render the Markdown cells correctly without requiring a kernel connection or the notebook code cells to be executed."

rgbkrk commented 1 year ago

I look forward to the JEP. As it stands this is pretty broad in scope if it's intended to affect markdown. Focusing on just what the storage format is for the JEP will help this pass quickly with folks.

stevejpurves commented 1 year ago

@rgbkrk indeed - the intention is to focus on the storage of results and provide first class support for those, no matter what the use case if for them -- so will be independent from any specific markdown concerns.

stevejpurves commented 1 year ago

@MatsWallden if you want to play with some inline execution it's available in this extension in at least one place already. The extension uses the user_expressions mechanism and was some of the inspiration behind proposing this JEP.