Add cell and notebook properties to the JupyterError event - #20
Conversation
| id: cell.model.toJSON().id as JSONValue, | ||
| metadata: cell.model.toJSON().metadata as JSONValue |
There was a problem hiding this comment.
Hello,
Just asking a question at random, as I don't know the details of how cells are stored in memory.
Does cell.model.toJSON() triggers a full copy of all the data in the model?
If yes, then performance could be improved by:
- calling cell.model.toJSON() only once
- if possible: calling toJSON() selectively on the specific metadata attributes that will be exploited
Motivation: some of the cell metadata attributes may have large values, like for widget states. The model itself might (?) contain large data, like cell outputs).
There was a problem hiding this comment.
Yes, cell.model.toJSON() serializes completely. for id this is superfluous because id is always a primitive. For metadata it makes sense because it's better to make a copy than to pass by reference. But @cmarmo, I would ask, do you actually want everything inside metadata? Depending on the notebook this might have fields you don't care about. Either way, @nthiery's point is valid.
There was a problem hiding this comment.
Thanks @afshin for your answer: in general I don't want to keep all the metadata, but the extension we are using now is configurable, so we can choose a list of metadata to be kept.
I wonder whether it is relevant to implement all the selection and configuration machinery here or create a new extension based on this one with custom events.
There was a problem hiding this comment.
Well, we already know all metadata is safe json and we can't seek out specifics within that metadata at this layer of the stack, so I think your plan to emit the whole of the cell's metadata is okay here.
| /** | ||
| * The executed cell. | ||
| */ | ||
| cell: JSONObject; |
There was a problem hiding this comment.
I would define the things you want JupyterError to provide under the cell key instead of making just a plain JSON object. It'll make it clearer what the emission is shipping.
|
You're on the right track here! The build only failed because it needs a |
|
I believe I have addressed the comments. |
Dear maintainers,
this pull request adds the
idandmetadatacell properties to theJupyterErrorevent schema and to the reported metrics.Thank you for considering it.