Example #1
0
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
Example #2
0
from filestore.fs import FileStore

# pull from /etc/metadatastore/connection.yaml or
# /home/BLUSER/.config/metdatastore/connection.yml
mds = MDS({'host': 'xf21id1-ca1',
   'database': 'metadatastore',
   'port': 27017,
   'timezone': 'US/Eastern'}, auth=False)
# mds = MDS({'host': CA, 'port': 7770})

# pull configuration from /etc/filestore/connection.yaml or
# /home/BLUSER/.config/filestore/connection.yml
db = Broker(mds, FileStore({'host': 'xf21id1-ca1',
		    'port': 27017,
		    'database': 'filestore'}))
register_builtin_handlers(db.fs)

# Subscribe metadatastore to documents.
# If this is removed, data is not saved to metadatastore.
from bluesky.global_state import gs
gs.RE.subscribe('all', mds.insert)

# At the end of every run, verify that files were saved and
# print a confirmation message.
#from bluesky.callbacks.broker import verify_files_saved
#gs.RE.subscribe('stop', post_run(verify_files_saved))

# Import matplotlib and put it in interactive mode.
import matplotlib.pyplot as plt
plt.ion()
Example #3
0
_mds_config_old = {'host': 'xf03id-ca1',
               'port': 27017,
               'database': 'datastore',
               'timezone': 'US/Eastern'}
mds_old = MDS(_mds_config_old, auth=False)

_fs_config_old = {'host': 'xf03id-ca1',
              'port': 27017,
              'database': 'filestore'}
db_old = Broker(mds_old, FileStore(_fs_config_old))


from hxntools.handlers.xspress3 import Xspress3HDF5Handler
from hxntools.handlers.timepix import TimepixHDF5Handler

register_builtin_handlers(db_new.fs)

db_new.fs.register_handler(Xspress3HDF5Handler.HANDLER_NAME,
                           Xspress3HDF5Handler)
db_new.fs.register_handler(TimepixHDF5Handler._handler_name,
                           TimepixHDF5Handler, overwrite=True)


register_builtin_handlers(db_old.fs)
db_old.fs.register_handler(Xspress3HDF5Handler.HANDLER_NAME,
                           Xspress3HDF5Handler)
db_old.fs.register_handler(TimepixHDF5Handler._handler_name,
                           TimepixHDF5Handler, overwrite=True)


# wrapper for two databases
Example #4
0
from filestore.fs import FileStore

# pull from /etc/metadatastore/connection.yaml
mds = MDS({'host': 'xf10id-ca1',
           'database': 'datastore',
           'port': 27017,
           'timezone': 'US/Eastern'
           }, auth=False)
# mds = MDS({'host': CA, 'port': 7770})

# pull configuration from /etc/filestore/connection.yaml
db = Broker(mds, FileStore({'host': 'xf10id-ca1',
                            'database': 'filestore',
                            'port': 27017,
                            }))
register_builtin_handlers(db.fs)

from bluesky.global_state import gs
gs.RE.subscribe_lossless('all', mds.insert)

# Import matplotlib and put it in interactive mode.
import matplotlib.pyplot as plt
plt.ion()

# Make plots update live while scans run.
from bluesky.utils import install_qt_kicker
install_qt_kicker()


RE=gs.RE
RE.md['beamline_id'] = 'IXS'