Skip to content

Commit 45fced7

Browse files
Add show_tracebacks trait (#630)
* Add show_tracebacks trait * flake8 (remove logging) Co-authored-by: Maarten A. Breddels <[email protected]>
1 parent 781ce68 commit 45fced7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

voila/app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ class Voila(Application):
7373
examples = 'voila example.ipynb --port 8888'
7474

7575
flags = {
76-
'debug': ({'Voila': {'log_level': logging.DEBUG}}, _("Set the log level to logging.DEBUG")),
76+
'debug': (
77+
{'Voila': {'log_level': logging.DEBUG, 'show_tracebacks': True}},
78+
_("Set the log level to logging.DEBUG, and show exception tracebacks in output.")
79+
),
7780
'no-browser': ({'Voila': {'open_browser': False}}, _('Don\'t open the notebook in a browser after startup.'))
7881
}
7982

@@ -183,6 +186,10 @@ class Voila(Application):
183186
)
184187
)
185188

189+
show_tracebacks = Bool(False, config=True, help=_(
190+
'Whether to send tracebacks to clients on exceptions.'
191+
))
192+
186193
port_retries = Integer(50, config=True,
187194
help=_("The number of additional ports to try if the specified port is not available.")
188195
)

voila/execute.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
# The full license is in the file LICENSE, distributed with this software. #
88
#############################################################################
99

10-
import logging
11-
1210
from nbconvert.preprocessors import ClearOutputPreprocessor
1311
from nbclient.exceptions import CellExecutionError
1412
from nbclient import NotebookClient
@@ -79,7 +77,7 @@ async def execute_cell(self, cell, resources, cell_index, store_history=True):
7977

8078
def should_strip_error(self):
8179
"""Return True if errors should be stripped from the Notebook, False otherwise, depending on the current config."""
82-
return 'Voila' not in self.config or 'log_level' not in self.config['Voila'] or self.config['Voila']['log_level'] != logging.DEBUG
80+
return 'Voila' not in self.config or not self.config['Voila'].get('show_tracebacks', False)
8381

8482
def strip_notebook_errors(self, nb):
8583
"""Strip error messages and traceback from a Notebook."""

0 commit comments

Comments
 (0)