コード例 #1
0
ファイル: simulation.py プロジェクト: sbillinge/xpdAcq
def build_pymongo_backed_broker():
    """Provide a function level scoped MDS instance talking to
    temporary database on localhost:27017 with v1 schema.

    """
    from databroker.broker import Broker
    from metadatastore.mds import MDS
    from filestore.utils import create_test_database
    from filestore.fs import FileStore
    from filestore.handlers import NpyHandler

    db_name = "mds_testing_disposable_{}".format(str(uuid.uuid4()))
    mds_test_conf = dict(database=db_name, host='localhost',
                         port=27017, timezone='US/Eastern')
    try:
       # nasty details: to save MacOS user
        mds = MDS(mds_test_conf, 1, auth=False)
    except TypeError:
        mds = MDS(mds_test_conf, 1)

    db_name = "fs_testing_base_disposable_{}".format(str(uuid.uuid4()))
    fs_test_conf = create_test_database(host='localhost',
                                        port=27017,
                                        version=1,
                                        db_template=db_name)
    fs = FileStore(fs_test_conf, version=1)
    fs.register_handler('npy', NpyHandler)

    db = Broker(mds, fs)
    insert_imgs(db.mds, db.fs, 1, (2048,2048))

    return db
コード例 #2
0
ファイル: test_spec.py プロジェクト: BCDA-APS/suitcase
def test_spec_to_document(sf, mds_all, scan_ids):
    map = {
        'start': mds_all.insert_run_start,
        'stop': mds_all.insert_run_stop,
        'descriptor': mds_all.insert_descriptor,
        'event': mds_all.insert_event
    }
    start_uids = list()

    db = Broker(mds_all, fs=None)

    for document_name, document in spec.spec_to_document(
            sf, mds_all, scan_ids=scan_ids, validate=True):
        document = dict(document)
        del document['_name']
        if not isinstance(document_name, str):
            document_name = document_name.name
        # insert the documents
        if document_name == 'start':
            document['beamline_id'] = 'test'
            start_uids.append(document['uid'])
        map[document_name](**document)

    # make sure we are not trying to add duplicates
    assert len(start_uids) == len(set(start_uids))

    # smoketest the retrieval
    hdrs = []
    for uid in start_uids:
        hdr = db[uid]
        # make sure we only get one back
        assert isinstance(hdr, Header)
        hdrs.append(hdr)

    # make sure we are not getting duplicates back out
    hdr_uids = [hdr.start.uid for hdr in hdrs]
    assert len(hdr_uids) == len(set(hdr_uids))
    if isinstance(sf, spec.Specscan):
        sf = [sf]
    if isinstance(sf, str):
        sf = spec.Specfile(sf)
    for hdr, specscan in zip(hdrs, sf):
        for descriptor in hdr.descriptors:
            ev = list(mds_all.get_events_generator(descriptor))
            if descriptor.get('name') == 'baseline':
                # we better only have one baseline event
                assert len(ev) == 1
            else:
                assert len(specscan.scan_data) == len(ev)
コード例 #3
0
ファイル: conftest.py プロジェクト: BCDA-APS/suitcase
def mds_all(request):
    '''Provide a function level scoped metadatastore instance talking to
    temporary database on localhost:27017 with focus on v1.
    '''
    db_name = "mds_testing_disposable_{}".format(str(uuid.uuid4()))
    test_conf = dict(database=db_name,
                     host='localhost',
                     port=27017,
                     timezone='US/Eastern',
                     mongo_user='******',
                     mongo_pwd='jerry')
    #version_v = request.param
    mds = MDS(test_conf, auth=AUTH)

    db = Broker(mds, fs=None)

    def delete_dm():
        print("DROPPING DB")
        mds._connection.drop_database(db_name)

    request.addfinalizer(delete_dm)

    return db.mds
コード例 #4
0
from bluesky.callbacks.broker import LiveImage
import numpy as np
import zmq.asyncio as zmq_asyncio
from bluesky.utils import install_qt_kicker

# from xpdan.tools import better_mask_img

d = {
    'directory': '/home/christopher/live_demo_data',
    'timezone': tzlocal.get_localzone().zone,
    'dbpath': os.path.join('/home/christopher/live_demo_data', 'filestore')
}
mds = MDSRO(d)
fs = RegistryRO(d)
fs.register_handler('AD_TIFF', AreaDetectorTiffHandler)
db = Broker(mds=mds, reg=fs)
td = TemporaryDirectory()
source = conf_main_pipeline(
    db,
    td.name,
    # vis=False,
    write_to_disk=False,
    # mask_setting=None
)

# a = LiveImage('pe1_image')
loop = zmq_asyncio.ZMQEventLoop()
install_qt_kicker(loop=loop)


def put_in_queue(nd):