示例#1
0
    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)
示例#2
0
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
示例#3
0
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)