    log_msgs = camera_replay(list(lr), fr)
  
    failed = False
    if not update:
      ref_commit = open("model_replay_ref_commit").read().strip()
      log_fn = "%s_%s_%s.bz2" % (TEST_ROUTE, "model", ref_commit)
      cmp_log = LogReader(BASE_URL + log_fn)
      results: Any = {TEST_ROUTE: {}}
      results[TEST_ROUTE]["modeld"] = compare_logs(cmp_log, log_msgs, ignore_fields=['logMonoTime', 'valid', 'model.frameDropPerc', 'model.modelExecutionTime'])
      diff1, diff2, failed = format_diff(results, ref_commit)
 
</s> remove     upload_file(log_fn, os.path.basename(log_fn))
 </s> add     try:
      upload_file(log_fn, os.path.basename(log_fn))
    except Exception as e:
      print("failed to upload", e)

    with open(ref_commit_fn, 'w') as f:
      f.write(str(new_commit)) </s> remove def camera_replay(lr, fr):
 </s> add def replace_calib(msg, calib):
  msg = msg.as_builder()
  if calib is not None:
    msg.liveCalibration.extrinsicMatrix = get_view_frame_from_road_frame(*calib, 1.22).flatten().tolist()
  return msg

def camera_replay(lr, fr, desire=None, calib=None): </s> remove       if msg.which() == "liveCalibrationd":
        pm.send(msg.which(), msg.as_builder())
 </s> add       if msg.which() == "liveCalibration":
        pm.send(msg.which(), replace_calib(msg, calib))
    ref_commit = open(ref_commit_fn).read().strip()
    log_msgs = camera_replay(list(lr), fr)
  
    failed = False
    if not update:
    ref_commit = open(ref_commit_fn).read().strip()
      log_fn = "%s_%s_%s.bz2" % (TEST_ROUTE, "model", ref_commit)
      cmp_log = LogReader(BASE_URL + log_fn)
      results: Any = {TEST_ROUTE: {}}
      results[TEST_ROUTE]["modeld"] = compare_logs(cmp_log, log_msgs, ignore_fields=['logMonoTime', 'valid', 'model.frameDropPerc', 'model.modelExecutionTime'])
      diff1, diff2, failed = format_diff(results, ref_commit)
keep keep keep keep replace keep keep keep keep keep
 Added model_replay and fixed some bugs in camera_replay (#2679)

* Added model_replay and fixed some bugs in camera_replay

* Unpack capnp logs on device

* add sync to device

* GPU now also works on PC

* update model ref

* update refs

* dont change this one

* Use pipeline calib instead of rlog calib

* remove that

* update refs

Co-authored-by: Willem Melching <willem.melching@gmail.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> 
selfdrive/test/process_replay/camera_replay.py