SPB Git

spb/wp33_uqo

Public MIT
4.6 KB · 56 lines python
1#!/usr/bin/env python32"""Build the sanitized artifacts/environment.json from the raw probes kept in artifacts/private/ (not committed).3Only hardware facts that were read live are included; no IP addresses, serial numbers or credentials."""4import glob, json, os, re, subprocess, sys, time, platform5ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))6PRIV = os.path.join(ROOT, "artifacts", "private")78def parse_kv(line):9    return dict(kv.split("=", 1) for kv in line.strip().split("|") if "=" in kv)1011nodes = {}12for f in sorted(glob.glob(os.path.join(PRIV, "*.txt"))):13    name = os.path.basename(f).replace(".retry", "").replace(".txt", "")14    if name.startswith(("inventory", "linkprobe", "netprobe")):15        continue16    line = open(f).read().strip().split("\n")[-1]17    if "chip=" not in line:18        nodes.setdefault(name, {"status": "unreachable (SSH timeout 2026-11-01)"}); continue19    kv = parse_kv(line)20    nodes[name] = {"status": "reachable", "chip": kv.get("chip"), "ram_gb": int(kv["ram"]), "macos": kv.get("os"),21                   "gpu_cores": int(kv["gpu"]) if kv.get("gpu", "").isdigit() else None, "disk_free_gb": int(kv["disk_free"].rstrip("G")) if kv.get("disk_free", "").rstrip("G").isdigit() else None,22                   "system_python": kv.get("py"), "mlx_preinstalled": kv.get("mlx") not in (None, "none"), "load_avg_at_probe": kv.get("load")}23lp = os.path.join(PRIV, "linkprobe-2026-11-01.txt")24if os.path.exists(lp):25    for line in open(lp):26        kv = parse_kv(line); n = line.split("|")[0]27        if n in nodes and nodes[n].get("status") == "reachable":28            nodes[n].update({"en0_media": kv.get("media"), "homebrew_pythons": [p for p in kv.get("brewpy", "").split(",") if p], "uv": bool(kv.get("uv")),29                             "xcode": kv.get("xcode"), "metal_compiler": kv.get("metal") or None, "rdma_ctl_present": bool(kv.get("rdma")), "iperf3": kv.get("iperf3") not in (None, "no", "")})30net = {}31for fn in ("netprobe-2026-11-01.txt", "netprobe2-2026-11-01.txt"):32    p = os.path.join(PRIV, fn)33    if not os.path.exists(p): continue34    for line in open(p):35        m = re.match(r"rtt (\S+)->(\S+) ([\d.]+)/([\d.]+)/([\d.]+)/([\d.]+) ms", line.strip())36        if m:37            net.setdefault("rtt_ms", []).append({"from": m.group(1), "to": "lan-host-" + m.group(2).split(".")[-1] if m.group(2)[0].isdigit() else m.group(2), "min": float(m.group(3)), "avg": float(m.group(4)), "max": float(m.group(5))})38        m = re.match(r"iperf3 (\S+)->(\S+) \(.*\): ([\d.]+) Gbit/s sent ([\d.]+) Gbit/s recv", line.strip())39        if m:40            net.setdefault("iperf3_gbits", []).append({"from": m.group(1), "to": m.group(2), "sent": float(m.group(3)), "recv": float(m.group(4))})41        if line.startswith("tb-ifaces"):42            n = line.split(":")[0].split()[1]43            net.setdefault("thunderbolt_active_links", {})[n] = ("status: active" in line and "en0" not in line.split("status: active")[0][-60:]) and False44laptop = {"role": "development laptop (not on the cluster LAN)", "chip": subprocess.run(["sysctl", "-n", "machdep.cpu.brand_string"], capture_output=True, text=True).stdout.strip(),45          "ram_gb": int(subprocess.run(["sysctl", "-n", "hw.memsize"], capture_output=True, text=True).stdout) // 2**30, "macos": platform.mac_ver()[0],46          "gpu_cores": 40, "cpu_cores": 18, "ssd_random_3p4MB_GBps_cold": 8.50, "ssd_seq_GBps_cold": 11.5, "ssd_source": "benchmarks/raw/gateA/ssd/laptop-M5Max.json"}47env = {"generated": time.strftime("%Y-%m-%dT%H:%M:%S"), "note": "Live inventory of 2026-11-01; aliases are cluster names, no addresses or serials. Unreachable aliases are listed but unused.",48       "laptop": laptop, "cluster_nodes": nodes, "network": {"lan": "1 GbE switch (all nodes negotiate 1000baseT on en0)", "thunderbolt": "no active Thunderbolt link between any two nodes at probe time (RDMA/JACCL blocked pending cabling)", **net},49       "software": {"mlx_venv": "0.32.4", "mlx_lm_venv": "0.32.2", "python_venv": "3.12", "third_party_commits": {"colibri": "0a5504a1dc64f86fcd0fe7db298b0448c730e7e6", "mlx": "bd63d3803008edda03ce74080955d9879e2ef1eb", "mlx-lm": "736ab0d8c1d0edc79c3d798044fe6904e2fa23be", "llama.cpp": "a91eab67d8389d979d29fdf6633b2edd0718eb4b"}}}50out = os.path.join(ROOT, "artifacts", "environment.json")51json.dump(env, open(out, "w"), indent=2)52reach = [n for n, v in nodes.items() if v.get("status") == "reachable"]53print(f"wrote {out}: {len(reach)} reachable nodes, {len(nodes) - len(reach)} unreachable")54for n in sorted(reach, key=lambda x: -nodes[x]["ram_gb"]):55    v = nodes[n]; print(f"  {n:8s} {v['chip']:16s} {v['ram_gb']:3d} GB  GPU {v['gpu_cores']}  macOS {v['macos']}  free {v['disk_free_gb']} GB  {v.get('en0_media','')}")56
Files · 2d987b30cb427aa933cb485dd908495f7ea82b47
Menu

Theme