databroker
databroker copied to clipboard
archiver function fails on first execution - making it not compatible with flow control
For the code below, Shift+Enter is needed twice for the cell containing the last line of the input code below. This is also the case if PVs are changed or Kernel is restarted.
input code
from databroker.eventsource.archiver import ArchiverEventSource
from databroker import Broker
db = Broker.named('six',auto_register = False)
labels = ['m6pit', 'm7pit', 'grpit']
pv_dict={labels[0]:'XF:02IDD-ES{Mir:6-Ax:Pch}Mtr.RBV',
labels[1]:'XF:02IDD-ES{Mono:2-Ax:MP}Mtr.RBV',
labels[2]:'XF:02IDD-ES{Mono:2-Ax:GP}Mtr.RBV'}
ARCHIVER_URL = 'http://xf02id1-ca1.cs.nsls2.local:17668'
arc = ArchiverEventSource(ARCHIVER_URL, 'US/Eastern', pv_dict)
scans =[66861,]
h = db[scans[0]]
data = arc.table_given_header(h)
Last line returns exception for the first execution (new PVs or reset kernel)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-2ab349fe4ecc> in <module>()
----> 1 data = arc.table_given_header(h)
2 print(data.shape)
3 print('\nlines returned from archive: ', data.shape[0])
4 print('\nlines per PV (avg): ', data.shape[0]/len(labels))
5 print('\nkeys of data:',data.keys() )
/opt/conda_envs/analysis-2018-3.2/lib/python3.6/site-packages/databroker/eventsource/archiver.py in table_given_header(self, header, fields)
113 fields = set(fields)
114 docs = list(self.docs_given_header(header=header,
--> 115 fill=False, fields=fields))
116 return pd.DataFrame.from_records(data=docs, index='seq_num')
117
/opt/conda_envs/analysis-2018-3.2/lib/python3.6/site-packages/databroker/eventsource/archiver.py in docs_given_header(self, header, fill, fields, **kwargs)
83 for d in self.descriptors_given_header(header):
84 # Stash the desc uids in a local var so we can use them in events.
---> 85 pv = list(d['data_keys'].values())[0]['source']
86 desc_uids[pv] = d['uid']
87 yield d
TypeError: string indices must be integers
Note that this is probably some version of data broker 0.9.x
or 0.11.x
.