mirror of https://github.com/commaai/openpilot.git
LogReader: print number of missing rlogs (#32830)
* count rlogs * minimization changes * cache to avoid duplicate checks * no real point in checking qlogs to just show the warning --------- Co-authored-by: Shane Smiskol <shane@smiskol.com>
This commit is contained in:
parent
b7695c00e8
commit
504dd4543d
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import bz2
|
||||
from functools import partial
|
||||
from functools import cache, partial
|
||||
import multiprocessing
|
||||
import capnp
|
||||
import enum
|
||||
|
@ -87,18 +87,21 @@ Source = Callable[[SegmentRange, ReadMode], LogPaths]
|
|||
|
||||
InternalUnavailableException = Exception("Internal source not available")
|
||||
|
||||
|
||||
@cache
|
||||
def default_valid_file(fn: LogPath) -> bool:
|
||||
return fn is not None and file_exists(fn)
|
||||
|
||||
|
||||
def auto_strategy(rlog_paths: LogPaths, qlog_paths: LogPaths, interactive: bool, valid_file: ValidFileCallable) -> LogPaths:
|
||||
# auto select logs based on availability
|
||||
if any(rlog is None or not valid_file(rlog) for rlog in rlog_paths) and all(qlog is not None and valid_file(qlog) for qlog in qlog_paths):
|
||||
missing_rlogs = [rlog is None or not valid_file(rlog) for rlog in rlog_paths].count(True)
|
||||
if missing_rlogs != 0:
|
||||
if interactive:
|
||||
if input("Some rlogs were not found, would you like to fallback to qlogs for those segments? (y/n) ").lower() != "y":
|
||||
if input(f"{missing_rlogs} rlogs were not found, would you like to fallback to qlogs for those segments? (y/n) ").lower() != "y":
|
||||
return rlog_paths
|
||||
else:
|
||||
cloudlog.warning("Some rlogs were not found, falling back to qlogs for those segments...")
|
||||
cloudlog.warning(f"{missing_rlogs} rlogs were not found, falling back to qlogs for those segments...")
|
||||
|
||||
return [rlog if valid_file(rlog) else (qlog if valid_file(qlog) else None)
|
||||
for (rlog, qlog) in zip(rlog_paths, qlog_paths, strict=True)]
|
||||
|
|
Loading…
Reference in New Issue