DPU GUI lagging after python 3 update

The legacy DPU GUI (originating in main_eVOLVER.py) seems a lot laggier since the switch to python 3, any ideas on how to improve this? The GUI is really just two buttons, so is there a different/reduced overhead way to do this?
One option would be rounding out the experiment manager in the electron app, but if there’s an intermediate option, might be nice in the meantime.

This has to do with the new DPU websockets communication logic and not because of the python 3 switch. I think there is a delay in there where it is just waiting for the signal from the eVOLVER for the new broadcast measurement. I’m not sure if theres a way to switch that around such that it doesnt happen? @heinsz

I don’t think this is the case. Tk GUI runs on a separate thread than everything else. When I converted the code, the GUI was slow before I added websockets. I just found this stack overflow post that might be helpful for us to try:

After more reading, maybe this is the problem? I found a different workaround here:

A simple test would be to remove the while loops, see if it is responsive. We can also do the opposite, make an infinite loop and see how the GUI responds.

GUI’s in python are kind of awkward. I have some code written that lets you send signals to the python program from an external application, which is what we used to allow the electron app to manage the python script. We should probably just move towards that direction, and eventually use the class based implementation of experiments in dpu-cloud.

https://github.com/FYNCH-BIO/dpu-cloud/tree/master/legacy/pyshell

1 Like

Lets just try to test and transition to the electron GUI ASAP then, since thats almost ready for deployment anyways.

2 Likes

I agree. I’m happy to help - I got it relatively close for the jove paper, it just needs a few extra features to work for real experiments. I’ll describe it in some github issues.

Perhaps completely removing the GUI and replacing it with a while True loop could temporarily solve the issue. One could catch Ctrl-C events to pause the script. The user can then hit Ctrl-C again to permanently stop the script or another key to resume. I think I can give it a shot while the new features are getting ready.

I implemented a no-GUI client script (along with some other refactoring and logging to file). You can find it here if it can be useful, but the relevant change is this one:

if __name__ == '__main__':
    exp_name, evolver_ip, evolver_port = custom_script.choose_name()
    vials = range(0,16)
    start_time, OD_initial = eVOLVER_module.initialize_exp(exp_name, vials,
                                                           evolver_ip,
                                                           evolver_port)
    loop_start = time.time()
    while True:
        try:
            # run update if at least a second has passed
            loop_time = time.time()
            if loop_time - loop_start >= 1:
                update_eVOLVER()
                loop_start = time.time()
        except KeyboardInterrupt:
            try:
                print('Ctrl-C detected, pausing experiment')
                stop_exp()
                while True:
                    key = input('Experiment paused. Press any key to restart '
                                ' or hit Ctrl-C again to terminate experiment')
                    break
            except KeyboardInterrupt:
                print('Second Ctrl-C detected, shutting down')
                stop_exp()
                print('Experiment stopped, goodbye!')
                break
1 Like

I have made the changes needed to remove the GUI (together with light refactoring and adding a log file); I have opened a pull request, suggestions/edits are welcome.