@@ -584,9 +584,9 @@ def _calculate_total_slots(self) -> SlotsMap:
584584
585585 def _calculate_available_total_slots (self ) -> SlotsMap :
586586 reserved_resources = {
587- SlotName ("cpu" ): Decimal (self .local_config .resource_common .reserved_cpu ),
588- SlotName ("mem" ): Decimal (self .local_config .resource_common .reserved_mem ),
589- SlotName ("disk" ): Decimal (self .local_config .resource_common .reserved_disk ),
587+ SlotName ("cpu" ): Decimal (self .local_config .resource .reserved_cpu ),
588+ SlotName ("mem" ): Decimal (self .local_config .resource .reserved_mem ),
589+ SlotName ("disk" ): Decimal (self .local_config .resource .reserved_disk ),
590590 }
591591
592592 available_slots : dict [SlotName , Decimal ] = {}
@@ -671,19 +671,18 @@ def _calculate_device_slot(
671671 f"Unrecognized AbstractAllocMap type { alloc_map_type } "
672672 )
673673 case ResourceAllocationMode .MANUAL :
674+ assert resource_config .allocations is not None
674675 match slot_name :
675676 case SlotName (device_name = "cpu" ):
676- assert resource_config .allocated_cpu is not None
677- return Decimal (resource_config .allocated_cpu )
677+ return Decimal (resource_config .allocations .cpu )
678678 case SlotName (device_name = "mem" ):
679- assert resource_config .allocated_mem is not None
680- return Decimal (resource_config .allocated_mem )
679+ return Decimal (resource_config .allocations .mem )
681680 case slot_name :
682- if slot_name not in resource_config .allocated_devices :
681+ if slot_name not in resource_config .allocations . devices :
683682 raise ValueError (
684- f"{ slot_name = } not found in config { resource_config .allocated_devices !r} "
683+ f"{ slot_name = } not found in config { resource_config .allocations . devices !r} "
685684 )
686- return resource_config .allocated_devices [slot_name ]
685+ return resource_config .allocations . devices [slot_name ]
687686
688687 def _calculate_reserved_slots (self , device_slots : SlotsMap ) -> SlotsMap :
689688 reserved_slots : dict [SlotName , Decimal ] = {}
@@ -693,7 +692,7 @@ def _calculate_reserved_slots(self, device_slots: SlotsMap) -> SlotsMap:
693692 return reserved_slots
694693
695694 def _calculate_resource_scaling_factor (self , allocated_slots : SlotsMap ) -> SlotsMap :
696- match self .local_config .resource_common .allocation_mode :
695+ match self .local_config .resource .allocation_mode :
697696 case ResourceAllocationMode .SHARED :
698697 return defaultdict (lambda : Decimal (1.0 ))
699698 case ResourceAllocationMode .AUTO_SPLIT :
@@ -748,7 +747,7 @@ async def _scan_available_resources(self) -> Mapping[SlotName, Decimal]:
748747 return await dummy_scan (compute_device_types )
749748
750749 def _ensure_slots_are_not_overallocated (self ) -> None :
751- if self .local_config .resource_common .allocation_mode != ResourceAllocationMode .MANUAL :
750+ if self .local_config .resource .allocation_mode != ResourceAllocationMode .MANUAL :
752751 return
753752
754753 allocated_slots : dict [SlotName , Decimal ] = defaultdict (lambda : Decimal ("0" ))
0 commit comments