def intercept(work_db: WorkDB, config: ConfigDict): """Mark as skipped all work item with filtered operator """ exclude_operators = config.get('exclude-operators') re_exclude_operators = re.compile('|'.join('(:?%s)' % e for e in exclude_operators)) for item in work_db.pending_work_items: if re_exclude_operators.match(item.operator_name): log.info( "operator skipping %s %s %s %s %s %s", item.job_id, item.operator_name, item.occurrence, item.module_path, item.start_pos, item.end_pos, ) work_db.set_result( item.job_id, WorkResult( output="Filtered operator", worker_outcome=WorkerOutcome.SKIPPED, ), )
def init(module_paths, work_db: WorkDB): """Clear and initialize a work-db with work items. Any existing data in the work-db will be cleared and replaced with entirely new work orders. In particular, this means that any results in the db are removed. Args: module_paths: iterable of pathlib.Paths of modules to mutate. work_db: A `WorkDB` instance into which the work orders will be saved. """ operator_names = list(cosmic_ray.plugins.operator_names()) work_db.clear() work_db.add_work_items(_all_work_items(module_paths, operator_names))
def filter(self, work_db: WorkDB, args: Namespace): """Mark as skipped all work item that is not new """ if args.config is None: config = work_db.get_config() else: config = load_config(args.config) branch = config.sub('git', 'git-filter').get('branch', 'master') self._skip_filtered(work_db, branch)
def filter(self, work_db: WorkDB, args: Namespace): """Mark as skipped all work item with filtered operator """ if args.config is None: config = work_db.get_config() else: config = load_config(args.config) exclude_operators = config.sub('filters', 'operators-filter').get( 'exclude-operators', ()) self._skip_filtered(work_db, exclude_operators)