def extract_roots(self, model, rev_ids, caches=None): """ Extracts a mapping of root datasources capabile of generating the features needed for a particular model. :Parameters: rev_ids : int | `iterable` Revision IDs to extract for model : str The name of a :class:`~revscoring.scorer_models.scorer_model.ScorerModel` to extract the roots for """ features = self[model].features root_ds = [d for d in dependencies.dig(features) if isinstance(d, Datasource)] error_root_vals = self.extractor.extract(rev_ids, root_ds, caches=caches) root_ds_caches = {} for rev_id, (error, root_vals) in zip(rev_ids, error_root_vals): if error is None: root_ds_caches[rev_id] = \ (None, {rd: rv for rd, rv in zip(root_ds, root_vals)}) else: root_ds_caches[rev_id] = (error, None) return root_ds_caches
def extract_roots(self, model, rev_ids, caches=None): """ Extracts a mapping of root datasources capabile of generating the features needed for a particular model. :Parameters: rev_ids : int | `iterable` Revision IDs to extract for model : str The name of a :class:`~revscoring.ScorerModel` to extract the roots for """ features = self[model].features root_ds = [ d for d in dependencies.dig(features) if isinstance(d, Datasource) ] error_root_vals = self.extractor.extract(rev_ids, root_ds, caches=caches) root_ds_caches = {} for rev_id, (error, root_vals) in zip(rev_ids, error_root_vals): if error is None: root_ds_map = {rd: rv for rd, rv in zip(root_ds, root_vals)} if caches is not None: root_ds_map.update(caches.get(rev_id, {})) root_ds_caches[rev_id] = (None, root_ds_map) else: root_ds_caches[rev_id] = (error, None) return root_ds_caches
def _generate_root_datasources(self, model_names): for model_name in model_names: for dependency in dependencies.dig(self.model_features(model_name)): if isinstance(dependency, Datasource): yield dependency
def load_model_and_queue(self, q, config, key): model = Model.from_config(config, key) # Just return the model info and the root of the features q.put((model.info, list(dig(model.features))))