Skip to content

Commit

Permalink
Merge pull request #314 from jeffyjefflabs/clear-output
Browse files Browse the repository at this point in the history
Clear output before executing the notebook
  • Loading branch information
SylvainCorlay committed Jul 23, 2019
2 parents b076e03 + c21b216 commit 3df5181
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions voila/execute.py
Expand Up @@ -6,6 +6,7 @@
# The full license is in the file LICENSE, distributed with this software. #
#############################################################################

from nbconvert.preprocessors import ClearOutputPreprocessor
from nbconvert.preprocessors.execute import CellExecutionError, ExecutePreprocessor

from ipykernel.jsonutil import json_clean
Expand Down Expand Up @@ -129,5 +130,7 @@ def executenb(nb, cwd=None, km=None, **kwargs):
resources = {}
if cwd is not None:
resources['metadata'] = {'path': cwd} # pragma: no cover
# Clear any stale output, in case of exception
nb, resources = ClearOutputPreprocessor().preprocess(nb, resources)
ep = ExecutePreprocessorWithOutputWidget(**kwargs)
return ep.preprocess(nb, resources, km=km)[0]

0 comments on commit 3df5181

Please sign in to comment.