How to get output model for a given cell in a JupyterLab extension?

Many thanks for the detailed answer!

To First:
Juhu, With your help I am now able to access the output values:

  • use outputs.get(index) method inside index loops instead of outputs[index] or iterations
  • be careful about timing

In order to find out what expression caused some output, I have to evaluate the last line
of the cell input, because the output model does not include that information (please correct if this is wrong).

To Second:

I also highly recommend sticking to the public members (do not use underscored properties like ._output )

Fully agree.

reading the API reference

Once I know where to look/what key terms to search for, the api doc might be helpful.
Where can I find the doc for the “outputs” property of the cell model,
saying that I should use outputs.get(index) instead of outputs[index] and that outputs is not iterable?

That info does not seem to be included in

https://jupyterlab.readthedocs.io/en/stable/api/classes/cells.codecell-1.html
or
https://jupyterlab.readthedocs.io/en/stable/api/interfaces/cells.icodecellmodel.html
or the search:

=> This forum is a very important/helpful supplement to the api doc.

I updated a related answer on SO to clarify where to find documentation. Please extend/correct if you want:

To Third and Finally

I included nbsafety as another option in an overview here:

Maybe, just maybe, contributing to that project would be a better way forward rather
than trying to re-implement it from scratch?

Yes, I would prefer to build on existing solutions. I am still in the orientation phase, trying to follow multiple paths (including options like observablehq and starboard) and find out what might give the best match.

Indeed, I have several ideas that I would like to combine for reactive data flow models:

1 Like