databroker icon indicating copy to clipboard operation
databroker copied to clipboard

ENH improved exception strings to make fault identification easier

Open ambarb opened this issue 3 years ago • 0 comments

I use the search keys function in db() to setup a big batch of header to then automate analysis.

When it fails in the search phase, I have no idea what the scan number is and I spend a lot of time hacking around in functions that are "one-off" analyses.

The exception for not finding things descriptors isn't part of the db() search keys capability but all of these things are used in conjunction to deliver data in a palatable format to understand how the experiment is going. Because of my one-off customized analysis for a single experiment, I was able to identify a problem, stop the scripts, constrain a sample translation range, and then restart. Otherwise, I would have taken junk data and not known until it was too late, and would be sitting at home after the beam time wondering how much of the data was useless.

While at the beamline, I had to spend more time find out which database record was causing the problem instead of concentrating on fixing the experiment and restarting the script.

The exception looks something like (here, just printing to illustrate my point)

----> 5     print('\t', h.descriptors[0]["configuration"]["eiger1m_single"]["data"]['eiger1m_single_cam_acquire_period'])
KeyError: 'eiger1m_single'

which doesn't tell me which scan is at fault. yes, I could the loop the entire thing with a try except and print the scan number, but this is harder if you are a user just using a beamline function (or maybe one day, a gui). IF that is the case, then you are stuck doing something like:

i=-2
h=db[i]
while h.start["scan_id"] != 47101:
    print(i, h.start["scan_id"], h.start["plan_name"], h.start["detectors"])
    print('\t', h.descriptors[0]["configuration"]["eiger1m_single"]["data"]['eiger1m_single_cam_acquire_period'])
    i = i-1
    h=db[i]

in order to see which scan number is the one causing the problem

ambarb avatar Mar 19 '21 19:03 ambarb