tools: keep re pattern file small (#33084)

remove bz2 from re file
This commit is contained in:
Shane Smiskol 2024-07-25 22:05:10 -07:00 committed by GitHub
parent f39c5c22e8
commit e68bb26e14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 23 deletions

View File

@ -3,8 +3,7 @@
import argparse
from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, replay_process
from openpilot.tools.lib.helpers import save_log
from openpilot.tools.lib.logreader import LogReader
from openpilot.tools.lib.logreader import LogReader, save_log
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run process on route and create new logs",

View File

@ -10,8 +10,7 @@ from openpilot.tools.lib.openpilotci import BASE_URL, get_url
from openpilot.selfdrive.test.process_replay.compare_logs import compare_logs, format_diff
from openpilot.selfdrive.test.process_replay.process_replay import get_process_config, replay_process
from openpilot.tools.lib.framereader import FrameReader
from openpilot.tools.lib.logreader import LogReader
from openpilot.tools.lib.helpers import save_log
from openpilot.tools.lib.logreader import LogReader, save_log
TEST_ROUTE = "2f4452b03ccb98f0|2022-12-03--13-45-30"
SEGMENT = 6

View File

@ -14,8 +14,7 @@ from openpilot.selfdrive.test.process_replay.vision_meta import DRIVER_CAMERA_FR
from openpilot.selfdrive.test.update_ci_routes import upload_route
from openpilot.tools.lib.route import Route
from openpilot.tools.lib.framereader import FrameReader, BaseFrameReader, FrameType
from openpilot.tools.lib.logreader import LogReader, LogIterable
from openpilot.tools.lib.helpers import save_log
from openpilot.tools.lib.logreader import LogReader, LogIterable, save_log
class DummyFrameReader(BaseFrameReader):

View File

@ -14,8 +14,7 @@ from openpilot.selfdrive.test.process_replay.compare_logs import compare_logs, f
from openpilot.selfdrive.test.process_replay.process_replay import CONFIGS, PROC_REPLAY_DIR, FAKEDATA, replay_process, \
check_openpilot_enabled, check_most_messages_valid
from openpilot.tools.lib.filereader import FileReader
from openpilot.tools.lib.logreader import LogReader
from openpilot.tools.lib.helpers import save_log
from openpilot.tools.lib.logreader import LogReader, save_log
source_segments = [
("BODY", "937ccb7243511b65|2022-05-24--16-03-09--1"), # COMMA.COMMA_BODY

View File

@ -1,6 +1,3 @@
import bz2
# regex patterns
class RE:
DONGLE_ID = r'(?P<dongle_id>[a-f0-9]{16})'
@ -18,13 +15,3 @@ class RE:
EXPLORER_FILE = fr'^(?P<segment_name>{SEGMENT_NAME})--(?P<file_name>[a-z]+\.[a-z0-9]+)$'
OP_SEGMENT_DIR = fr'^(?P<segment_name>{SEGMENT_NAME})$'
def save_log(dest, log_msgs, compress=True):
dat = b"".join(msg.as_builder().to_bytes() for msg in log_msgs)
if compress:
dat = bz2.compress(dat)
with open(dest, "wb") as f:
f.write(dat)

View File

@ -27,6 +27,16 @@ LogIterable = Iterable[LogMessage]
RawLogIterable = Iterable[bytes]
def save_log(dest, log_msgs, compress=True):
dat = b"".join(msg.as_builder().to_bytes() for msg in log_msgs)
if compress:
dat = bz2.compress(dat)
with open(dest, "wb") as f:
f.write(dat)
class _LogFileReader:
def __init__(self, fn, canonicalize=True, only_union_types=False, sort_by_time=False, dat=None):
self.data_version = None

View File

@ -12,8 +12,7 @@ from functools import partial
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.car.fingerprints import MIGRATION
from openpilot.tools.lib.helpers import save_log
from openpilot.tools.lib.logreader import LogReader, ReadMode
from openpilot.tools.lib.logreader import LogReader, ReadMode, save_log
juggle_dir = os.path.dirname(os.path.realpath(__file__))