print the full traceback
Right now the traceback is rather useless.
Example:
import adaptive
adaptive.notebook_extension()
def raising():
raise Exception('yo')
def f(x):
raising()
learner = adaptive.Learner1D(f, bounds=(-1, 1))
runner = adaptive.Runner(learner)
>>> runner.task.print_stack()
Traceback for <Task finished coro=<AsyncRunner._run() done, defined at /gscratch/home/t-banijh/adaptive/adaptive/runner.py:356> exception=RuntimeError('An error occured while evaluating "learner.function(-1.0)". See the top traceback for details.',)> (most recent call last):
RuntimeError: An error occured while evaluating "learner.function(-1.0)". See the top traceback for details.
File "/gscratch/home/t-banijh/adaptive/adaptive/runner.py", line 312, in status
return 'failed'
File "/gscratch/home/t-banijh/adaptive/adaptive/runner.py", line 312, in status
return 'failed'
File "/gscratch/home/t-banijh/adaptive/adaptive/runner.py", line 405, in _run
self.end_time = time.time()
With the code of this PR it becomes:
>>> runner.task.print_stack()
Traceback for <Task finished coro=<AsyncRunner._run() done, defined at /gscratch/home/t-banijh/adaptive/adaptive/runner.py:358> exception=RuntimeError('An error occured while evaluating "learner.function(-0.09677419354838712)". See the traceback for details.:\n\nconcurrent.futures.process._RemoteTraceback: \n"""\nTraceback (most recent call last):\n File "/home/t-banijh/miniconda3/envs/dev/lib/python3.6/concurrent/futures/process.py", line 175, in _process_worker\n r = call_item.fn(*call_item.args, **call_item.kwargs)\n File "<ipython-input-1-98bcb3ca1bae>", line 8, in f\n raising()\n File "<ipython-input-1-98bcb3ca1bae>", line 5, in raising\n raise Exception(\'yo\')\nException: yo\n"""\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File "/gscratch/home/t-banijh/adaptive/adaptive/runner.py", line 386, in _run\n y = fut.result()\nException: yo\n',)> (most recent call last):
RuntimeError: An error occured while evaluating "learner.function(-0.09677419354838712)". See the traceback for details.:
concurrent.futures.process._RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/t-banijh/miniconda3/envs/dev/lib/python3.6/concurrent/futures/process.py", line 175, in _process_worker
r = call_item.fn(*call_item.args, **call_item.kwargs)
File "<ipython-input-1-98bcb3ca1bae>", line 8, in f
raising()
File "<ipython-input-1-98bcb3ca1bae>", line 5, in raising
raise Exception('yo')
Exception: yo
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/gscratch/home/t-banijh/adaptive/adaptive/runner.py", line 386, in _run
y = fut.result()
Exception: yo
File "/gscratch/home/t-banijh/adaptive/adaptive/runner.py", line 408, in _run
self.end_time = time.time()
I don't know why the first part (lines above RuntimeError: An error occured while evaluating "learner.function(-0.09677419354838712)".
) are printed, but at least the rest is super useful.