From e87b24a1e65b5cccc256410f26259fb5e062d3de Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Mon, 5 Feb 2024 23:21:27 +0800 Subject: [PATCH] matching master char case --- cereal | 2 +- selfdrive/athena/athenad.py | 4 ++-- selfdrive/camerad/test/test_camerad.py | 6 +++--- selfdrive/controls/lib/events.py | 4 ++-- selfdrive/debug/check_lag.py | 4 ++-- selfdrive/debug/count_events.py | 6 +++--- selfdrive/debug/dump.py | 4 ++-- selfdrive/debug/internal/qlog_size.py | 4 ++-- selfdrive/locationd/test/test_locationd.py | 6 +++--- selfdrive/loggerd/tests/test_loggerd.py | 12 ++++++------ selfdrive/test/process_replay/process_replay.py | 6 +++--- selfdrive/test/profiling/lib.py | 4 ++-- selfdrive/test/test_onroad.py | 6 +++--- system/camerad/test/test_camerad.py | 6 +++--- system/hardware/tici/tests/test_power_draw.py | 4 ++-- system/loggerd/tests/test_loggerd.py | 12 ++++++------ system/sensord/tests/test_pigeond.py | 6 +++--- system/sensord/tests/test_sensord.py | 4 ++-- 18 files changed, 50 insertions(+), 50 deletions(-) diff --git a/cereal b/cereal index 613fe6ca9..1b1ff66b7 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 613fe6ca9efa4975b9535d04ec987d5fe07bdeed +Subproject commit 1b1ff66b74382d4ab010807003b52b80d41f2282 diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index 15088f69b..779ff8bc5 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -29,7 +29,7 @@ import cereal.messaging as messaging from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.api import Api from openpilot.common.basedir import PERSIST from openpilot.common.file_helpers import CallbackReader @@ -310,7 +310,7 @@ def _do_upload(upload_item: UploadItem, callback: Optional[Callable] = None) -> # security: user should be able to request any message from their car @dispatcher.add_method def getMessage(service: str, timeout: int = 1000) -> Dict: - if service is None or service not in service_list: + if service is None or service not in SERVICE_LIST: raise Exception("invalid service") socket = messaging.sub_sock(service, timeout=timeout) diff --git a/selfdrive/camerad/test/test_camerad.py b/selfdrive/camerad/test/test_camerad.py index 6669df301..4f76bcecf 100755 --- a/selfdrive/camerad/test/test_camerad.py +++ b/selfdrive/camerad/test/test_camerad.py @@ -6,7 +6,7 @@ import cereal.messaging as messaging from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.system.hardware import TICI @@ -43,10 +43,10 @@ def setUpClass(cls): for cam, msgs in cls.logs.items(): if cls.sensor_type is None: cls.sensor_type = getattr(msgs[0], msgs[0].which()).sensor.raw - expected_frames = service_list[cam].frequency * TEST_TIMESPAN + expected_frames = SERVICE_LIST[cam].frequency * TEST_TIMESPAN assert expected_frames*0.95 < len(msgs) < expected_frames*1.05, f"unexpected frame count {cam}: {expected_frames=}, got {len(msgs)}" - dts = np.abs(np.diff([getattr(m, m.which()).timestampSof/1e6 for m in msgs]) - 1000/service_list[cam].frequency) + dts = np.abs(np.diff([getattr(m, m.which()).timestampSof/1e6 for m in msgs]) - 1000/SERVICE_LIST[cam].frequency) assert (dts < FRAME_DELTA_TOLERANCE[cls.sensor_type]).all(), f"{cam} dts(ms) out of spec: max diff {dts.max()}, 99 percentile {np.percentile(dts, 99)}" for m in msgs: diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 7c30effce..787ba9847 100755 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -958,7 +958,7 @@ def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, if __name__ == '__main__': # print all alerts by type and priority - from cereal.services import service_list + from cereal.services import SERVICE_LIST from collections import defaultdict, OrderedDict event_names = {v: k for k, v in EventName.schema.enumerants.items()} @@ -966,7 +966,7 @@ def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster, CP = car.CarParams.new_message() CS = car.CarState.new_message() - sm = messaging.SubMaster(list(service_list.keys())) + sm = messaging.SubMaster(list(SERVICE_LIST.keys())) for i, alerts in EVENTS.items(): for et, alert in alerts.items(): diff --git a/selfdrive/debug/check_lag.py b/selfdrive/debug/check_lag.py index 141156db9..72d11d6ed 100755 --- a/selfdrive/debug/check_lag.py +++ b/selfdrive/debug/check_lag.py @@ -2,7 +2,7 @@ from typing import Dict import cereal.messaging as messaging -from cereal.services import service_list +from cereal.services import SERVICE_LIST TO_CHECK = ['carState'] @@ -20,7 +20,7 @@ t = sm.logMonoTime[s] / 1e9 if s in prev_t: - expected = 1.0 / (service_list[s].frequency) + expected = 1.0 / (SERVICE_LIST[s].frequency) dt = t - prev_t[s] if dt > 10 * expected: print(t, s, dt) diff --git a/selfdrive/debug/count_events.py b/selfdrive/debug/count_events.py index a8af5e6fe..a148996d9 100755 --- a/selfdrive/debug/count_events.py +++ b/selfdrive/debug/count_events.py @@ -7,7 +7,7 @@ from tqdm import tqdm from typing import List, Tuple, cast -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.tools.lib.route import Route from openpilot.tools.lib.logreader import LogReader @@ -17,7 +17,7 @@ cnt_valid: Counter = Counter() cnt_events: Counter = Counter() - cams = [s for s in service_list if s.endswith('CameraState')] + cams = [s for s in SERVICE_LIST if s.endswith('CameraState')] cnt_cameras = dict.fromkeys(cams, 0) alerts: List[Tuple[float, str]] = [] @@ -62,7 +62,7 @@ print("\n") print("Cameras") for k, v in cnt_cameras.items(): - s = service_list[k] + s = SERVICE_LIST[k] expected_frames = int(s.frequency * duration / cast(float, s.decimation)) print(" ", k.ljust(20), f"{v}, {v/expected_frames:.1%} of expected") diff --git a/selfdrive/debug/dump.py b/selfdrive/debug/dump.py index 2e427b973..e14ea03c5 100755 --- a/selfdrive/debug/dump.py +++ b/selfdrive/debug/dump.py @@ -8,7 +8,7 @@ from hexdump import hexdump from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST codecs.register_error("strict", codecs.backslashreplace_errors) @@ -31,7 +31,7 @@ poller = messaging.Poller() - for m in args.socket if len(args.socket) > 0 else service_list: + for m in args.socket if len(args.socket) > 0 else SERVICE_LIST: messaging.sub_sock(m, poller, addr=args.addr) values = None diff --git a/selfdrive/debug/internal/qlog_size.py b/selfdrive/debug/internal/qlog_size.py index 0bdbe8f79..5d6fe8ce3 100755 --- a/selfdrive/debug/internal/qlog_size.py +++ b/selfdrive/debug/internal/qlog_size.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.tools.lib.logreader import LogReader from openpilot.tools.lib.route import Route @@ -49,7 +49,7 @@ def make_pie(msgs, typ): msgs_by_type[m.which()].append(m.as_builder().to_bytes()) qlog_by_type = defaultdict(list) - for name, service in service_list.items(): + for name, service in SERVICE_LIST.items(): if service.decimation is None: continue diff --git a/selfdrive/locationd/test/test_locationd.py b/selfdrive/locationd/test/test_locationd.py index 6c6ac3343..b2f0b18d0 100755 --- a/selfdrive/locationd/test/test_locationd.py +++ b/selfdrive/locationd/test/test_locationd.py @@ -6,7 +6,7 @@ import capnp import cereal.messaging as messaging -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.params import Params from openpilot.common.transformations.coordinates import ecef2geodetic @@ -74,8 +74,8 @@ def test_params_gps(self): msgs = [] for sec in range(65): for name in self.LLD_MSGS: - for j in range(int(service_list[name].frequency)): - msgs.append(self.get_msg(name, int((sec + j / service_list[name].frequency) * 1e9))) + for j in range(int(SERVICE_LIST[name].frequency)): + msgs.append(self.get_msg(name, int((sec + j / SERVICE_LIST[name].frequency) * 1e9))) for msg in sorted(msgs, key=lambda x: x.logMonoTime): self.pm.send(msg.which(), msg) diff --git a/selfdrive/loggerd/tests/test_loggerd.py b/selfdrive/loggerd/tests/test_loggerd.py index 516ddbaac..cb327d1a3 100755 --- a/selfdrive/loggerd/tests/test_loggerd.py +++ b/selfdrive/loggerd/tests/test_loggerd.py @@ -11,7 +11,7 @@ import cereal.messaging as messaging from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.basedir import BASEDIR from openpilot.common.params import Params from openpilot.common.timeout import Timeout @@ -26,8 +26,8 @@ SentinelType = log.Sentinel.SentinelType -CEREAL_SERVICES = [f for f in log.Event.schema.union_fields if f in service_list - and service_list[f].should_log and "encode" not in f.lower()] +CEREAL_SERVICES = [f for f in log.Event.schema.union_fields if f in SERVICE_LIST + and SERVICE_LIST[f].should_log and "encode" not in f.lower()] class TestLoggerd(unittest.TestCase): @@ -179,8 +179,8 @@ def test_bootlog(self): self.assertEqual(expected_val, bootlog_val) def test_qlog(self): - qlog_services = [s for s in CEREAL_SERVICES if service_list[s].decimation is not None] - no_qlog_services = [s for s in CEREAL_SERVICES if service_list[s].decimation is None] + qlog_services = [s for s in CEREAL_SERVICES if SERVICE_LIST[s].decimation is not None] + no_qlog_services = [s for s in CEREAL_SERVICES if SERVICE_LIST[s].decimation is None] services = random.sample(qlog_services, random.randint(2, min(10, len(qlog_services)))) + \ random.sample(no_qlog_services, random.randint(2, min(10, len(no_qlog_services)))) @@ -227,7 +227,7 @@ def test_qlog(self): self.assertEqual(recv_cnt, 0, f"got {recv_cnt} {s} msgs in qlog") else: # check logged message count matches decimation - expected_cnt = (len(msgs) - 1) // service_list[s].decimation + 1 + expected_cnt = (len(msgs) - 1) // SERVICE_LIST[s].decimation + 1 self.assertEqual(recv_cnt, expected_cnt, f"expected {expected_cnt} msgs for {s}, got {recv_cnt}") def test_rlog(self): diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 1e56a2a9f..e00d72a6d 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -14,7 +14,7 @@ import cereal.messaging as messaging from cereal import car -from cereal.services import service_list +from cereal.services import SERVICE_LIST from cereal.visionipc import VisionIpcServer, get_endpoint_name as vipc_get_endpoint_name from openpilot.common.params import Params from openpilot.common.timeout import Timeout @@ -339,7 +339,7 @@ def controlsd_rcv_callback(msg, cfg, frame): socks = [ s for s in cfg.subs if - frame % int(service_list[msg.which()].frequency / service_list[s].frequency) == 0 + frame % int(SERVICE_LIST[msg.which()].frequency / SERVICE_LIST[s].frequency) == 0 ] if "sendcan" in socks and (frame - 1) < 2000: socks.remove("sendcan") @@ -403,7 +403,7 @@ def __call__(self, msg, cfg, frame): resp_sockets = [ s for s in cfg.subs - if frame % max(1, int(service_list[msg.which()].frequency / service_list[s].frequency)) == 0 + if frame % max(1, int(SERVICE_LIST[msg.which()].frequency / SERVICE_LIST[s].frequency)) == 0 ] return bool(len(resp_sockets)) diff --git a/selfdrive/test/profiling/lib.py b/selfdrive/test/profiling/lib.py index f28346f3f..1152db205 100644 --- a/selfdrive/test/profiling/lib.py +++ b/selfdrive/test/profiling/lib.py @@ -1,5 +1,5 @@ from collections import defaultdict, deque -from cereal.services import service_list +from cereal.services import SERVICE_LIST import cereal.messaging as messaging import capnp @@ -67,7 +67,7 @@ def __init__(self, msgs, trigger, services, check_averag_freq=False): # pylint: self.msgs = list(reversed(self.msgs)) for s in services: - self.freq[s] = service_list[s].frequency + self.freq[s] = SERVICE_LIST[s].frequency try: data = messaging.new_message(s) except capnp.lib.capnp.KjException: diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index fe5137f9a..baf6fe8d9 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -13,7 +13,7 @@ from cereal import car import cereal.messaging as messaging -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.basedir import BASEDIR from openpilot.common.timeout import Timeout from openpilot.common.params import Params @@ -179,7 +179,7 @@ def test_service_frequencies(self): continue with self.subTest(service=s): - assert len(msgs) >= math.floor(service_list[s].frequency*55) + assert len(msgs) >= math.floor(SERVICE_LIST[s].frequency*55) def test_cloudlog_size(self): msgs = [m for m in self.lr if m.which() == 'logMessage'] @@ -356,7 +356,7 @@ def test_timings(self): raise Exception(f"missing {s}") ts = np.diff(msgs) / 1e9 - dt = 1 / service_list[s].frequency + dt = 1 / SERVICE_LIST[s].frequency try: np.testing.assert_allclose(np.mean(ts), dt, rtol=0.03, err_msg=f"{s} - failed mean timing check") diff --git a/system/camerad/test/test_camerad.py b/system/camerad/test/test_camerad.py index 6669df301..4f76bcecf 100755 --- a/system/camerad/test/test_camerad.py +++ b/system/camerad/test/test_camerad.py @@ -6,7 +6,7 @@ import cereal.messaging as messaging from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.system.hardware import TICI @@ -43,10 +43,10 @@ def setUpClass(cls): for cam, msgs in cls.logs.items(): if cls.sensor_type is None: cls.sensor_type = getattr(msgs[0], msgs[0].which()).sensor.raw - expected_frames = service_list[cam].frequency * TEST_TIMESPAN + expected_frames = SERVICE_LIST[cam].frequency * TEST_TIMESPAN assert expected_frames*0.95 < len(msgs) < expected_frames*1.05, f"unexpected frame count {cam}: {expected_frames=}, got {len(msgs)}" - dts = np.abs(np.diff([getattr(m, m.which()).timestampSof/1e6 for m in msgs]) - 1000/service_list[cam].frequency) + dts = np.abs(np.diff([getattr(m, m.which()).timestampSof/1e6 for m in msgs]) - 1000/SERVICE_LIST[cam].frequency) assert (dts < FRAME_DELTA_TOLERANCE[cls.sensor_type]).all(), f"{cam} dts(ms) out of spec: max diff {dts.max()}, 99 percentile {np.percentile(dts, 99)}" for m in msgs: diff --git a/system/hardware/tici/tests/test_power_draw.py b/system/hardware/tici/tests/test_power_draw.py index fbca95f6f..1409e43cf 100755 --- a/system/hardware/tici/tests/test_power_draw.py +++ b/system/hardware/tici/tests/test_power_draw.py @@ -8,7 +8,7 @@ from typing import List import cereal.messaging as messaging -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.system.hardware import HARDWARE, TICI from openpilot.system.hardware.tici.power_monitor import get_power from openpilot.selfdrive.manager.process_config import managed_processes @@ -91,7 +91,7 @@ def test_camera_procs(self): cur = used[proc.name] expected = proc.power msgs_received = sum(msg_counts[msg] for msg in proc.msgs) - msgs_expected = int(sum(SAMPLE_TIME * service_list[msg].frequency for msg in proc.msgs)) + msgs_expected = int(sum(SAMPLE_TIME * SERVICE_LIST[msg].frequency for msg in proc.msgs)) tab.append([proc.name, round(expected, 2), round(cur, 2), msgs_expected, msgs_received]) with self.subTest(proc=proc.name): self.assertTrue(math.isclose(cur, expected, rel_tol=proc.rtol, abs_tol=proc.atol)) diff --git a/system/loggerd/tests/test_loggerd.py b/system/loggerd/tests/test_loggerd.py index b43f597c2..411ed68b0 100755 --- a/system/loggerd/tests/test_loggerd.py +++ b/system/loggerd/tests/test_loggerd.py @@ -12,7 +12,7 @@ import cereal.messaging as messaging from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.basedir import BASEDIR from openpilot.common.params import Params from openpilot.common.timeout import Timeout @@ -27,8 +27,8 @@ SentinelType = log.Sentinel.SentinelType -CEREAL_SERVICES = [f for f in log.Event.schema.union_fields if f in service_list - and service_list[f].should_log and "encode" not in f.lower()] +CEREAL_SERVICES = [f for f in log.Event.schema.union_fields if f in SERVICE_LIST + and SERVICE_LIST[f].should_log and "encode" not in f.lower()] class TestLoggerd(unittest.TestCase): @@ -216,8 +216,8 @@ def test_bootlog(self): self.assertEqual(expected_val, bootlog_val) def test_qlog(self): - qlog_services = [s for s in CEREAL_SERVICES if service_list[s].decimation is not None] - no_qlog_services = [s for s in CEREAL_SERVICES if service_list[s].decimation is None] + qlog_services = [s for s in CEREAL_SERVICES if SERVICE_LIST[s].decimation is not None] + no_qlog_services = [s for s in CEREAL_SERVICES if SERVICE_LIST[s].decimation is None] services = random.sample(qlog_services, random.randint(2, min(10, len(qlog_services)))) + \ random.sample(no_qlog_services, random.randint(2, min(10, len(no_qlog_services)))) @@ -242,7 +242,7 @@ def test_qlog(self): self.assertEqual(recv_cnt, 0, f"got {recv_cnt} {s} msgs in qlog") else: # check logged message count matches decimation - expected_cnt = (len(msgs) - 1) // service_list[s].decimation + 1 + expected_cnt = (len(msgs) - 1) // SERVICE_LIST[s].decimation + 1 self.assertEqual(recv_cnt, expected_cnt, f"expected {expected_cnt} msgs for {s}, got {recv_cnt}") def test_rlog(self): diff --git a/system/sensord/tests/test_pigeond.py b/system/sensord/tests/test_pigeond.py index d7c7567e4..d228dd20f 100755 --- a/system/sensord/tests/test_pigeond.py +++ b/system/sensord/tests/test_pigeond.py @@ -3,7 +3,7 @@ import unittest import cereal.messaging as messaging -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.gpio import gpio_read from openpilot.selfdrive.test.helpers import with_processes from openpilot.selfdrive.manager.process_config import managed_processes @@ -26,10 +26,10 @@ def test_frequency(self): sm = messaging.SubMaster(['ubloxRaw']) # setup time - for _ in range(int(5 * service_list['ubloxRaw'].frequency)): + for _ in range(int(5 * SERVICE_LIST['ubloxRaw'].frequency)): sm.update() - for _ in range(int(10 * service_list['ubloxRaw'].frequency)): + for _ in range(int(10 * SERVICE_LIST['ubloxRaw'].frequency)): sm.update() assert sm.all_checks() diff --git a/system/sensord/tests/test_sensord.py b/system/sensord/tests/test_sensord.py index e3cd77a1a..3a5ef850b 100755 --- a/system/sensord/tests/test_sensord.py +++ b/system/sensord/tests/test_sensord.py @@ -7,7 +7,7 @@ import cereal.messaging as messaging from cereal import log -from cereal.services import service_list +from cereal.services import SERVICE_LIST from openpilot.common.gpio import get_irqs_for_action from openpilot.system.hardware import TICI from openpilot.selfdrive.manager.process_config import managed_processes @@ -163,7 +163,7 @@ def test_sensor_frequency(self): for s, msgs in self.events.items(): with self.subTest(sensor=s): freq = len(msgs) / self.sample_secs - ef = service_list[s].frequency + ef = SERVICE_LIST[s].frequency assert ef*0.85 <= freq <= ef*1.15 def test_logmonottime_timestamp_diff(self):