def build_pymongo_backed_broker(request): '''Provide a function level scoped MDS instance talking to temporary database on localhost:27017 with v1 schema. ''' from metadatastore.mds import MDS from filestore.utils import create_test_database from filestore.fs import FileStore db_name = "mds_testing_disposable_{}".format(str(uuid.uuid4())) md_test_conf = dict(database=db_name, host='localhost', port=27017, timezone='US/Eastern') mds = MDS(md_test_conf, 1, auth=False) db_name = "fs_testing_base_disposable_{uid}" fs_test_conf = create_test_database(host='localhost', port=27017, version=1, db_template=db_name) fs = FileStore(fs_test_conf, version=1) def delete_fs(): print("DROPPING DB") fs._connection.drop_database(fs_test_conf['database']) mds._connection.drop_database(md_test_conf['database']) request.addfinalizer(delete_fs) return Broker(mds, fs)
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, (20, 20)) return db
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