Beispiel #1
0
    def run(self):
        """
        Do all the calculation here.
        :return:
        """

        # for each FeatureExtractor_type key in feature_dict, find the subclass
        # of FeatureExtractor, run, and put results in a dict
        for fextractor_type in self.feature_dict:

            fextractor_class = FeatureExtractor.find_subclass(fextractor_type)

            if self.feature_option_dict is not None \
                and fextractor_type in self.feature_option_dict:
                optional_dict = self.feature_option_dict[fextractor_type]
            else:
                optional_dict = self.optional_dict  # FIXME: hacky

            runner = fextractor_class(
                self.assets,
                logger=None,
                fifo_mode=self.fifo_mode,
                delete_workdir=self.delete_workdir,
                result_store=self.result_store,
                optional_dict=optional_dict,
                optional_dict2=self.optional_dict2,
            )
            runner.run(parallelize=self.parallelize, processes=self.processes)
            results = runner.results

            self.type2results_dict[fextractor_type] = results

        # assemble an output dict with demanded atom features
        # atom_features_dict = self.fextractor_atom_features_dict
        result_dicts = list(map(lambda x: dict(), self.assets))
        for fextractor_type in self.feature_dict:
            assert fextractor_type in self.type2results_dict
            for atom_feature in self._get_atom_features(fextractor_type):
                scores_key = self._get_scores_key(fextractor_type,
                                                  atom_feature)
                for result_index, result in enumerate(
                        self.type2results_dict[fextractor_type]):
                    try:
                        result_dicts[result_index][scores_key] = result[
                            scores_key]
                    except KeyError:
                        scores_key_alt = BasicResult.scores_key_wildcard_match(
                            result.result_dict, scores_key)
                        result_dicts[result_index][scores_key] = result[
                            scores_key_alt]

        self.results = list(
            map(lambda tasset: BasicResult(tasset[0], tasset[1]),
                zip(self.assets, result_dicts)))
Beispiel #2
0
    def run(self):
        """
        Do all the calculation here.
        :return:
        """

        # for each FeatureExtractor_type key in feature_dict, find the subclass
        # of FeatureExtractor, run, and put results in a dict
        for fextractor_type in self.feature_dict:

            # fextractor = self._get_fextractor_instance(fextractor_type)
            # fextractor.run()
            # results = fextractor.results

            fextractor_class = FeatureExtractor.find_subclass(fextractor_type)

            runner = fextractor_class(
                self.assets,
                logger=None,
                fifo_mode=self.fifo_mode,
                delete_workdir=self.delete_workdir,
                result_store=self.result_store,
                optional_dict=self.optional_dict,
                optional_dict2=self.optional_dict2,
            )
            runner.run(parallelize=self.parallelize)
            results = runner.results

            self.type2results_dict[fextractor_type] = results

        # assemble an output dict with demanded atom features
        # atom_features_dict = self.fextractor_atom_features_dict
        result_dicts = map(lambda x: dict(), self.assets)
        for fextractor_type in self.feature_dict:
            assert fextractor_type in self.type2results_dict
            for atom_feature in self._get_atom_features(fextractor_type):
                scores_key = self._get_scores_key(fextractor_type,
                                                  atom_feature)
                for result_index, result in enumerate(
                        self.type2results_dict[fextractor_type]):
                    result_dicts[result_index][scores_key] = result[scores_key]

        self.results = map(
            lambda (asset, result_dict): BasicResult(asset, result_dict),
            zip(self.assets, result_dicts))
Beispiel #3
0
    def run(self):
        """
        Do all the calculation here.
        :return:
        """

        # for each FeatureExtractor_type key in feature_dict, find the subclass
        # of FeatureExtractor, run, and put results in a dict
        for fextractor_type in self.feature_dict:
            runner = self._get_fextractor_instance(fextractor_type)
            runner.run(parallelize=self.parallelize, processes=self.processes)
            results = runner.results
            self.type2results_dict[fextractor_type] = results

        # assemble an output dict with demanded atom features
        # atom_features_dict = self.fextractor_atom_features_dict
        result_dicts = list(map(lambda x: dict(), self.assets))
        for fextractor_type in self.feature_dict:
            assert fextractor_type in self.type2results_dict
            for atom_feature in self._get_atom_features(fextractor_type):
                scores_key = self._get_scores_key(fextractor_type,
                                                  atom_feature)
                for result_index, result in enumerate(
                        self.type2results_dict[fextractor_type]):
                    try:
                        result_dicts[result_index][scores_key] = result[
                            scores_key]
                    except KeyError:
                        scores_key_alt = BasicResult.scores_key_wildcard_match(
                            result.result_dict, scores_key)
                        result_dicts[result_index][scores_key] = result[
                            scores_key_alt]

        self.results = list(
            map(lambda tasset: BasicResult(tasset[0], tasset[1]),
                zip(self.assets, result_dicts)))