python/ray/serve/deployment_state.py
def pop(
        self,
        exclude_version: Optional[DeploymentVersion] = None,
        states: Optional[List[ReplicaState]] = None,
        max_replicas: Optional[int] = math.inf,
        ranking_function: Optional[
            Callable[[List["DeploymentReplica"]], List["DeploymentReplica"]]
        ] = None,
    ) -> List[VersionedReplica]:
        """Get and remove all replicas of the given states.

        This removes the replicas from the container. Replicas are returned
        in order of state as passed in.

        Args:
            exclude_version (DeploymentVersion): if specified, replicas of the
                provided version will *not* be removed.
            states (str): states to consider. If not specified, all replicas
                are considered.
            max_replicas (int): max number of replicas to return. If not
                specified, will pop all replicas matching the criteria.
            ranking_function (callable): optional function to sort the replicas
                within each state before they are truncated to max_replicas and
                returned.
        """
        if states is None:
            states = ALL_REPLICA_STATES

        assert exclude_version is None or isinstance(exclude_version, DeploymentVersion)
        assert isinstance(states, list)

        replicas = []
        for state in states:
            popped = []
            remaining = []

            replicas_to_process = self._replicas[state]
            if ranking_function:
                replicas_to_process = ranking_function(replicas_to_process)

            for replica in replicas_to_process:
                if len(replicas) + len(popped) == max_replicas:
                    remaining.append(replica)
                elif exclude_version is not None and replica.version == exclude_version:
                    remaining.append(replica)
                else:
                    popped.append(replica)
            self._replicas[state] = remaining
            replicas.extend(popped)

        return replicas
Get and remove all replicas of the given states.

        This removes the replicas from the container. Replicas are returned
        in order of state as passed in.

        Args:
            exclude_version (DeploymentVersion): if specified, replicas of the
                provided version will *not* be removed.
            states (str): states to consider. If not specified, all replicas
                are considered.
            max_replicas (int): max number of replicas to return. If not
                specified, will pop all replicas matching the criteria.
            ranking_function (callable): optional function to sort the replicas
                within each state before they are truncated to max_replicas and
                returned.
        
Get and remove all replicas of the given states.
This removes the replicas from the container. Replicas are returned
in order of state as passed in.
Get and remove all replicas of the given states . This removes the replicas from the container . Replicas are returned in order of state as passed in .
def pop(
        self,
        exclude_version: Optional[DeploymentVersion] = None,
        states: Optional[List[ReplicaState]] = None,
        max_replicas: Optional[int] = math.inf,
        ranking_function: Optional[
            Callable[[List["DeploymentReplica"]], List["DeploymentReplica"]]
        ] = None,
    ) -> List[VersionedReplica]:
        if states is None:
            states = ALL_REPLICA_STATES
        assert exclude_version is None or isinstance(exclude_version, DeploymentVersion)
        assert isinstance(states, list)
        replicas = []
        for state in states:
            popped = []
            remaining = []
            replicas_to_process = self._replicas[state]
            if ranking_function:
                replicas_to_process = ranking_function(replicas_to_process)
            for replica in replicas_to_process:
                if len(replicas) + len(popped) == max_replicas:
                    remaining.append(replica)
                elif exclude_version is not None and replica.version == exclude_version:
                    remaining.append(replica)
                else:
                    popped.append(replica)
            self._replicas[state] = remaining
            replicas.extend(popped)
        return replicas
def pop ( self , exclude_version : Optional [ DeploymentVersion ] = None , states : Optional [ List [ ReplicaState ] ] = None , max_replicas : Optional [ int ] = math . inf , ranking_function : Optional [ Callable [ [ List [ "DeploymentReplica" ] ] , List [ "DeploymentReplica" ] ] ] = None , ) -> List [ VersionedReplica ] : if states is None : states = ALL_REPLICA_STATES assert exclude_version is None or isinstance ( exclude_version , DeploymentVersion ) assert isinstance ( states , list ) replicas = [ ] for state in states : popped = [ ] remaining = [ ] replicas_to_process = self . _replicas [ state ] if ranking_function : replicas_to_process = ranking_function ( replicas_to_process ) for replica in replicas_to_process : if len ( replicas ) + len ( popped ) == max_replicas : remaining . append ( replica ) elif exclude_version is not None and replica . version == exclude_version : remaining . append ( replica ) else : popped . append ( replica ) self . _replicas [ state ] = remaining replicas . extend ( popped ) return replicas
Get and remove all replicas of the given states.
Get and remove all replicas of the given states .
"""Get and remove all replicas of the given states.

        This removes the replicas from the container. Replicas are returned
        in order of state as passed in.

        Args:
            exclude_version (DeploymentVersion): if specified, replicas of the
                provided version will *not* be removed.
            states (str): states to consider. If not specified, all replicas
                are considered.
            max_replicas (int): max number of replicas to return. If not
                specified, will pop all replicas matching the criteria.
            ranking_function (callable): optional function to sort the replicas
                within each state before they are truncated to max_replicas and
                returned.
        """
self
exclude_version
Optional[DeploymentVersion]
if specified, replicas of the
provided version will *not* be removed.
if specified replicas of the provided version will * not * be removed .
states
Optional[List[ReplicaState]]
states to consider. If not specified, all replicas
are considered.
states to consider . If not specified all replicas are considered .
max_replicas
Optional[int]
max number of replicas to return. If not
specified, will pop all replicas matching the criteria.
max number of replicas to return . If not specified will pop all replicas matching the criteria .
ranking_function
Optional[
            Callable[[List["DeploymentReplica"]], List["DeploymentReplica"]]
        ]
optional function to sort the replicas
within each state before they are truncated to max_replicas and
returned.
optional function to sort the replicas within each state before they are truncated to max_replicas and returned .