-
Notifications
You must be signed in to change notification settings - Fork 9
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
Can we control how much content is shown from an exception? #304
Comments
https://stackoverflow.com/questions/46222753/how-do-i-suppress-tracebacks-in-jupyter
This cuts out the lines such as:
and reduces the report to lines such as:
|
Additional configuration of
|
Original error report:
|
All is controlled with
|
looks possible to direct error reporting to more than one destination through use of a custom function, as shown above: #304 (comment) |
There's even a suggestion on SO for switching on/off the full reporting in the exception handler. Like this:
|
That was exciting. Entered a semi-infinite loop:
ending with an automatic exit from ipython:
Needs work. |
That report was for the case where
|
A working example, updated for Py3 and IPython session:
|
Still need to define |
example shows there is more work to be done:
Expecting something more like this:
|
BTW, that specific library looks like a problem between incompatible support libraries. More work needed on the installation instructions. |
Follow advice described in the APS |
When the report is In [74]: %xmode Minimal
Exception reporting mode: Minimal Note: Valid modes: Plain, Context, Verbose, and Minimal. Simple ExampleRaise an exception in an interactive: session with In [75]: 1/0
ZeroDivisionError: division by zero Show the exception with the In [76]: sys.last_value
Out[76]: ZeroDivisionError('division by zero') Show the exception traceback with the In [77]: traceback.print_last()
Traceback (most recent call last):
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-75-9e1622b385b6>", line 1, in <module>
1/0
ZeroDivisionError: division by zero Bluesky Plan ExampleCause an exception to be raised (by the bluesky RunEngine) from handling a user's bluesky plan. First, the plan: from bluesky import plan_stubs as bps
from ophyd import EpicsSignalRO
uptime = EpicsSignalRO("gp:UPTIME", name="uptime")
def my_plan():
yield from bps.mv(uptime, "this will fail") Run the plan: In [98]: import bluesky
In [99]: RE = bluesky.RunEngine({})
In [100]: RE(my_plan())
Run aborted
Traceback (most recent call last):
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 1479, in _run
msg = self._plan_stack[-1].throw(
File "<ipython-input-97-7039c593798b>", line 7, in my_plan
yield from bps.mv(uptime, "this will fail")
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/plan_stubs.py", line 256, in mv
ret = yield Msg('set', obj, val, group=group, **kwargs)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 1563, in _run
new_response = await coro(msg)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 2065, in _set
ret = msg.obj.set(*msg.args, **kwargs)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/ophyd/signal.py", line 1324, in set
raise ReadOnlyError('Read-only signals cannot be set')
ophyd.utils.errors.ReadOnlyError: Read-only signals cannot be set
ReadOnlyError: Read-only signals cannot be set
Here is the longer report using In [101]: traceback.print_last()
Traceback (most recent call last):
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-100-892b0b05b47f>", line 1, in <module>
RE(my_plan())
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 882, in __call__
plan_return = self._resume_task(init_func=_build_task)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 1020, in _resume_task
raise exc
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 1643, in _run
raise err
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 1479, in _run
msg = self._plan_stack[-1].throw(
File "<ipython-input-97-7039c593798b>", line 7, in my_plan
yield from bps.mv(uptime, "this will fail")
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/plan_stubs.py", line 256, in mv
ret = yield Msg('set', obj, val, group=group, **kwargs)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 1563, in _run
new_response = await coro(msg)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/bluesky/run_engine.py", line 2065, in _set
ret = msg.obj.set(*msg.args, **kwargs)
File "/home/prjemian/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/ophyd/signal.py", line 1324, in set
raise ReadOnlyError('Read-only signals cannot be set')
ophyd.utils.errors.ReadOnlyError: Read-only signals cannot be set |
Extraneous detail (from In [113]: xmode?
Docstring:
Switch modes for the exception handlers.
Valid modes: Plain, Context, Verbose, and Minimal.
If called without arguments, acts as a toggle.
When in verbose mode the value --show (and --hide)
will respectively show (or hide) frames with ``__tracebackhide__ =
True`` value set.
File: ~/.conda/envs/bluesky_2022_1/lib/python3.9/site-packages/IPython/core/magics/basic.py |
How does this affect logging of exceptions? |
The error reports from bluesky are lengthy. Way too much information and too deep. How to limit this? Yes also record it in a log for diagnostic purposes.
The text was updated successfully, but these errors were encountered: