python/ray/tune/schedulers/resource_changing_scheduler.py
def reallocate_trial_resources_if_needed(
        self, trial_runner: "trial_runner.TrialRunner", trial: Trial, result: Dict
    ) -> Optional[Union[dict, PlacementGroupFactory]]:
        """Calls user defined resources_allocation_function. If the returned
        resources are not none and not the same as currently present, returns
        them. Otherwise, returns None."""
        if self._resources_allocation_function is None:
            return None

        if not getattr(self._resources_allocation_function, "metric", None):
            self._resources_allocation_function.metric = getattr(
                self._base_scheduler, "_metric", self._metric
            )
        if not getattr(self._resources_allocation_function, "mode", None):
            self._resources_allocation_function.mode = getattr(
                self._base_scheduler, "_mode", self._mode
            )

        new_resources = self._resources_allocation_function(
            trial_runner, trial, result, self
        )

        # if we can check if the new resources are the same,
        # we do that here and skip resource allocation
        if new_resources and not self._are_resources_the_same(trial, new_resources):
            return new_resources
        return None
Calls user defined resources_allocation_function. If the returned
        resources are not none and not the same as currently present, returns
        them. Otherwise, returns None.
Calls user defined resources_allocation_function. If the returned
resources are not none and not the same as currently present, returns
them. Otherwise, returns None.
Calls user defined resources_allocation_function . If the returned resources are not none and not the same as currently present returns them . Otherwise returns None .
def reallocate_trial_resources_if_needed(
        self, trial_runner: "trial_runner.TrialRunner", trial: Trial, result: Dict
    ) -> Optional[Union[dict, PlacementGroupFactory]]:
        if self._resources_allocation_function is None:
            return None
        if not getattr(self._resources_allocation_function, "metric", None):
            self._resources_allocation_function.metric = getattr(
                self._base_scheduler, "_metric", self._metric
            )
        if not getattr(self._resources_allocation_function, "mode", None):
            self._resources_allocation_function.mode = getattr(
                self._base_scheduler, "_mode", self._mode
            )
        new_resources = self._resources_allocation_function(
            trial_runner, trial, result, self
        )
        if new_resources and not self._are_resources_the_same(trial, new_resources):
            return new_resources
        return None
def reallocate_trial_resources_if_needed ( self , trial_runner : "trial_runner.TrialRunner" , trial : Trial , result : Dict ) -> Optional [ Union [ dict , PlacementGroupFactory ] ] : if self . _resources_allocation_function is None : return None if not getattr ( self . _resources_allocation_function , "metric" , None ) : self . _resources_allocation_function . metric = getattr ( self . _base_scheduler , "_metric" , self . _metric ) if not getattr ( self . _resources_allocation_function , "mode" , None ) : self . _resources_allocation_function . mode = getattr ( self . _base_scheduler , "_mode" , self . _mode ) new_resources = self . _resources_allocation_function ( trial_runner , trial , result , self ) if new_resources and not self . _are_resources_the_same ( trial , new_resources ) : return new_resources return None
Calls user defined resources_allocation_function.
Calls user defined resources_allocation_function .
"""Calls user defined resources_allocation_function. If the returned
        resources are not none and not the same as currently present, returns
        them. Otherwise, returns None.""" # if we can check if the new resources are the same, # we do that here and skip resource allocation
self
trial_runner
"trial_runner.TrialRunner"
trial
Trial
result
Dict