cleanup: remove dead code + deduplicate GPU state reads

Dead code removed:
- globals.py: GUILD_SETTINGS (empty dict, zero consumers)
- config.py: unused 'import os'
- config_manager.py: unused 'import os' and 'Union'
- server_manager.py: duplicate 'from datetime import datetime, timedelta'

GPU deduplication:
- get_current_gpu_url() now delegates to config_manager.get_gpu()
- get_gpu_status() endpoint now delegates to config_manager.get_gpu()
- Both previously re-read memory/gpu_state.json directly
This commit is contained in:
2026-04-09 20:34:17 +03:00
parent 834b2ea188
commit 5ac1f7fa8c
5 changed files with 7 additions and 25 deletions

View File

@@ -72,18 +72,10 @@ api_requests_logger = get_logger('api.requests')
# ========== GPU Selection Helper ==========
def get_current_gpu_url():
"""Get the URL for the currently selected GPU"""
gpu_state_file = os.path.join(os.path.dirname(__file__), "memory", "gpu_state.json")
try:
with open(gpu_state_file, "r") as f:
state = json.load(f)
current_gpu = state.get("current_gpu", "nvidia")
if current_gpu == "amd":
return globals.LLAMA_AMD_URL
else:
return globals.LLAMA_URL
except:
# Default to NVIDIA if state file doesn't exist
return globals.LLAMA_URL
from config_manager import config_manager
if config_manager.get_gpu() == "amd":
return globals.LLAMA_AMD_URL
return globals.LLAMA_URL
app = FastAPI()
@@ -697,13 +689,8 @@ def cleanup_bipolar_webhooks():
@app.get("/gpu-status")
def get_gpu_status():
"""Get current GPU selection"""
gpu_state_file = os.path.join(os.path.dirname(__file__), "memory", "gpu_state.json")
try:
with open(gpu_state_file, "r") as f:
state = json.load(f)
return {"gpu": state.get("current_gpu", "nvidia")}
except:
return {"gpu": "nvidia"}
from config_manager import config_manager
return {"gpu": config_manager.get_gpu()}
@app.post("/gpu-select")
async def select_gpu(request: Request):