def execute(self): vol = CloudVolume(self.layer_path) highres_bbox = Bbox( self.offset, self.offset + self.shape ) for mip in vol.available_mips: vol.mip = mip slices = vol.slices_from_global_coords(highres_bbox.to_slices()) bbox = Bbox.from_slices(slices).round_to_chunk_size(vol.underlying, offset=vol.bounds.minpt) vol.delete(bbox)
def execute(self): vol = CloudVolume(self.layer_path, mip=self.mip) highres_bbox = Bbox( self.offset, self.offset + self.shape ) top_mip = min(vol.available_mips[-1], self.mip + self.num_mips) for mip in range(self.mip, top_mip + 1): vol.mip = mip bbox = vol.bbox_to_mip(highres_bbox, self.mip, mip) bbox = bbox.round_to_chunk_size(vol.underlying, offset=vol.bounds.minpt) bbox = Bbox.clamp(bbox, vol.bounds) if bbox.volume() == 0: continue vol.delete(bbox)
def DeleteTask(layer_path:str, shape, offset, mip=0, num_mips=5): """Delete a block of images inside a layer on all mip levels.""" shape = Vec(*shape) offset = Vec(*offset) vol = CloudVolume(layer_path, mip=mip, max_redirects=0) highres_bbox = Bbox( offset, offset + shape ) top_mip = min(vol.available_mips[-1], mip + num_mips) for mip_i in range(mip, top_mip + 1): vol.mip = mip_i bbox = vol.bbox_to_mip(highres_bbox, mip, mip_i) bbox = bbox.round_to_chunk_size(vol.chunk_size, offset=vol.bounds.minpt) bbox = Bbox.clamp(bbox, vol.bounds) if bbox.volume() == 0: continue vol.delete(bbox)
def benchmark_upload(voltype): global CHUNK_SIZES global N originvol = CloudVolume('gs://seunglab-test/test_v0/{}'.format(voltype)) originvol.reset_scales() info = deepcopy(originvol.info) img = originvol[:] for chunk_size in CHUNK_SIZES[::-1]: cloudpath = 'gs://seunglab-test/test_v0/{}_upload_{}_{}_{}'.format(voltype, *chunk_size) info['scales'][0]['chunk_sizes'] = [ list(chunk_size) ] vol = CloudVolume(cloudpath, progress=True, info=info, compress='gzip') def upload(): vol[:] = img stats = benchmark(upload, N) log({ "direction": "upload", "compression": "gzip", "image_type": voltype, "N": N, "mean": stats['mean'], "fastest": stats['fastest'], "slowest": stats['slowest'], "cloudpath": cloudpath, "chunk_size": chunk_size, "dtype": vol.dtype, "hostname": socket.gethostname(), }) vol.delete(vol.bounds) for chunk_size in CHUNK_SIZES[::-1]: cloudpath = 'gs://seunglab-test/test_v0/{}_upload_{}_{}_{}'.format(voltype, *chunk_size) info['scales'][0]['chunk_sizes'] = [ list(chunk_size) ] vol = CloudVolume(cloudpath, progress=True, info=info, compress='') def upload(): vol[:] = img stats = benchmark(upload, N) log({ "direction": "upload", "compression": "none", "image_type": voltype, "N": N, "mean": stats['mean'], "fastest": stats['fastest'], "slowest": stats['slowest'], "cloudpath": cloudpath, "chunk_size": chunk_size, "dtype": vol.dtype, "hostname": socket.gethostname(), }) vol.delete(vol.bounds)