Skip to content

Commit 8dc0e74

Browse files
authored
fix(BA-2999): Fix the mock plugin handling an incorrect slot_type type (#6692)
1 parent dc2c320 commit 8dc0e74

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

changes/6692.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix Pydantic validation error from incorrect `slot_type` type in mock plugin

src/ai/backend/accelerator/mock/plugin.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,15 @@ async def init(self, context: Optional[Any] = None) -> None:
179179
for format_name, format in self.mock_config["formats"].items():
180180
self.device_formats[format_name] = _format_config_iv.check(format)
181181

182-
if self._mode == AllocationModes.DISCRETE:
183-
self.slot_types.append((f"{self.key}.device", "count")) # type: ignore # (only updated here)
184-
elif self._mode == AllocationModes.FRACTIONAL:
185-
self.slot_types.append((f"{self.key}.shares", "count")) # type: ignore # (only updated here)
186-
else:
187-
log.error("Invalid allocation mode: {}", self._mode)
188-
self.enabled = False
189-
return
182+
match self._mode:
183+
case AllocationModes.DISCRETE:
184+
self.slot_types.append((SlotName(f"{self.key}.device"), SlotTypes.COUNT))
185+
case AllocationModes.FRACTIONAL:
186+
self.slot_types.append((SlotName(f"{self.key}.shares"), SlotTypes.COUNT))
187+
case _:
188+
log.error("Invalid allocation mode: {}", self._mode)
189+
self.enabled = False
190+
return
190191

191192
if self.key == DeviceName("cuda"): # CUDA specific setups
192193
self.exclusive_slot_types = {"cuda.device:*-mig", "cuda.device", "cuda.shares"}

0 commit comments

Comments
 (0)