enhancement-proposals icon indicating copy to clipboard operation
enhancement-proposals copied to clipboard

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

Open stevejpurves opened this issue 2 years ago • 5 comments

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

stevejpurves avatar Mar 06 '23 13:03 stevejpurves

Thanks for sharing the notes. FYI @MSeal @rgbkrk

willingc avatar Mar 10 '23 06:03 willingc

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."

MatsWallden avatar Mar 14 '23 19:03 MatsWallden

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.

rgbkrk avatar Mar 16 '23 04:03 rgbkrk

@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 avatar Mar 22 '23 17:03 stevejpurves

@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.

stevejpurves avatar Mar 22 '23 17:03 stevejpurves