(
        self, new_target_capacity: float, group_targets: Optional[Mapping[str, float]] = None, dry_run: bool = False,
    )
Decrease the capacity in the cluster

        The number of tasks killed is limited by ``self.max_tasks_to_kill``, and the nodes are terminated in an
        order which (hopefully) reduces the impact on jobs running on the cluster.

        :param group_targets: a list of new resource group target_capacities; if None, use the existing
            target_capacities (this parameter is necessary in order for dry runs to work correctly)
        :param dry_run: if True, do not modify the state of the cluster, just log actions
Decrease the capacity in the cluster
Decrease the capacity in the cluster
def prune_excess_fulfilled_capacity(
        self, new_target_capacity: float, group_targets: Optional[Mapping[str, float]] = None, dry_run: bool = False,
    ) -> None:
        """ Decrease the capacity in the cluster

        The number of tasks killed is limited by ``self.max_tasks_to_kill``, and the nodes are terminated in an
        order which (hopefully) reduces the impact on jobs running on the cluster.

        :param group_targets: a list of new resource group target_capacities; if None, use the existing
            target_capacities (this parameter is necessary in order for dry runs to work correctly)
        :param dry_run: if True, do not modify the state of the cluster, just log actions
        """

        marked_nodes_by_group = self._choose_nodes_to_prune(new_target_capacity, group_targets)

        if not dry_run:
            if self.draining_enabled:
                assert self.draining_client  # make mypy happy
                for group_id, node_metadatas in marked_nodes_by_group.items():
                    for node_metadata in node_metadatas:
                        self.draining_client.submit_instance_for_draining(
                            node_metadata.instance,
                            sender=cast(Type[AWSResourceGroup], self.resource_groups[group_id].__class__,),
                            scheduler=self.scheduler,
                        )
            else:
                for group_id, node_metadatas in marked_nodes_by_group.items():
                    self.resource_groups[group_id].terminate_instances_by_id(
                        [node_metadata.instance.instance_id for node_metadata in node_metadatas]
                    )
def prune_excess_fulfilled_capacity ( self , new_target_capacity : float , group_targets : Optional [ Mapping [ str , float ] ] = None , dry_run : bool = False , ) -> None : marked_nodes_by_group = self . _choose_nodes_to_prune ( new_target_capacity , group_targets ) if not dry_run : if self . draining_enabled : assert self . draining_client # make mypy happy for group_id , node_metadatas in marked_nodes_by_group . items ( ) : for node_metadata in node_metadatas : self . draining_client . submit_instance_for_draining ( node_metadata . instance , sender = cast ( Type [ AWSResourceGroup ] , self . resource_groups [ group_id ] . __class__ , ) , scheduler = self . scheduler , ) else : for group_id , node_metadatas in marked_nodes_by_group . items ( ) : self . resource_groups [ group_id ] . terminate_instances_by_id ( [ node_metadata . instance . instance_id for node_metadata in node_metadatas ] )