forked from Rockachopa/Timmy-time-dashboard
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX - Restructure desktop nav from 8+ flat links + overflow dropdown into 5 grouped dropdowns (Core, Agents, Intel, System, More) matching the mobile menu structure to reduce decision fatigue - Extract all inline styles from mission_control.html and base.html notification elements into mission-control.css with semantic classes - Replace JS-built innerHTML with secure DOM construction in notification loader and chat history - Add CONNECTING state to connection indicator (amber) instead of showing OFFLINE before WebSocket connects - Add tablet breakpoint (1024px) with larger touch targets for Apple Pencil / stylus use and safe-area padding for iPad toolbar - Add active-link highlighting in desktop dropdown menus - Rename "Mission Control" page title to "System Overview" to disambiguate from the chat home page - Add "Home — Timmy Time" page title to index.html https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h * fix(security): move auth-gate credentials to environment variables Hardcoded username, password, and HMAC secret in auth-gate.py replaced with os.environ lookups. Startup now refuses to run if any variable is unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example. https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h * refactor(tooling): migrate from black+isort+bandit to ruff Replace three separate linting/formatting tools with a single ruff invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs), .pre-commit-config.yaml, and CI workflow. Fixes all ruff errors including unused imports, missing raise-from, and undefined names. Ruff config maps existing bandit skips to equivalent S-rules. https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
708c8a2477
commit
9d78eb31d1
@@ -11,20 +11,17 @@ model roles (student, teacher, judge/PRM) run on dedicated resources.
|
||||
import logging
|
||||
import sqlite3
|
||||
import threading
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime, timezone
|
||||
from enum import Enum
|
||||
from dataclasses import dataclass
|
||||
from datetime import UTC, datetime
|
||||
from enum import StrEnum
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from config import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
DB_PATH = Path("data/swarm.db")
|
||||
|
||||
|
||||
class ModelFormat(str, Enum):
|
||||
class ModelFormat(StrEnum):
|
||||
"""Supported model weight formats."""
|
||||
|
||||
GGUF = "gguf" # Ollama-compatible quantised weights
|
||||
@@ -33,7 +30,7 @@ class ModelFormat(str, Enum):
|
||||
OLLAMA = "ollama" # Already loaded in Ollama by name
|
||||
|
||||
|
||||
class ModelRole(str, Enum):
|
||||
class ModelRole(StrEnum):
|
||||
"""Role a model can play in the system (OpenClaw-RL style)."""
|
||||
|
||||
GENERAL = "general" # Default agent inference
|
||||
@@ -60,7 +57,7 @@ class CustomModel:
|
||||
|
||||
def __post_init__(self):
|
||||
if not self.registered_at:
|
||||
self.registered_at = datetime.now(timezone.utc).isoformat()
|
||||
self.registered_at = datetime.now(UTC).isoformat()
|
||||
|
||||
|
||||
def _get_conn() -> sqlite3.Connection:
|
||||
@@ -178,11 +175,11 @@ class ModelRegistry:
|
||||
logger.info("Unregistered model: %s", name)
|
||||
return True
|
||||
|
||||
def get(self, name: str) -> Optional[CustomModel]:
|
||||
def get(self, name: str) -> CustomModel | None:
|
||||
"""Look up a model by name."""
|
||||
return self._models.get(name)
|
||||
|
||||
def list_models(self, role: Optional[ModelRole] = None) -> list[CustomModel]:
|
||||
def list_models(self, role: ModelRole | None = None) -> list[CustomModel]:
|
||||
"""List all registered models, optionally filtered by role."""
|
||||
models = list(self._models.values())
|
||||
if role is not None:
|
||||
@@ -212,7 +209,7 @@ class ModelRegistry:
|
||||
if model_name not in self._models:
|
||||
return False
|
||||
with self._lock:
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
now = datetime.now(UTC).isoformat()
|
||||
conn = _get_conn()
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -243,7 +240,7 @@ class ModelRegistry:
|
||||
del self._agent_assignments[agent_id]
|
||||
return True
|
||||
|
||||
def get_agent_model(self, agent_id: str) -> Optional[CustomModel]:
|
||||
def get_agent_model(self, agent_id: str) -> CustomModel | None:
|
||||
"""Get the model assigned to an agent, or None for default."""
|
||||
model_name = self._agent_assignments.get(agent_id)
|
||||
if model_name:
|
||||
@@ -256,13 +253,13 @@ class ModelRegistry:
|
||||
|
||||
# ── Role-based lookups ─────────────────────────────────────────────────
|
||||
|
||||
def get_reward_model(self) -> Optional[CustomModel]:
|
||||
def get_reward_model(self) -> CustomModel | None:
|
||||
"""Get the active reward/PRM model, if any."""
|
||||
reward_models = self.list_models(role=ModelRole.REWARD)
|
||||
active = [m for m in reward_models if m.active]
|
||||
return active[0] if active else None
|
||||
|
||||
def get_teacher_model(self) -> Optional[CustomModel]:
|
||||
def get_teacher_model(self) -> CustomModel | None:
|
||||
"""Get the active teacher model for distillation."""
|
||||
teacher_models = self.list_models(role=ModelRole.TEACHER)
|
||||
active = [m for m in teacher_models if m.active]
|
||||
|
||||
Reference in New Issue
Block a user