File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,19 @@ async def render(notebook_id: str = ID_VALIDATOR):
247
247
config .root_level_metadata_as_raw_cell = False
248
248
notebook = jupytext .reads (data .decode (), metadata .format , config = config )
249
249
output , resources = exporter .from_notebook_node (
250
- notebook , {"object_metadata" : metadata }
250
+ # When rendering things with widgets, nbconvert code seems to assume that
251
+ # if resources is passed in, it will unconditionally actually have a copy of
252
+ # notebook metadata - in particular, keys named 'path' and 'name'.
253
+ # And if they aren't present, they kinda get set to "". This basically means that
254
+ # future nbconvert code just doesn't have access to the notebook metadata,
255
+ # including the widget state! And no widget stuff is displayed.
256
+ # https://github.com/jupyter/nbconvert/blob/fec19fa4d538495c3c02b85708878287463412ae/nbconvert/filters/widgetsdatatypefilter.py#L41
257
+ # and https://github.com/jupyter/nbconvert/blob/fec19fa4d538495c3c02b85708878287463412ae/nbconvert/exporters/exporter.py#L156
258
+ # are some of the relevant bits.
259
+ # https://github.com/jupyter/nbconvert/pull/2118 is the upstream PR that fixes
260
+ # this. In the meantime, we simply explicitly set "name" already to get widgets back
261
+ notebook ,
262
+ {"object_metadata" : metadata , "metadata" : {"name" : "Notebook" }},
251
263
)
252
264
return HTMLResponse (
253
265
output ,
You can’t perform that action at this time.
0 commit comments