mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-23 15:02:06 +08:00
process_replay: progress bar support (#28447)
* Add support for tqdm progress bar * Fix argument name
This commit is contained in:
@@ -6,6 +6,7 @@ import platform
|
||||
from collections import OrderedDict
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional, Callable
|
||||
from tqdm import tqdm
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from cereal import car
|
||||
@@ -340,9 +341,9 @@ def replay_process_with_name(name, lr, *args, **kwargs):
|
||||
return replay_process(cfg, lr, *args, **kwargs)
|
||||
|
||||
|
||||
def replay_process(cfg, lr, fingerprint=None, return_all_logs=False):
|
||||
def replay_process(cfg, lr, fingerprint=None, return_all_logs=False, disable_progress=False):
|
||||
all_msgs = list(lr)
|
||||
process_logs = _replay_single_process(cfg, all_msgs, fingerprint)
|
||||
process_logs = _replay_single_process(cfg, all_msgs, fingerprint, disable_progress)
|
||||
|
||||
if return_all_logs:
|
||||
keys = set(cfg.subs)
|
||||
@@ -356,7 +357,7 @@ def replay_process(cfg, lr, fingerprint=None, return_all_logs=False):
|
||||
return log_msgs
|
||||
|
||||
|
||||
def _replay_single_process(cfg, lr, fingerprint):
|
||||
def _replay_single_process(cfg, lr, fingerprint, disable_progress):
|
||||
with OpenpilotPrefix():
|
||||
controlsState = None
|
||||
initialized = False
|
||||
@@ -404,7 +405,7 @@ def _replay_single_process(cfg, lr, fingerprint):
|
||||
|
||||
# Do the replay
|
||||
cnt = 0
|
||||
for msg in pub_msgs:
|
||||
for msg in tqdm(pub_msgs, disable=disable_progress):
|
||||
with Timeout(cfg.timeout, error_msg=f"timed out testing process {repr(cfg.proc_name)}, {cnt}/{len(pub_msgs)} msgs done"):
|
||||
resp_sockets, end_of_cycle = cfg.subs, True
|
||||
if cfg.should_recv_callback is not None:
|
||||
|
||||
@@ -99,7 +99,7 @@ def test_process(cfg, lr, segment, ref_log_path, new_log_path, ignore_fields=Non
|
||||
ref_log_msgs = list(LogReader(ref_log_path))
|
||||
|
||||
try:
|
||||
log_msgs = replay_process(cfg, lr)
|
||||
log_msgs = replay_process(cfg, lr, disable_progress=True)
|
||||
except Exception as e:
|
||||
raise Exception("failed on segment: " + segment) from e
|
||||
|
||||
|
||||
Reference in New Issue
Block a user