def test_no_evdesc(): run_start_uid = mdsc.insert_run_start( scan_id=42, beamline_id='testbed', owner='tester', group='awesome-devs', project='Nikea', time=document_insertion_time, uid=str(uuid.uuid4())) with pytest.raises(mdsc.NoEventDescriptors): mdsc.descriptors_by_start(run_start_uid)
def test_no_evdesc(): run_start_uid = mdsc.insert_run_start(scan_id=42, beamline_id='testbed', owner='tester', group='awesome-devs', project='Nikea', time=document_insertion_time, uid=str(uuid.uuid4())) mdsc.descriptors_by_start(run_start_uid)
def from_run_start(cls, run_start, verify_integrity=False): """ Build a Header from a RunStart Document. Parameters ---------- run_start : metadatastore.document.Document or str RunStart Document or uid Returns ------- header : databroker.broker.Header """ run_start_uid = mc.doc_or_uid_to_uid(run_start) run_start = mc.run_start_given_uid(run_start_uid) try: run_stop = doc.ref_doc_to_uid(mc.stop_by_start(run_start_uid), 'run_start') except mc.NoRunStop: run_stop = None try: ev_descs = [doc.ref_doc_to_uid(ev_desc, 'run_start') for ev_desc in mc.descriptors_by_start(run_start_uid)] except mc.NoEventDescriptors: ev_descs = [] d = {'start': run_start, 'stop': run_stop, 'descriptors': ev_descs} return cls('header', d)
def test_run_stop_by_run_start(): run_start_uid, e_desc_uid, data_keys = setup_syn() run_stop_uid = mdsc.insert_run_stop(run_start_uid, ttime.time(), uid=str(uuid.uuid4())) run_start = mdsc.run_start_given_uid(run_start_uid) run_stop = mdsc.run_stop_given_uid(run_stop_uid) ev_desc = mdsc.descriptor_given_uid(e_desc_uid) run_stop2 = mdsc.stop_by_start(run_start) run_stop3 = mdsc.stop_by_start(run_start_uid) assert run_stop == run_stop2 assert run_stop == run_stop3 ev_desc2, = mdsc.descriptors_by_start(run_start) ev_desc3, = mdsc.descriptors_by_start(run_start_uid) assert ev_desc == ev_desc2 assert ev_desc == ev_desc3
def test_run_stop_by_run_start(): run_start_uid, e_desc_uid, data_keys = setup_syn() run_stop_uid = mdsc.insert_run_stop(run_start_uid, ttime.time(), uid=str(uuid.uuid4())) run_start = mdsc.run_start_given_uid(run_start_uid) run_stop = mdsc.run_stop_given_uid(run_stop_uid) ev_desc = mdsc.descriptor_given_uid(e_desc_uid) run_stop2 = mdsc.stop_by_start(run_start) run_stop3 = mdsc.stop_by_start(run_start_uid) assert_equal(run_stop, run_stop2) assert_equal(run_stop, run_stop3) ev_desc2, = mdsc.descriptors_by_start(run_start) ev_desc3, = mdsc.descriptors_by_start(run_start_uid) assert_equal(ev_desc, ev_desc2) assert_equal(ev_desc, ev_desc3)
def f(name, stop_doc): uid = stop_doc['run_start'] start = run_start_given_uid(uid) descriptors = descriptors_by_start(uid) # For convenience, I'll rely on the broker to get Events. header = db[uid] events = get_events(header) callback.start(start) for d in descriptors: callback.descriptor(d) for e in events: callback.event(e) callback.stop(stop_doc)
def f(name, stop_doc): if name != 'stop': return uid = stop_doc['run_start'] start = run_start_given_uid(uid) descriptors = descriptors_by_start(uid) # For convenience, I'll rely on the broker to get Events. header = db[uid] events = get_events(header) callback('start', start) for d in descriptors: callback('descriptor', d) for e in events: callback('event', e) callback('stop', stop_doc)