"""DaisyChain dashboard (CLI: `daisychain-dashboard`). Tailwind-styled page with a readiness banner, P2P connectivity scan, pooled resource + capacity plan, and live training status. Config via DAISY_NODES_FILE. Serves on :8080.""" import json from html import escape as _html_escape import os from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer try: from daisychain.dashboard.scanner import scan_cluster except Exception: from scanner import scan_cluster # running from the folder directly NODES_FILE = os.environ.get("DAISY_NODES_FILE", "config/nodes.example.json") PORT = int(os.environ.get("DAISY_DASH_PORT", "8080")) EXPECTED_WORLD = os.environ.get("DAISY_EXPECTED_WORLD") BASE_BATCH = int(os.environ.get("DAISY_BASE_BATCH", "32")) def load_nodes(): with open(NODES_FILE) as f: return json.load(f) def _chip(ok, yes="OK", no="DOWN"): cls = ("bg-emerald-500/20 text-emerald-600 dark:text-emerald-400" if ok else "bg-rose-500/20 text-rose-600 dark:text-rose-400") return f'{yes if ok else no}' #: Remote-supplied strings are escaped before they reach the page. #: #: `device` and the GPU `name` come from each node's /resources JSON -- i.e. from #: the OTHER machine, not from local config -- and were interpolated raw into the #: dashboard HTML. A node serving `{"gpu": {"name": ""}}` #: would run script in the operator's browser on the next 3-second refresh. #: The node list itself is local config and trusted, but escaping it too costs #: nothing and keeps the rule simple: nothing reaches the page unescaped. def _e(v) -> str: return _html_escape("" if v is None else str(v)) def render(d): ready = d["ready"] banner = ("bg-emerald-500", "✓ CLUSTER READY — all nodes connected") if ready \ else ("bg-rose-500", f"✗ NOT READY — {d['reachable']}/{d['total']} nodes reachable") rows = "" for n in d["nodes"]: lat = f'{n["latency_ms"]} ms' if n["latency_ms"] is not None else "—" res = n.get("resources") or {} dev = res.get("device", "—") gpu = (res.get("gpu") or {}).get("name", "") devlabel = _e(dev) + (f" ({_e(gpu)})" if gpu else "") rows += f"""
{loss:.5f} cluster-avg loss
""" else: train = 'No active run detected (waiting for rank 0 status)…
' return f"""Old Hardware Training Pipeline · scanned {d['scanned_at']}
Nodes
{d['reachable']}/{d['total']}
Total cores
{plan['total_cores']}
Total RAM
{tot_ram}
| Node | Host | Agent | Device | Latency |
|---|
| Node | Device | RAM | Capacity | Weight | Batch |
|---|