ruvnet--ruview
9740bc64c9
Bench Regression Guard / bench compile-verify (--no-run) (push) Failing after 0s
Continuous Deployment / Pre-deployment Checks (push) Has been skipped
Bench Regression Guard / bench fast-run (informational, non-gating) (push) Has been skipped
Firmware CI / Verify version.txt matches release tag (push) Has been skipped
Dashboard a11y + cross-browser / a11y (push) Failing after 0s
nvsim Dashboard → GitHub Pages / build-and-deploy (push) Failing after 2s
Firmware CI / Build firmware (esp32s3 / 4mb) (push) Failing after 15s
Firmware CI / Build firmware (esp32c6 / c6-4mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / Build Espressif QEMU (push) Failing after 1s
Firmware QEMU Tests (ADR-061) / Fuzz Testing (ADR-061 Layer 6) (push) Failing after 1s
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-max) (push) Has been skipped
Firmware CI / Build firmware (esp32s3 / 8mb) (push) Failing after 15s
Firmware QEMU Tests (ADR-061) / QEMU Test (boundary-min) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (default) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier0) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (edge-tier1) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (full-adr060) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / QEMU Test (tdm-3node) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / Swarm Test (ADR-062) (push) Has been skipped
Firmware QEMU Tests (ADR-061) / NVS Matrix Generation (push) Failing after 1s
Fix-Marker Regression Guard / Verify fix markers (push) Failing after 1s
ADR-115 MQTT integration tests / mqtt-integration (push) Failing after 1s
npm packages / harness/ruview (node 20) (push) Failing after 1s
npm packages / tools/ruview-mcp (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 20) (push) Failing after 1s
npm packages / tools/ruview-cli (node 22) (push) Failing after 1s
npm packages / tools/ruview-mcp (node 22) (push) Failing after 1s
nvsim-server → ghcr.io / build-and-publish (push) Failing after 1s
ruview-swarm CI guard / tests (full+train) (push) Failing after 2s
ruview-swarm CI guard / tests (ruflo) (push) Failing after 1s
ruview-swarm CI guard / tests (train) (push) Failing after 2s
BFLD MQTT Integration / cargo test --features mqtt (live mosquitto) (push) Failing after 29s
ruview-swarm CI guard / tests (default) (push) Failing after 2s
Point Cloud Viewer → GitHub Pages / build-and-deploy (push) Failing after 8s
ruview-swarm CI guard / ITAR / publish guard (push) Failing after 0s
ruview-swarm CI guard / build train_marl bin (push) Failing after 2s
ruview-swarm CI guard / clippy (-D warnings, --no-deps) (push) Failing after 3s
Security Scanning / Dependency Vulnerability Scan (push) Failing after 0s
Security Scanning / Static Application Security Testing (push) Failing after 1s
Security Scanning / Infrastructure Security Scan (push) Failing after 1s
Security Scanning / Secret Scanning (push) Failing after 1s
npm packages / harness/ruview (node 22) (push) Failing after 17s
Security Scanning / License Compliance Scan (push) Failing after 1s
Security Scanning / Container Security Scan (push) Failing after 4s
Security Scanning / Security Policy Compliance (push) Failing after 0s
wifi-densepose sensing-server → Docker Hub + ghcr.io / build · push · smoke-test (push) Failing after 1s
three.js demos → GitHub Pages / build-and-deploy (push) Failing after 1s
Verify Pipeline Determinism / Verify Pipeline Determinism (3.11) (push) Failing after 1s
Continuous Deployment / Deploy to Production (push) Has been cancelled
Continuous Deployment / Rollback Deployment (push) Has been cancelled
Continuous Deployment / Post-deployment Monitoring (push) Has been cancelled
Continuous Deployment / Notify Deployment Status (push) Has been cancelled
Continuous Deployment / Deploy to Staging (push) Has been cancelled
Security Scanning / Security Report (push) Has been cancelled
104 行
3.8 KiB
Python
104 行
3.8 KiB
Python
"""Self-contained regression test for the RuView calibration service.
|
|
|
|
Exercises the committed CLI end-to-end on synthetic data (CPU, no GPU, no real checkpoint):
|
|
build a base -> calibrate.py fits an adapter -> infer.py runs base+adapter -> assert the
|
|
adapter is small, inference is shape-correct and finite, and the adapter actually changes output.
|
|
|
|
Run: python test_calibration.py (or via pytest)
|
|
"""
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import numpy as np
|
|
import torch
|
|
|
|
HERE = Path(__file__).parent
|
|
sys.path.insert(0, str(HERE))
|
|
from model import PoseNet, standardize # noqa: E402
|
|
|
|
|
|
def _make_base(path: Path):
|
|
torch.manual_seed(0)
|
|
net = PoseNet()
|
|
# Save without the deterministic gr.A buffer (mirrors the published checkpoint;
|
|
# calibrate.py/infer.py load with strict=False).
|
|
sd = {k: v for k, v in net.state_dict().items() if k != "gr.A"}
|
|
torch.save(sd, path)
|
|
|
|
|
|
def _make_data(path: Path, n: int, seed: int):
|
|
rng = np.random.default_rng(seed)
|
|
X = rng.standard_normal((n, 3, 114, 10)).astype(np.float32)
|
|
Y = rng.random((n, 17, 2)).astype(np.float32) # keypoints in [0,1]
|
|
np.savez(path, X=X, Y=Y)
|
|
|
|
|
|
def _run(*args):
|
|
r = subprocess.run(
|
|
[sys.executable, str(HERE / args[0]), *map(str, args[1:])],
|
|
capture_output=True, text=True,
|
|
)
|
|
assert r.returncode == 0, f"{args[0]} failed:\n{r.stdout}\n{r.stderr}"
|
|
return r.stdout
|
|
|
|
|
|
def test_calibration_end_to_end():
|
|
with tempfile.TemporaryDirectory() as d:
|
|
d = Path(d)
|
|
base = d / "base.pt"
|
|
calib = d / "calib.npz"
|
|
frames = d / "frames.npz"
|
|
adapter = d / "room.adapter.npz"
|
|
kp = d / "kp.npy"
|
|
|
|
_make_base(base)
|
|
_make_data(calib, n=40, seed=1) # ≥20 → no underfit warning
|
|
_make_data(frames, n=16, seed=2)
|
|
|
|
# 1) calibrate -> adapter
|
|
out = _run("calibrate.py", "--base", base, "--data", calib, "--out", adapter,
|
|
"--iters", "50", "--device", "cpu")
|
|
assert adapter.exists(), "adapter not written"
|
|
assert "saved" in out.lower()
|
|
sz = adapter.stat().st_size
|
|
assert sz < 200_000, f"adapter unexpectedly large ({sz} bytes)"
|
|
|
|
# adapter contains the expected LoRA tensors (materialize + close so the
|
|
# Windows tempdir can be cleaned up — np.load keeps a lazy file handle).
|
|
with np.load(adapter) as z:
|
|
keys = [k for k in z.files if k.endswith(".A") or k.endswith(".B")]
|
|
assert keys, f"adapter has no LoRA tensors: {z.files}"
|
|
lora = {k: z[k].astype(np.float32) for k in keys}
|
|
|
|
# 2) infer with adapter -> keypoints
|
|
_run("infer.py", "--base", base, "--adapter", adapter, "--data", frames,
|
|
"--out", kp, "--device", "cpu")
|
|
out_kp = np.load(kp)
|
|
assert out_kp.shape == (16, 17, 2), f"bad keypoint shape {out_kp.shape}"
|
|
assert np.isfinite(out_kp).all(), "non-finite keypoints"
|
|
assert (out_kp >= 0).all() and (out_kp <= 1).all(), "keypoints out of [0,1]"
|
|
|
|
# 3) adapter must actually change the output vs the zero-shot base
|
|
with np.load(frames) as fz:
|
|
frames_x = fz["X"][:]
|
|
net = PoseNet()
|
|
net.load_state_dict(torch.load(base, map_location="cpu"), strict=False)
|
|
net.eval()
|
|
x = standardize(torch.tensor(frames_x))
|
|
with torch.no_grad():
|
|
base_kp = net(x).reshape(16, 17, 2).numpy()
|
|
net.add_lora()
|
|
net.load_lora(lora)
|
|
net.eval()
|
|
with torch.no_grad():
|
|
cal_kp = net(x).reshape(16, 17, 2).numpy()
|
|
assert np.abs(base_kp - cal_kp).sum() > 1e-4, "adapter did not change output"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_calibration_end_to_end()
|
|
print("PASS: calibration service end-to-end (calibrate -> adapter -> infer)")
|