Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
matching master char case
Browse files Browse the repository at this point in the history
  • Loading branch information
eFiniLan committed Feb 5, 2024
1 parent ec74994 commit e87b24a
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion cereal
4 changes: 2 additions & 2 deletions selfdrive/athena/athenad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/camerad/test/test_camerad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,15 +958,15 @@ 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()}
alerts_by_type: Dict[str, Dict[int, List[str]]] = defaultdict(lambda: defaultdict(list))

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():
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/debug/check_lag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/debug/count_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]] = []
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/debug/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/debug/internal/qlog_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions selfdrive/locationd/test/test_locationd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions selfdrive/loggerd/tests/test_loggerd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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))))
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/test/process_replay/process_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/test/profiling/lib.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/test/test_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions system/camerad/test/test_camerad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions system/hardware/tici/tests/test_power_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 6 additions & 6 deletions system/loggerd/tests/test_loggerd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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))))
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions system/sensord/tests/test_pigeond.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions system/sensord/tests/test_sensord.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e87b24a

Please sign in to comment.