feat(llm): Tempo der Netzwerkkarte im Download-Fenster
Die Box meldet bei jedem Download-Fortschritt ihre Netzwerkkarten (echte Karten, die "up" sind) mit Tempo. Der Container sieht nur sein eigenes eth0, darum liest er das /sys des Rechners (neu: /sys:/hostsys:ro im llm-adapter). Das Download-Fenster zeigt pro Download z.B. "🔌 enp5s0 100 Mbit/s (max. ~12 MB/s — Kabel/Port prüfen)" — orange unter 1 Gbit/s. Anlass: ki-box hing an einem 100-Mbit-Port, 8 Verbindungen brachten darum nichts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1400,10 +1400,43 @@ async def _gpu_info(card: str) -> dict:
|
||||
return {"gpu": card}
|
||||
|
||||
|
||||
# Tempo der Netzwerkkarte(n) der Box — der Container sieht nur sein eigenes
|
||||
# eth0, darum liest er das /sys des Rechners (docker-compose: /sys:/hostsys:ro).
|
||||
# Nur echte Karten (mit device-Link), die "up" sind. Fehlt der Mount: [].
|
||||
HOST_SYS = os.getenv("HOST_SYS", "/hostsys")
|
||||
_link_cache: dict = {"ts": 0.0, "links": []}
|
||||
|
||||
|
||||
def _host_links() -> list:
|
||||
if time.time() - _link_cache["ts"] < 60:
|
||||
return _link_cache["links"]
|
||||
links = []
|
||||
base = os.path.join(HOST_SYS, "class", "net")
|
||||
try:
|
||||
for name in sorted(os.listdir(base)):
|
||||
d = os.path.join(base, name)
|
||||
try:
|
||||
if not os.path.exists(os.path.join(d, "device")):
|
||||
continue
|
||||
with open(os.path.join(d, "operstate")) as fh:
|
||||
if fh.read().strip() != "up":
|
||||
continue
|
||||
with open(os.path.join(d, "speed")) as fh:
|
||||
mbit = int(fh.read().strip())
|
||||
except (OSError, ValueError):
|
||||
continue
|
||||
if mbit > 0:
|
||||
links.append({"iface": name, "mbit": mbit})
|
||||
except OSError:
|
||||
pass
|
||||
_link_cache.update(ts=time.time(), links=links)
|
||||
return links
|
||||
|
||||
|
||||
async def _emit_progress(ws, key: str, phase: str, **extra) -> None:
|
||||
await _send(ws, "llm_provision_progress",
|
||||
{"instanceId": INSTANCE_ID, "node": NODE_NAME, "key": key,
|
||||
"phase": phase, "ts": int(time.time() * 1000), **extra})
|
||||
"phase": phase, "ts": int(time.time() * 1000), "links": _host_links(), **extra})
|
||||
|
||||
|
||||
async def _watch_download(ws, key: str, files: list, stop: asyncio.Event, final_phase: bool = True) -> None:
|
||||
|
||||
Reference in New Issue
Block a user