def _update_searcher()

in syne_tune/optimizer/schedulers/hyperband.py [0:0]


    def _update_searcher(
            self, trial_id: str, config: Dict, result: Dict, task_info: Dict):
        """
        Updates searcher with `result` (depending on `searcher_data`), and
        registers pending config with searcher.

        :param trial_id:
        :param config:
        :param result: Record obtained from `on_trial_result`
        :param task_info: Info from `self.terminator.on_task_report`
        :return: Should searcher be updated?
        """
        task_continues = task_info['task_continues']
        milestone_reached = task_info['milestone_reached']
        next_milestone = task_info.get('next_milestone')
        do_update = False
        pending_resources = []
        if self.searcher_data == 'rungs':
            if milestone_reached:
                # Update searcher with intermediate result
                do_update = True
                if task_continues and next_milestone is not None:
                    pending_resources = [next_milestone]
        elif not task_info.get('ignore_data', False):
            # All results are reported to the searcher, except if
            # task_info['ignore_data'] is True. The latter happens only for
            # tasks running promoted configs. In this case, we may receive
            # reports before the first milestone is reached, which should not
            # be passed to the searcher (they'd duplicate earlier
            # datapoints).
            # See also header comment of PromotionRungSystem.
            do_update = True
            if task_continues:
                resource = int(result[self._resource_attr])
                if self._register_pending_myopic or next_milestone is None:
                    pending_resources = [resource + 1]
                elif milestone_reached:
                    # Register pending evaluations for all resources up to
                    # `next_milestone`
                    pending_resources = list(range(resource + 1,
                                                   next_milestone + 1))
        # Update searcher
        if do_update:
            self._update_searcher_internal(trial_id, config, result)
        # Register pending evaluations
        for resource in pending_resources:
            self.searcher.register_pending(
                trial_id=trial_id, config=config,
                milestone=resource)
        return do_update