fix(pybot×actpred): v3 审计 P2 清零——验收链 fixed_range + 导出断言 + overrun 节流

- v3-P2-1: _npu_test/_onnx_validate 按 normalize_mode 分支(fixed_range 免 stats,
  HailoPredictor 透传模式,torch 参考同口径反归一化)
- v3-P2-2: export_deploy/export_onnx 一致性 diff 超 1e-4 即 sys.exit(P2-f 闭环)
- v3-P2-3: run_loop overrun 告警节流(第1次+每100次),降 hz 建议仅 >10% 输出
- P2-a1: default_column_weights 扩展列(action_dim>18)默认 1.0
- P2-c: 补 predictor 异常清理路径测试(异常传播 + finally 落盘)
- P2-d/P2-e: Resize 口径与 resume scheduler T_max 语义文档化
- R2-4: _set.sh 安装后断言 CPU 版 torch,误装 CUDA 即拦截
测试: pybot 89 passed (+1)、actpred 148 passed/18 skipped
This commit is contained in:
qing committed 2026-08-14 23:01:56 +08:00
1 parent ad3a624b4c
commit 9179281420
13 files changed
+161 -54

No files matched your search

+24
View File
@@ -489,3 +489,27 @@ def test_robot_importable_without_numpy():
r = subprocess.run([sys.executable, "-c", child],
capture_output=True, text=True, cwd=repo)
assert r.returncode == 0 and "ok" in r.stdout, r.stderr
def test_predictor_exception_still_flushes_recorder(mock_i2c, tmp_path):
"""P2-c:predictor 中途抛异常时 run_loop 的 finally 仍落盘,
已录制 steps 不丢失且异常照常向上传播(由 with robot 清理硬件)"""
from pybot.recorder import EpisodeRecorder
class RaisingPredictor(MockPredictor):
def predict(self, images, action_history):
if self._step >= 1:
raise RuntimeError("backend boom")
return super().predict(images, action_history)
robot = _make_robot(LOOP_MT, mock_i2c)
robot.active()
pred = RaisingPredictor(frame_len=3, history_len=2, action_dim=4)
rec = EpisodeRecorder(str(tmp_path), action_dim=4)
with pytest.raises(RuntimeError, match="backend boom"):
robot.run_loop(pred, hz=1000.0, max_steps=5, recorder=rec)
robot.deactive()
# 第 1 步已录制(第 2 步 predict 抛异常),finally flush 已落盘
acts = np.load(tmp_path / "episode_0000" / "actions.npy")
assert acts.shape[0] == 1