Skip to content

Commit

Permalink
don't 500 on cell execution errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanov committed Jun 5, 2019
1 parent cadc6e8 commit 26e3383
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions voila/execute.py
Expand Up @@ -6,7 +6,7 @@
# The full license is in the file LICENSE, distributed with this software. #
#############################################################################

from nbconvert.preprocessors.execute import ExecutePreprocessor
from nbconvert.preprocessors.execute import CellExecutionError, ExecutePreprocessor
from ipykernel.jsonutil import json_clean


Expand Down Expand Up @@ -77,13 +77,20 @@ def set_state(self, state):
del self.executor.output_hook[self.msg_id]
self.msg_id = msg_id

def make_error_notebook(nb, e):
return nb

class ExecutePreprocessorWithOutputWidget(ExecutePreprocessor):
"""Execute, but respect the output widget behaviour"""
def preprocess(self, nb, resources, km=None):
self.output_hook = {}
self.output_objects = {}
return super(ExecutePreprocessorWithOutputWidget, self).preprocess(nb, resources=resources, km=km)
try:
result = super(ExecutePreprocessorWithOutputWidget, self).preprocess(nb, resources=resources, km=km)
except CellExecutionError as e:
self.log.error(e)
result = (nb, resources)
return result

def output(self, outs, msg, display_id, cell_index):
parent_msg_id = msg['parent_header'].get('msg_id')
Expand Down

0 comments on commit 26e3383

Please sign in to comment.