def fiup(ctx, collection, path, registry, dest, pool_size): """Collect files in a study by COLLECTION (accession number) using a PATH REGISTRY, and send to DEST.""" services = ctx.obj.get('services') click.echo(click.style('Upload Registered Files by Accession Number', underline=True, bold=True)) file_indexer = FileIndexer(pool_size=pool_size) R = Redis(**services[registry]) O = Orthanc(**services[dest]) if collection != "ALL": result = file_indexer.upload_collection( collection=collection, basepath=path, registry=R, dest=O ) else: items = file_indexer.items_on_path(basepath=path, registry=R) click.echo('Expecting {} items on path'.format(len(items))) result = file_indexer.upload_path( basepath=path, registry=R, dest=O ) click.echo(result)
def test_index(setup_redis): print("Testing indexing speed") R = Redis() R.clear() dcmfdx = FileIndexer(pool_size=15) dcmfdx.index_path( basepath=path, registry=R, rex="*", recurse_style=recursion_style ) """
def test_redis_index(setup_redis): R = Redis() d = Dixel(meta={"FileName": "my_file"}, tags={"AccessionNumber": "100"}) R.add_to_collection(d, item_key="FileName") logging.debug( R.collections() ) assert("100" in R.collections() ) logging.debug( R.collected_items("100") ) assert("my_file" in R.collected_items("100") )
def findex(ctx, path, registry, orthanc_db, regex, pool_size): """Inventory collections of files by accession number with a PATH REGISTRY for retrieval""" services = ctx.obj.get('services') click.echo(click.style('Register Files by Accession Number', underline=True, bold=True)) file_indexer = FileIndexer(pool_size=pool_size) R = Redis(**services[registry]) result = file_indexer.index_path( path, registry=R, rex=regex, recurse_style="UNSTRUCTURED" if not orthanc_db else "ORTHANC" ) click.echo(result)
def test_upload(setup_redis, setup_orthanc0): print("Testing upload speed") R = Redis() O = Orthanc() O.clear() dcmfdx = FileIndexer(pool_size=15) dcmfdx.upload_path( basepath=path, registry=R, dest=O ) pprint(O.gateway.statistics()) """
def test_redis_ep(setup_redis): logging.debug("Test Redis EP") R = Redis() logging.debug(R) R.check() t = Test(data={"myDateTime": datetime.now(), "foo": {'bar': 3}}) id = R.put(t) s = R.get(id) logging.debug(t) logging.debug(s) assert( t == s ) u = Test(data=42) id2 = R.put(u) v = R.get(id2) logging.debug(u) logging.debug(v) assert( u == v ) R.update(id, u) w = R.get(id) assert( w == v ) assert( w != s ) assert( R.exists(id) ) R.delete(id) assert( not R.exists(id) ) a = "one two three" id2 = R.put(a) b = R.get(id2) assert( a == b )
def get_cache(self): return Redis(**self.redis_conf)