ui replay: Add progress bar (#37471)

* add replay progress bar

* simplify

* use frames instead

* update

* disable in CI

* +1
This commit is contained in:
David
2026-03-10 18:42:56 -05:00
committed by GitHub
parent d55ccba5fe
commit 0ce679f687
+26 -23
View File
@@ -4,6 +4,7 @@ import argparse
import coverage
import pyray as rl
from tqdm import tqdm
from typing import Literal
from collections.abc import Callable
from cereal.messaging import PubMaster
@@ -75,33 +76,35 @@ def run_replay(variant: LayoutVariant) -> None:
rl.get_time = lambda: frame / FPS
# Main loop to replay events and render frames
for _ in gui_app.render():
# Handle all events for the current frame
while script_index < len(script) and script[script_index][0] == frame:
_, event = script[script_index]
# Call setup function, if any
if event.setup:
event.setup()
# Send mouse events to the application
if event.mouse_events:
with gui_app._mouse._lock:
gui_app._mouse._events.extend(event.mouse_events)
# Update persistent send function
if event.send_fn is not None:
send_fn = event.send_fn
# Move to next script event
script_index += 1
with tqdm(total=script[-1][0] + 1, desc="Replaying", unit="frame", disable=bool(os.getenv("CI"))) as pbar:
for _ in gui_app.render():
# Handle all events for the current frame
while script_index < len(script) and script[script_index][0] == frame:
_, event = script[script_index]
# Call setup function, if any
if event.setup:
event.setup()
# Send mouse events to the application
if event.mouse_events:
with gui_app._mouse._lock:
gui_app._mouse._events.extend(event.mouse_events)
# Update persistent send function
if event.send_fn is not None:
send_fn = event.send_fn
# Move to next script event
script_index += 1
# Keep sending cereal messages for persistent states (onroad, alerts)
if send_fn:
send_fn()
# Keep sending cereal messages for persistent states (onroad, alerts)
if send_fn:
send_fn()
ui_state.update()
ui_state.update()
frame += 1
frame += 1
pbar.update(1)
if script_index >= len(script):
break
if script_index >= len(script):
break
gui_app.close()