forked from M-Labs/artiq
Improve exception reports when exception can't be reconstructed
Artiq assumes that all exceptions raised by the kernel can be constructed with a single string argument. This isn't always the case. Especially for exceptions that originated in python and were propagated to the kernel over rpc. With out this change a mosek solver failure looks like: ``` ERROR root:logging_tools.py:41 Terminating with exception (TypeError: __init__() missing 1 required positional argument: 'msg') Traceback (most recent call last): File "/home/mb/.cache/pypoetry/virtualenvs/ion-transport-1-b41LI0-py3.8/lib/python3.8/site-packages/artiq/master/worker_impl.py", line 540, in main exp_inst.run() File "/home/mb/.cache/pypoetry/virtualenvs/ion-transport-1-b41LI0-py3.8/lib/python3.8/site-packages/artiq/test_tools/experiment.py", line 82, in wrapper meth() File "/home/mb/.cache/pypoetry/virtualenvs/ion-transport-1-b41LI0-py3.8/lib/python3.8/site-packages/artiq/language/core.py", line 54, in run_on_core return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs) File "/home/mb/.cache/pypoetry/virtualenvs/ion-transport-1-b41LI0-py3.8/lib/python3.8/site-packages/artiq/coredevice/core.py", line 152, in run self.comm.serve(embedding_map, symbolizer, demangler) File "/home/mb/.cache/pypoetry/virtualenvs/ion-transport-1-b41LI0-py3.8/lib/python3.8/site-packages/artiq/coredevice/comm_kernel.py", line 720, in serve self._serve_exception(embedding_map, symbolizer, demangler) File "/home/mb/.cache/pypoetry/virtualenvs/ion-transport-1-b41LI0-py3.8/lib/python3.8/site-packages/artiq/coredevice/comm_kernel.py", line 699, in _serve_exception python_exn = python_exn_type( TypeError: __init__() missing 1 required positional argument: 'msg' ``` With this change we get: ``` ERROR root:logging_tools.py:41 Terminating with exception (RuntimeError: Exception type=<class 'mosek.Error'>, which couldn't be reconstructed (__init__() missing 1 required positional argument: 'msg')) Core Device Traceback: Traceback (most recent call first): File "/home/mb/oxionics/ion-transport/tests/test_end_to_end.py", line 280, in get_transport return self.seq.solve() File "/home/mb/oxionics/ion-transport/tests/test_end_to_end.py", line 288, in artiq_worker_test_end_to_end.TransportTestScan.run(..., ...) (RA=+0x2e4) self.seq.record(self.get_transport(1e-6 + 1e-7 * x)) mosek.Error(27): rescode.err_license_expired(1001): The license has expired. End of Core Device Traceback Traceback (most recent call last): File "/home/mb/oxionics/artiq/artiq/master/worker_impl.py", line 540, in main exp_inst.run() File "/home/mb/oxionics/artiq/artiq/test_tools/experiment.py", line 82, in wrapper meth() File "/home/mb/oxionics/artiq/artiq/language/core.py", line 54, in run_on_core return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs) File "/home/mb/oxionics/artiq/artiq/coredevice/core.py", line 152, in run self.comm.serve(embedding_map, symbolizer, demangler) File "/home/mb/oxionics/artiq/artiq/coredevice/comm_kernel.py", line 732, in serve self._serve_exception(embedding_map, symbolizer, demangler) File "/home/mb/oxionics/artiq/artiq/coredevice/comm_kernel.py", line 714, in _serve_exception raise python_exn RuntimeError: Exception type=<class 'mosek.Error'>, which couldn't be reconstructed (__init__() missing 1 required positional argument: 'msg') ``` Signed-off-by: Michael Birtwell <michael.birtwell@oxionics.com>
This commit is contained in:
parent
40df2a6526
commit
ad13e2205d
|
@ -686,8 +686,14 @@ class CommKernel:
|
|||
else:
|
||||
python_exn_type = embedding_map.retrieve_object(core_exn.id)
|
||||
|
||||
python_exn = python_exn_type(
|
||||
nested_exceptions[-1][1].format(*nested_exceptions[0][2]))
|
||||
try:
|
||||
python_exn = python_exn_type(
|
||||
nested_exceptions[-1][1].format(*nested_exceptions[0][2]))
|
||||
except Exception as ex:
|
||||
python_exn = RuntimeError(
|
||||
f"Exception type={python_exn_type}, which couldn't be "
|
||||
f"reconstructed ({ex})"
|
||||
)
|
||||
python_exn.artiq_core_exception = core_exn
|
||||
raise python_exn
|
||||
|
||||
|
|
Loading…
Reference in New Issue