Skip to content

FunctionRunner getting incorrect source code of function #43

@chrisjbillington

Description

@chrisjbillington

The following connection table:

from labscript import *
from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock
from labscript_devices.FunctionRunner.labscript_devices import FunctionRunner

DummyPseudoclock(name='pulseblaster_0')
FunctionRunner('fr')

start()
stop(1)

And experiment:

from labscript import *
from labscript_devices.DummyPseudoclock.labscript_devices import DummyPseudoclock
from labscript_devices.FunctionRunner.labscript_devices import FunctionRunner

DummyPseudoclock(name='pulseblaster_0')

FunctionRunner('fr')

def foo(shot_context,t,arg):
    print(f"hello, {arg}!")
    x=7
    print(x)

fr.add_function('start',foo,'world')

start()
t = 0
stop(t+0.1)

When compiled and run, gives an error in BLACS which for me is:

Traceback (most recent call last):
  File "/home/bilbo/venvs/labscript/blacs.git/blacs/tab_base_classes.py", line 925, in _transition_to_buffered
    return self.transition_to_buffered(
  File "/home/bilbo/venvs/labscript/labscript_devices.git/labscript_devices/FunctionRunner/blacs_workers.py", line 68, in transition_to_buffered
    self.function_table = deserialise_function_table(
  File "/home/bilbo/venvs/labscript/labscript_devices.git/labscript_devices/FunctionRunner/blacs_workers.py", line 40, in deserialise_function_table
    function, args, kwargs = deserialise_function(
  File "/home/bilbo/venvs/labscript/labscript_devices.git/labscript_devices/FunctionRunner/utils.py", line 59, in deserialise_function
    exec(code, namespace)
  File "<string>", line 19, in <module>
  File "/home/bilbo/venvs/labscript/.venv/lib/python3.8/site-packages/zprocess/process_tree.py", line 1475, in connect_to_parent
    raise ValueError(msg)
ValueError: Cannot connect_to_parent() twice

And which for Rohit who reported the issue on the mailing list is:

Traceback (most recent call last):
  File "C:\labscript_suite\blacs\tab_base_classes.py", line 926, in _transition_to_buffered
    device_name, h5_file, front_panel_values, fresh
  File "C:\labscript_suite\labscript_devices\FunctionRunner\blacs_workers.py", line 69, in transition_to_buffered
    function_table, self.device_name
  File "C:\labscript_suite\labscript_devices\FunctionRunner\blacs_workers.py", line 41, in deserialise_function_table
    name, source, args, kwargs, __name__=device_name, __file__=device_name
  File "C:\labscript_suite\labscript_devices\FunctionRunner\utils.py", line 56, in deserialise_function
    code = compile(source, '<string>', 'exec', dont_inherit=True,)
  File "<string>", line 1
    def mainloop(self):
    ^
IndentationError: unexpected indent

Looking at my shot file, it seems the FunctionRunner has saved the entire source of runmanager/batch_compiler.py, whereas presumably it has saved just the mainloop() function for Rohit.

Needless to say, it shouldn't be doing that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions