def iterate_over_stream(self, stream_name, fill=False, key=None, **kwargs): if key is None: key = self.key if key: for event in db.get_events(self.header, fill=False, name=stream_name): yield event['data'][key]
def f(name, doc): if name != 'stop': return uid = ensure_uid(doc['run_start']) header = db[uid] callback('start', header['start']) for descriptor in header['descriptors']: callback('descriptor', descriptor) for event in db.get_events(header, fill=fill): callback('event', event) # Depending on the order that this callback and the # databroker-insertion callback were called in, the databroker might # not yet have the 'stop' document that we currently have, so we'll # use our copy instead of expecting the header to include one. callback('stop', doc)
def test_get_resource_uid(): from databroker import DataBroker as db fs = FileStoreMoving(db.fs.config) old_fs = db.fs db.fs = fs register_builtin_handlers(fs) events = list(image_and_scalar.run()) fs_res = set() run_start = events[0]['descriptor']['run_start'] hdr = db[run_start['uid']] for ev in db.get_events(hdr, fill=False): for k in ['img', 'img_sum_x', 'img_sum_y']: dd = ev['data'] if k in dd: fs_res.add(fs.resource_given_eid(dd[k])['uid']) assert fs_res == db.get_resource_uids(hdr) db.fs = old_fs
def verify_files_saved(name, doc, db=None): "This is a brute-force approach. We retrieve all the data." if db is None: from databroker import DataBroker as db ttime.sleep(0.1) # Wait for data to be saved. if name != 'stop': return print(" Verifying that all the run's Documents were saved...") try: header = db[ensure_uid(doc['run_start'])] except Exception as e: print(" Verification Failed! Error: {0}".format(e)) return else: print('\x1b[1A\u2713') # print a checkmark on the previous line print(" Verifying that all externally-stored files are accessible...") try: list(db.get_events(header, fill=True)) except Exception as e: print(" Verification Failed! Error: {0}".format(e)) else: print('\x1b[1A\u2713') # print a checkmark on the previous line
def verify_files_saved(name, doc, db=None): "This is a brute-force approach. We retrieve all the data." if db is None: from databroker import DataBroker as db ttime.sleep(0.1) # Wati for data to be saved. if name != 'stop': return print(" Verifying that all the run's Documents were saved...") try: header = db[doc['run_start']] except Exception as e: print(" Verification Failed! Error: {0}".format(e)) return else: print('\x1b[1A\u2713') # print a checkmark on the previous line print(" Verifying that all externally-stored files are accessible...") try: list(db.get_events(header, fill=True)) except Exception as e: print(" Verification Failed! Error: {0}".format(e)) else: print('\x1b[1A\u2713') # print a checkmark on the previous line