nbval icon indicating copy to clipboard operation
nbval copied to clipboard

Traceback: Missing output fields from running code: {'image/svg+xml'}

Open nikokaoja opened this issue 5 years ago • 1 comments

Hi there,

I encountered failed tests of my notebook for cells that produce plots. I have been getting an error:

Traceback: Missing output fields from running code: {'image/svg+xml'}

What is the best way to avoid this type of errors ?

nikokaoja avatar Mar 04 '20 15:03 nikokaoja

Seems like your notebook file has an image/svg+xml output that is not showing up when nbval runs the notebook.

In my case it was:

Traceback: Missing output fields from running code: {'stderr'}

because a pair of stderr.write calls in one cell were ending up as separate outputs when run via Papermill, but were merged into one output when run interactively or via py.test --nbval.

Here's the place where the message originates: https://github.com/computationalmodelling/nbval/blob/d7bc34893a9251fbfd4b270347197619c32fe6ea/nbval/plugin.py#L479-L486

It is triggered when the re-run cell's outputs don't match the notebook file on disk.

The pytest/nbval output specifices which code cell index the error occurred at. Here's an easy way to inspect a given cell (including outputs / metadata):

cell_idx=6
jq '[.cells[] | select(.cell_type == "code")]'"[$cell_idx]" notebook.ipynb

ryan-williams avatar Dec 26 '23 01:12 ryan-williams