mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
fix(hwfit): tolerate non-numeric gpu_count in /api/hwfit/models (#3639)
* fix(hwfit): tolerate non-numeric gpu_count in /api/hwfit/models The route did `n = int(gpu_count)` with no guard, so a non-numeric query param like `?gpu_count=abc` raised ValueError and returned HTTP 500. Parse it defensively (mirroring the gpu_group guard a few lines above): a malformed value is ignored, exactly like omitting the param, and valid values still apply. Adds tests/test_hwfit_gpu_count_nonnumeric.py: a non-numeric gpu_count returns a ranking instead of raising, and a numeric value is still accepted. * test(hwfit): cover non-numeric manual_gpu_count too Follow-up to the gpu_count guard: add a regression test for the sibling manual_gpu_count query param (the hardware simulator in _apply_manual_hardware), which dev already guards by defaulting to 1 on a non-numeric value. This pins that behaviour so the endpoint's count parsing is fully covered and cannot regress to a 500.
This commit is contained in:
committed by
GitHub
parent
d1a5a7d680
commit
9c00da6d1c
@@ -177,8 +177,14 @@ def setup_hwfit_routes():
|
||||
system["gpu_name"] = g["name"]
|
||||
system["active_group"] = {**g, "use_count": n}
|
||||
|
||||
if gpu_count != "":
|
||||
n = int(gpu_count)
|
||||
# Parse the optional count defensively (matches the gpu_group guard
|
||||
# above): a non-numeric query param previously raised ValueError ->
|
||||
# HTTP 500. A malformed value is ignored, same as omitting it.
|
||||
try:
|
||||
n = int(gpu_count) if gpu_count != "" else None
|
||||
except ValueError:
|
||||
n = None
|
||||
if n is not None:
|
||||
if n == 0:
|
||||
# RAM-only mode: rank against system memory, offload allowed.
|
||||
system["has_gpu"] = False
|
||||
|
||||
Reference in New Issue
Block a user