labscript-suite / lyse

π—Ήπ˜†π˜€π—² is a data analysis framework for experiments controlled by the 𝘭𝘒𝘣𝘴𝘀𝘳π˜ͺ𝘱𝘡 𝘴𝘢π˜ͺ𝘡𝘦. It coordinates online analysis of live experiment data, by automatically running Python analysis scripts.
http://labscriptsuite.org
Other
3 stars 45 forks source link

[Question] Http protocol for adding shots to lyse #94

Open ldes89150 opened 3 years ago

ldes89150 commented 3 years ago

Hi,

In our lab, we use control systems forked from Sandia National Lab https://github.com/QITI/IonControl and ARTIQ.

I am thinking of adding the capability of sending shots to lyse from our control systems.

Can you point me to some documents about the http protocol for communicating lyse?

Thanks!

chrisjbillington commented 3 years ago

Hi @ldes89150,

The protocol isn't HTTP - lyse is listening on a zeromq REP socket. It expects a client REQ socket to connect to it and send a dictionary that has been serialised using python's pickle module, in the format:

{"filepath": <path of a shot file>}

Where the dictionary's value is a filepath to a shot file on disk.

If you want to submit shots to it from another control system, you'll need to have some code store the shot's data into a HDF5 file in the same format the rest of the labscript suite uses to store data - this varies depending on what kind of data, but we can talk more about that if you're not familiar.

So long as your code is in Python and you have the labscript suite installed, the easiest way to send a shot to lyse (provided you've already got a shot file) would be the following Python code using wrapper functions.

from labscript_utils.labconfig import LabConfig
from labscript_utils.ls_zprocess import zmq_get
from labscript_utils.shared_drive import path_to_agnostic

port = LabConfig().get('ports', 'lyse')
hostname = 'localhost' # computer running lyse
shot_file = "path/to/some/shot_file.h5"

zmq_get(port, hostname, {"filename": path_to_agnostic(shot_file)})

The path_to_agnostic is so that you can pass a filepath that is on a shared drive, between computers that might have different drive letters for the shared drive (if you have configured labscript to use a shared drive in this way).