Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bogus error message on timeout with --execute #74

Closed
akhmerov opened this issue Jul 29, 2015 · 5 comments
Closed

Bogus error message on timeout with --execute #74

akhmerov opened this issue Jul 29, 2015 · 5 comments
Milestone

Comments

@akhmerov
Copy link
Member

When a cell times out in nbconvert with --execute flag the traceback shows this traceback:

[NbConvertApp] ERROR | from time import sleep
sleep(2 * 60)
Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 11, in <module>
    sys.exit(start_ipython())
  File "/usr/local/lib/python2.7/dist-packages/IPython/__init__.py", line 120, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 574, in launch_instance
    app.start()
  File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 367, in start
    return self.subapp.start()
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 278, in start
    self.convert_notebooks()
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 401, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 372, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/nbconvertapp.py", line 324, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 156, in from_filename
    return self.from_notebook_node(nbformat.read(f, as_version=4), resources=resources, **kw)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/notebook.py", line 26, in from_notebook_node
    nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 127, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/exporters/exporter.py", line 281, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb,resources)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/execute.py", line 59, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/base.py", line 70, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/execute.py", line 73, in preprocess_cell
    outputs = self.run_cell(cell)
  File "/usr/local/lib/python2.7/dist-packages/IPython/nbconvert/preprocessors/execute.py", line 87, in run_cell
    msg = self.kc.shell_channel.get_msg(timeout=self.timeout)
  File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/blocking/channels.py", line 57, in get_msg
    raise Empty
Empty

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

I believe the raised error message here should be more informative (I didn't realize there was a timeout at all).

Details: tested on IPython 3.2.1, with a notebook containing a single cell

from time import sleep
sleep(2 * 60)

Using the command ipython nbconvert --to notebook --execute test_notebook.ipynb.

@takluyver
Copy link
Member

I agree, that should have a more useful error message. Do you want to make a PR?

@akhmerov
Copy link
Member Author

Depends: at this point I don't understand neither how to install current nbconvert nor the testing policy. If it's just editing the error type&message, then sure.

@takluyver
Copy link
Member

You can install it from a clone with pip install --pre -e . (--pre because it will pull in a pre-release version of IPython). You can run the tests with nosetests.

I expect you'll need to catch the Empty error and raise a new exception in its place.

@akhmerov
Copy link
Member Author

OK, after checking the source I saw there is already a description of what happens, and moreover it is very decent in nbconvert 4.0 compared to ipython 3. The only problem in my view is that it is buried by the traceback (the one I've copied in the original message). Would re-raising CellExecutionError("Cell execution timed out, see log for details.") instead of Empty be a reasonable way to point to the log?

@takluyver
Copy link
Member

I think I'd leave CellExecutionError for actual errors in the user code. I'd use TimeoutError in Python 3, and maybe RuntimeError in Python 2. The message you suggest looks fine, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants