@@ -319,7 +319,9 @@ def format(cls, data: ClusterStatus, verbose: bool = False) -> str:
319319 pending_report = cls ._pending_node_report (data )
320320 failure_report = cls ._failed_node_report (data , verbose )
321321 cluster_usage_report = cls ._cluster_usage_report (data , verbose )
322- constraints_report = cls ._constraint_report (data )
322+ constraints_report = cls ._constraint_report (
323+ data .resource_demands .cluster_constraint_demand
324+ )
323325 demand_report = cls ._demand_report (data )
324326 node_usage_report = (
325327 ""
@@ -543,7 +545,9 @@ def _pending_node_report(data: ClusterStatus) -> str:
543545 return " (no pending nodes)"
544546
545547 @staticmethod
546- def _constraint_report (data : ClusterStatus ) -> str :
548+ def _constraint_report (
549+ cluster_constraint_demand : List [ClusterConstraintDemand ],
550+ ) -> str :
547551 """Returns a formatted string describing the resource constraints from request_resources().
548552
549553 Args:
@@ -552,11 +556,21 @@ def _constraint_report(data: ClusterStatus) -> str:
552556 Returns:
553557 String containing the formatted constraints report, either listing each constraint
554558 and count or indicating no constraints exist.
559+
560+ Example:
561+ >>> cluster_constraint_demand = [
562+ ... ClusterConstraintDemand(bundles_by_count=[
563+ ... ResourceRequestByCount(bundle={"CPU": 4}, count=2),
564+ ... ResourceRequestByCount(bundle={"GPU": 1}, count=1)
565+ ... ])
566+ ... ]
567+ >>> ClusterStatusFormatter._constraint_report(cluster_constraint_demand)
568+ " {'CPU': 4}: 2 from request_resources()\\ n {'GPU': 1}: 1 from request_resources()"
555569 """
556570 constraint_lines = []
557571 request_demand = [
558572 (bc .bundle , bc .count )
559- for constraint_demand in data . resource_demands . cluster_constraint_demand
573+ for constraint_demand in cluster_constraint_demand
560574 for bc in constraint_demand .bundles_by_count
561575 ]
562576 for bundle , count in request_demand :
0 commit comments