(self, killable_nodes: List[ClusterNodeMetadata])
return sorted(killable_nodes, key=sort_key,)
Returns killable_nodes sorted with most-killable things first.
Returns killable_nodes sorted with most-killable things first.
Returns killable_nodes sorted with most - killable things first .
def _prioritize_killable_nodes(self, killable_nodes: List[ClusterNodeMetadata]) -> List[ClusterNodeMetadata]:
        """Returns killable_nodes sorted with most-killable things first."""

        def sort_key(node_metadata: ClusterNodeMetadata,) -> Tuple[int, int, int, int, int]:
            return (
                0 if node_metadata.agent.state == AgentState.ORPHANED else 1,
                0 if node_metadata.agent.state == AgentState.IDLE else 1,
                0 if node_metadata.instance.is_stale else 1,
                node_metadata.agent.batch_task_count,
                node_metadata.agent.task_count,
            )

        return sorted(killable_nodes, key=sort_key,)
def _prioritize_killable_nodes ( self , killable_nodes : List [ ClusterNodeMetadata ] ) -> List [ ClusterNodeMetadata ] : def sort_key ( node_metadata : ClusterNodeMetadata , ) -> Tuple [ int , int , int , int , int ] : return ( 0 if node_metadata . agent . state == AgentState . ORPHANED else 1 , 0 if node_metadata . agent . state == AgentState . IDLE else 1 , 0 if node_metadata . instance . is_stale else 1 , node_metadata . agent . batch_task_count , node_metadata . agent . task_count , ) return sorted ( killable_nodes , key = sort_key , )