Skip to content

Commit e7809ce

Browse files
committed
Add some better trace message to help debug
1 parent 348241e commit e7809ce

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/resources/jupyter/jupyter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,21 @@ def run_server_subprocess(options, status):
226226
# run a notebook directly (not a server)
227227
def run_notebook(options, status):
228228

229-
# run notebook w/ some special exception handling. note that we don't
229+
# run notebook w/ some special exception handling. note that we don't
230230
# log exceptions here b/c they are considered normal course of execution
231231
# for errors that occur in notebook cells
232-
try:
232+
try:
233+
trace('Running notebook_execute')
233234
notebook_execute(options, status)
234235
except Exception as e:
236+
trace(f'run_notebook caught exception: {type(e).__name__}')
235237
# CellExecutionError for execution at the terminal includes a bunch
236238
# of extra stack frames internal to this script. remove them
237239
msg = str(e)
238240
kCellExecutionError = "nbclient.exceptions.CellExecutionError: "
239241
loc = msg.find(kCellExecutionError)
240242
if loc != -1:
241-
msg = msg[loc + len(kCellExecutionError)]
243+
msg = msg[loc + len(kCellExecutionError):]
242244
sys.stderr.write("\n\n" + msg + "\n")
243245
sys.stderr.flush()
244246
sys.exit(1)

src/resources/jupyter/notebook.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ def cell_execute(client, cell, index, execution_count, eval_default, store_histo
520520
allow_errors = cell_options.get('error')
521521

522522
trace(f"cell_execute with eval={eval}")
523+
if (allow_errors == True):
524+
trace(f"cell_execute with allow_errors={allow_errors}")
523525

524526
# execute if eval is active
525527
if eval == True:
@@ -556,9 +558,10 @@ def cell_execute(client, cell, index, execution_count, eval_default, store_histo
556558
# Check for display errors in output (respecting both global and cell settings)
557559
cell_allows_errors = allow_errors if allow_errors is not None else client.allow_errors
558560
if not cell_allows_errors:
561+
trace("Cell does not allow errors: checking for uncaught errors")
559562
for output in cell.outputs:
560563
if output.get('output_type') == 'error':
561-
trace("Uncaught error found in output")
564+
trace(" Uncaught error found in output")
562565
from nbclient.exceptions import CellExecutionError
563566
error_name = output.get('ename', 'Error')
564567
error_value = output.get('evalue', '')

0 commit comments

Comments
 (0)