labscript-suite-temp / blacs

BLACS, part of the labscript suite, provides an interface to hardware used to control a buffered experiment. It manages a queue of shots to be run as well as providing manual control over devices between shots.
Other
0 stars 0 forks source link

Connection table recompile can't handle missing globals file #42

Closed philipstarkey closed 6 years ago

philipstarkey commented 6 years ago

Original report (archived issue) by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


There is a exception in BLACS when one of the globals files is missing during recompilation of the connection table. This exception does not make its cause obvious:

#!python

2018-04-26 10:42:16,874 ERROR BLACS: Got an exception:
Traceback (most recent call last):
  File "/Users/janwerkmann/labscript_suite/blacs/plugins/connection_table/__init__.py", line 188, in on_recompile_connection_table
    self.BLACS['plugins'][module].menu.on_recompile_connection_table()
  File "/Users/janwerkmann/labscript_suite/blacs/plugins/connection_table/__init__.py", line 130, in on_recompile_connection_table
    CompileAndRestart(self.BLACS, globals_files, self.BLACS['exp_config'].get('paths','connection_table_py'), self.BLACS['exp_config'].get('paths','connection_table_h5'),close_notification_func=self.close_notification_func)
  File "/Users/janwerkmann/labscript_suite/blacs/compile_and_restart.py", line 54, in __init__
    self.compile()
  File "/Users/janwerkmann/labscript_suite/blacs/compile_and_restart.py", line 76, in compile
    self.globals_files, self.tempfilename, self.output_box.port, self.finished_compiling)
  File "/Users/janwerkmann/labscript_suite/runmanager/__init__.py", line 748, in compile_labscript_with_globals_files_async
    zprocess.zmq_push_multipart(stream_port, data=['stderr', error])
  File "/Users/janwerkmann/anaconda/lib/python2.7/site-packages/zprocess/clientserver.py", line 259, in __call__
    data = _typecheck_or_convert_data(data, self.dtype)
  File "/Users/janwerkmann/anaconda/lib/python2.7/site-packages/zprocess/clientserver.py", line 75, in _typecheck_or_convert_data
    raise TypeError(msg)
TypeError: multipart sockets can only send an iterable of bytes objects, not <type 'list'>.

Traceback (most recent call last):
  File "/Users/janwerkmann/labscript_suite/blacs/plugins/connection_table/__init__.py", line 188, in on_recompile_connection_table
    self.BLACS['plugins'][module].menu.on_recompile_connection_table()
  File "/Users/janwerkmann/labscript_suite/blacs/plugins/connection_table/__init__.py", line 130, in on_recompile_connection_table
    CompileAndRestart(self.BLACS, globals_files, self.BLACS['exp_config'].get('paths','connection_table_py'), self.BLACS['exp_config'].get('paths','connection_table_h5'),close_notification_func=self.close_notification_func)
  File "/Users/janwerkmann/labscript_suite/blacs/compile_and_restart.py", line 54, in __init__
    self.compile()
  File "/Users/janwerkmann/labscript_suite/blacs/compile_and_restart.py", line 76, in compile
    self.globals_files, self.tempfilename, self.output_box.port, self.finished_compiling)
  File "/Users/janwerkmann/labscript_suite/runmanager/__init__.py", line 748, in compile_labscript_with_globals_files_async
    zprocess.zmq_push_multipart(stream_port, data=['stderr', error])
  File "/Users/janwerkmann/anaconda/lib/python2.7/site-packages/zprocess/clientserver.py", line 259, in __call__
    data = _typecheck_or_convert_data(data, self.dtype)
  File "/Users/janwerkmann/anaconda/lib/python2.7/site-packages/zprocess/clientserver.py", line 75, in _typecheck_or_convert_data
    raise TypeError(msg)
TypeError: multipart sockets can only send an iterable of bytes objects, not <type 'list'>.
philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Looks like the exception string is the wrong datatype on Python 3. Could you try changing the offending line to:

zprocess.zmq_push_multipart(stream_port, data=['stderr', error.encode('utf8')])

with the error string getting encoded to bytes?

philipstarkey commented 6 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


nope tried that didn't work

philipstarkey commented 6 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


I think the error states that zprocess.zmq_push_multipart doesn't like lists as data but I'm still investigating.

philipstarkey commented 6 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


Ok so I found the bug. zprocess.zmq_push_multipart calls _typecheck_or_convert_data. This function checks that all items in the list 'data' are of type bytes. However this will not be the case in python3 for all strings that don't have a bytes literal in front of them. So the fix would be:

#!python

zprocess.zmq_push_multipart(stream_port, data=[b'stderr', error.encode('utf8')])

Should I create a pull request over at runmanager or should we fix this in zprocess.?

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Excellent!

I consider this a runmanager bug, zprocess is doing the intended error checking and I don't think I want it to auto encode, though its error could be made more useful by saying the type of the element in the list instead of just 'list'. But I'll deal with that separately.

philipstarkey commented 6 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


Fixed in runmanager commit labscript-suite-temp/runmanager@85e7c9978f411ec329dfb4a86091dfa0869a1469