def trim(theory=THEORY, parallel=True, **options): """Trim a set of normal regions for running analyst on small machines. Options: log_level, log_file """ with atlas.chdir(theory): options.setdefault('log_file', 'trim.log') with cartographer.load(theory, DB('world.normal'), **options) as db: min_size = pomagma.util.MIN_SIZES[theory] max_size = db.info()['item_count'] sizes = suggest_region_sizes(min_size, max_size) tasks = [] for size in sizes: tasks.append({ 'size': size, 'temperature': 0, 'filename': DB('region.normal.{:d}').format(size) }) if parallel: print 'Trimming {} regions of sizes {}-{}'.format( len(sizes), sizes[0], sizes[-1]) db.trim(tasks) else: for task in tasks: print 'Trimming region of size {}'.format(task['size']) db.trim([task])
def trim_normal_regions(self): self.log('Trimming normal regions') assert self.is_normal() max_size = self.db.info()['item_count'] # trim sequentially because these are large for size in suggest_region_sizes(self.min_size, max_size): filename = self.normal_region.format(size) self.db.trim([{'size': size, 'filename': filename}])