Dash server for experiment control

I’m developing an interface for controlling and capturing data from scientific instruments in real time. We have several experiments set up with the same instruments. All the instruments are connected to a computer, with some python code for controlling/communicating with the instruments and recording the data coming from them.

The current interface is using Bokeh, but we’re having issues with it. I’m wondering if Dash would be a better fit.

The idea is to run a single server on the computer connected to each experiment setup. Users need to control the instruments and watch the data change (while it’s also being recorded in the background). Most of the time this will be on the same computer, but not always (e.g. checking on a long-running experiment from their home computer in the evening).

The issue with Dash in this particular instance is how Callbacks aren’t supposed to mess with global state. I understand the reasoning and agree with it. However, in this particular use case there is one server connected to one set of physical devices. We specifically want to interact with these instruments which are in the global state. Obviously this will cause issues if multiple users try to connect at the same time, but this is a private thing for controlling experiments so we will make sure we don’t do that (only allowing one connection to the server is something we might look at in the future, but it’s unlikely to be an issue so it’s pretty low-priority right now).

Is Dash the right fit here? I’ve been looking all over the place for other solutions for displaying controls alongside graphs of real-time data and I’ve only found Dash and Bokeh.

I would split your use case into 3 main blocks,

A) Recording the data
B) Viewing the data
C) Controlling the experiment

Dash is a good fit for (B), but for (A) you should use something else (it sounds like this system might already be in place). You could in principle use Dash for ©, but to ensure state consistency between the controls in Dash and the experiment, websocket communication would be preferred as compared to http (which is used by Dash). There has been a previous project addressing this issue,

but i am not sure to which degree it is maintained. However, it you want to follow this path, i guess it could be a good place to start non-the-less :slight_smile:

Thanks for that Emil, that’s exactly what I’m looking for!