From 33cd1d4ed4c200c7838f0b46f4de3f77d614eda1 Mon Sep 17 00:00:00 2001 From: Vidar Tonaas Fauske Date: Fri, 5 Jun 2020 14:09:03 +0100 Subject: [PATCH] Add show_tracebacks trait --- voila/app.py | 9 ++++++++- voila/execute.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/voila/app.py b/voila/app.py index b03fc41a4..49b709a54 100644 --- a/voila/app.py +++ b/voila/app.py @@ -76,7 +76,10 @@ class Voila(Application): examples = 'voila example.ipynb --port 8888' flags = { - 'debug': ({'Voila': {'log_level': logging.DEBUG}}, _("Set the log level to logging.DEBUG")), + 'debug': ( + {'Voila': {'log_level': logging.DEBUG, 'show_tracebacks': True}}, + _("Set the log level to logging.DEBUG, and show exception tracebacks in output.") + ), 'no-browser': ({'Voila': {'open_browser': False}}, _('Don\'t open the notebook in a browser after startup.')) } @@ -186,6 +189,10 @@ class Voila(Application): ) ) + show_tracebacks = Bool(False, config=True, help=_( + 'Whether to send tracebacks to clients on exceptions.' + )) + port_retries = Integer(50, config=True, help=_("The number of additional ports to try if the specified port is not available.") ) diff --git a/voila/execute.py b/voila/execute.py index 773efb57c..b3b14deb3 100644 --- a/voila/execute.py +++ b/voila/execute.py @@ -79,7 +79,7 @@ async def execute_cell(self, cell, resources, cell_index, store_history=True): def should_strip_error(self): """Return True if errors should be stripped from the Notebook, False otherwise, depending on the current config.""" - return 'Voila' not in self.config or 'log_level' not in self.config['Voila'] or self.config['Voila']['log_level'] != logging.DEBUG + return 'Voila' not in self.config or not self.config['Voila'].get('show_tracebacks', False) def strip_notebook_errors(self, nb): """Strip error messages and traceback from a Notebook."""