Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Better error reporting on startup #3

Open
DavidSagan opened this issue Sep 29, 2017 · 1 comment
Open

Better error reporting on startup #3

DavidSagan opened this issue Sep 29, 2017 · 1 comment

Comments

@DavidSagan
Copy link

Starting up Tao with, say a misspelled lattice file:
>>> tao = Tao('-lat Oops.bmad')
Gives the error traceback:

  File "<stdin>", line 1, in <module>
  File "/nfs/acc/user/dcs16/TaoGui/pytao/pytao/tao.py", line 135, in __init__
    self.pipe.set_init_args(join_args(initargs))
  File "/home/dcs16/dcs16/usr_local/lib/python3.5/site-packages/minrpc-0.0.3-py3.5.egg/minrpc/client.py", line 139, in DeferredMethod
  File "/home/dcs16/dcs16/usr_local/lib/python3.5/site-packages/minrpc-0.0.3-py3.5.egg/minrpc/client.py", line 93, in _request
  File "/home/dcs16/dcs16/usr_local/lib/python3.5/site-packages/minrpc-0.0.3-py3.5.egg/minrpc/client.py", line 99, in _dispatch
  File "/home/dcs16/dcs16/usr_local/lib/python3.5/site-packages/minrpc-0.0.3-py3.5.egg/minrpc/client.py", line 107, in _dispatch_exception
minrpc.client.ImportError: Traceback (most recent call last):
  File "/home/dcs16/dcs16/usr_local/lib/python3.5/site-packages/minrpc-0.0.3-py3.5.egg/minrpc/service.py", line 85, in _dispatch
  File "/home/dcs16/dcs16/usr_local/lib/python3.5/site-packages/minrpc-0.0.3-py3.5.egg/minrpc/service.py", line 101, in _dispatch_function_call
ImportError: No module named 'pytao.tao_pipe'

This is very uninformative. Is there a way to give a better error message?

@coldfix
Copy link
Member

coldfix commented Oct 1, 2017

The ImportError is a bit weird and should not happen due to a runtime error. It should occur only when there is a problem with how the C extension module is linked against bmad/tao or if you are executing from a directory into which pytao is not installed. This can happen, e.g., if you have installed with python setup.py install and then execute the python process from the clone directory. In this case, the pytao package is loaded from the current working directory, but this folder doesn't contain the built C extension module (which goes in to <prefix>/lib/pythonX.Y/site-packages/pytao/). To circumvent this, install pytao with python setup.py develop or execute python from anywhere else but the pytao directory.

The same line shows for me:

>>> tao = Tao('-lat Oops.bmad')
    ERROR IN bmad_parser: UNABLE TO OPEN FILE: Oops.bmad

[FATAL | 2017-OCT-01 13:09:53] tao_init_lattice:
    PARSER ERROR DETECTED FOR UNIVERSE: 1
    EXITING...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/thomas/hit/dev/.virtualenv/27-production/src/pytao/pytao/tao.py", line 136, in __init__
    self.set('global', lattice_calc_on='F')
  File "/home/thomas/hit/dev/.virtualenv/27-production/src/pytao/pytao/tao.py", line 351, in set
    self.command('set', join_args(what), k, '=', v)
  File "/home/thomas/hit/dev/.virtualenv/27-production/src/pytao/pytao/tao.py", line 162, in command
    self.pipe.command(cmd)
  File "/home/thomas/hit/dev/minrpc/minrpc/client.py", line 148, in DeferredMethod
    funcname, args, kwargs)
  File "/home/thomas/hit/dev/minrpc/minrpc/client.py", line 100, in _request
    raise RemoteProcessCrashed()
minrpc.client.RemoteProcessCrashed

So, if bmad/tao properly reports the error before crashing, the relevant line is contained in the output. However, the RPC mechanism adds several stack layers that you are generally uninterested in - that's true and not easy to fix.

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

No branches or pull requests

2 participants