Open janosh opened 1 year ago
I would assume errors have some sort of metadata annotation. Do you have an example notebook with an error?
This is the noteobook's relevant JSON:
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "IndexError",
"evalue": "list index out of range",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn [1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m [][\u001b[39m0\u001b[39;49m]\n",
"\u001b[0;31mIndexError\u001b[0m: list index out of range"
]
}
],
"source": [
"[][0]"
]
}
]
}
So maybe the trigger could be
any(out["ename"].endswith("Error") for out in outputs)
An output_type
of error
is an indication of error output.
I won't be able to work on implementing this. Contributions welcome!
Is it possible to detect whether a cell output is an error + stack trace and let users specify one of 3 options
ignore
,strip
orerror
? The first would be current behavior of doing nothing, second would remove the cell output and third would exitnbstripout
non-zero so that using it as apre-commit
hook aborts commits.My goal is to prevent accidentally releasing notebooks like this: