Revert "CI: pylint to ruff (#29276)" (#29284)

This reverts commit ffad7279cbad3c4f2ea786287b4624d3a3aa18d7.
old-commit-hash: a91764954b
beeps
Justin Newberry 2 years ago committed by GitHub
parent c1bcb53d4e
commit ff96892511
  1. 28
      .pre-commit-config.yaml
  2. 4
      poetry.lock
  3. 10
      pyproject.toml
  4. 2
      selfdrive/car/body/carcontroller.py
  5. 2
      selfdrive/controls/lib/events.py
  6. 2
      selfdrive/debug/clear_dtc.py
  7. 7
      selfdrive/debug/dump.py
  8. 6
      selfdrive/locationd/test/test_laikad.py
  9. 2
      selfdrive/modeld/runners/onnx_runner.py
  10. 3
      selfdrive/modeld/thneed/lib.py
  11. 16
      selfdrive/navd/tests/test_map_renderer.py
  12. 4
      selfdrive/test/process_replay/capture.py
  13. 4
      selfdrive/test/process_replay/migration.py
  14. 28
      selfdrive/test/process_replay/process_replay.py
  15. 2
      selfdrive/test/process_replay/regen.py
  16. 34
      selfdrive/test/process_replay/test_processes.py
  17. 14
      selfdrive/thermald/tests/test_power_monitoring.py
  18. 2
      selfdrive/updated.py
  19. 2
      system/sensord/rawgps/structs.py

@ -34,11 +34,31 @@ repos:
types: [python]
args: ['--explicit-package-bases']
exclude: '^(third_party/)|(cereal/)|(opendbc/)|(panda/)|(laika/)|(laika_repo/)|(rednose/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(xx/)'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: ruff
exclude: '^(third_party/)|(cereal/)|(body/)|(rednose/)|(rednose_repo/)|(opendbc/)|(panda/)|(tools/)|(selfdrive/modeld/thneed/debug/)|(selfdrive/modeld/test/)|(selfdrive/camerad/test/)|(installer/)|(tinygrad_repo/)'
- id: flake8
exclude: '^(third_party/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(opendbc/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)|(selfdrive/debug/)/'
additional_dependencies: ['flake8-no-implicit-concat']
args:
- --indent-size=2
- --enable-extensions=NIC
- --select=F,E112,E113,E304,E502,E701,E702,E703,E71,E72,E731,W191,W6
- --statistics
- -j4
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
exclude: '^(third_party/)|(cereal/)|(rednose/)|(panda/)|(laika/)|(laika_repo/)|(rednose_repo/)|(tinygrad/)|(tinygrad_repo/)'
args:
- -j0
- -rn
- -sn
- --rcfile=.pylintrc
- repo: local
hooks:
- id: cppcheck

4
poetry.lock generated

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:36187dd8afc0afe0abdb6976b5d31bb07294ec91c96022b426e86a0484216d8e
size 792009
oid sha256:4bdf2a7ffee6dd09d6532b7e2a2cd5d6af889658cfbbe0d02deac92e14be33e9
size 809997

@ -19,6 +19,7 @@ cffi = "*"
crcmod = "*"
cryptography = "*"
Cython = "*"
flake8 = "*"
Flask = "*"
future-fstrings = "*" # for acados
gunicorn = "*"
@ -91,6 +92,7 @@ pprofile = "*"
pre-commit = "*"
pycurl = "*"
pygame = "*"
pylint = "*"
pyprof2calltree = "*"
pytest = "*"
pytest-xdist = "*"
@ -159,7 +161,6 @@ PyMySQL = "~0.9"
pyproj = "*"
python-logstash = "*"
redis = "*"
ruff = "*"
s2sphere = "*"
scikit-image = "*"
scikit-learn = "*"
@ -185,10 +186,3 @@ opencv-python-headless = { url = "https://github.com/commaai/opencv-python-build
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff]
select = ["E", "F", "W"]
ignore = ["W292", "E741"]
line-length = 2500
target-version="py311"

@ -56,7 +56,7 @@ class CarController:
speed_error = speed_desired - speed_measured
if self.wheeled_body is None:
freeze_integrator = ((speed_error < 0 and self.speed_pid.error_integral <= -MAX_POS_INTEGRATOR) or
freeze_integrator = ((speed_error < 0 and self.speed_pid.error_integral <= -MAX_POS_INTEGRATOR) or
(speed_error > 0 and self.speed_pid.error_integral >= MAX_POS_INTEGRATOR))
angle_setpoint = self.speed_pid.update(speed_error, freeze_integrator=freeze_integrator)

@ -724,7 +724,7 @@ EVENTS: Dict[int, Dict[str, Union[Alert, AlertCallbackType]]] = {
ET.SOFT_DISABLE: soft_disable_alert("Calibration Incomplete"),
ET.NO_ENTRY: NoEntryAlert("Calibration in Progress"),
},
EventName.calibrationRecalibrating: {
ET.PERMANENT: calibration_incomplete_alert,
ET.SOFT_DISABLE: soft_disable_alert("Device Remount Detected: Recalibrating"),

@ -35,6 +35,6 @@ try:
except MessageTimeoutError:
# functional address isn't properly handled so a timeout occurs
if args.addr != 0x7DF:
pass
pass
print("")
print("you may need to power cycle your vehicle now")

@ -3,15 +3,14 @@ import os
import sys
import argparse
import json
from hexdump import hexdump
import codecs
import cereal.messaging as messaging
codecs.register_error("strict", codecs.backslashreplace_errors)
from hexdump import hexdump
from cereal import log
import cereal.messaging as messaging
from cereal.services import service_list
codecs.register_error("strict", codecs.backslashreplace_errors)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Dump communication sockets. See cereal/services.py for a complete list of available sockets.')

@ -111,7 +111,7 @@ class TestLaikad(unittest.TestCase):
laikad = Laikad()
laikad.fetch_navs(gpstime, block=False)
laikad.orbit_fetch_future.result(30)
# Get results and save orbits to laikad:
laikad.fetch_navs(gpstime, block=False)
ephem = laikad.astro_dog.navs['G01'][0]
@ -238,7 +238,7 @@ class TestLaikad(unittest.TestCase):
if len(out_msg.gnssMeasurements.ephemerisStatuses):
seen_chip_eph = seen_chip_eph or any([x.source == 'gnssChip' for x in out_msg.gnssMeasurements.ephemerisStatuses])
seen_internet_eph = seen_internet_eph or any([x.source == 'internet' for x in out_msg.gnssMeasurements.ephemerisStatuses])
self.assertTrue(has_navs or has_polys)
self.assertTrue(has_fix)
self.assertTrue(seen_chip_eph or auto_fetch_navs)
@ -281,7 +281,7 @@ class TestLaikad(unittest.TestCase):
self.assertTrue(any([x.source=='cache' for x in msg.gnssMeasurements.ephemerisStatuses]))
self.assertIsNotNone(msg)
#TODO test cache with only orbits
#TODO test cache with only orbits
#with patch('selfdrive.locationd.laikad.get_orbit_data', return_value=None) as mock_method:
# # Verify no orbit downloads even if orbit fetch times is reset since the cache has recently been saved and we don't want to download high frequently
# laikad.astro_dog.orbit_fetched_times = TimeRangeHolder()

@ -8,7 +8,7 @@ from typing import Tuple, Dict, Union, Any
os.environ["OMP_NUM_THREADS"] = "4"
os.environ["OMP_WAIT_POLICY"] = "PASSIVE"
import onnxruntime as ort # noqa: E402
import onnxruntime as ort # pylint: disable=import-error
ORT_TYPES_TO_NP_TYPES = {'tensor(float16)': np.float16, 'tensor(float)': np.float32, 'tensor(uint8)': np.uint8}

@ -1,5 +1,4 @@
import struct
import json
import struct, json
def load_thneed(fn):
with open(fn, "rb") as f:

@ -30,7 +30,7 @@ class MapBoxInternetDisabledRequestHandler(http.server.BaseHTTPRequestHandler):
def setup(self):
if self.INTERNET_ACTIVE:
super().setup()
def handle(self):
if self.INTERNET_ACTIVE:
super().handle()
@ -38,7 +38,7 @@ class MapBoxInternetDisabledRequestHandler(http.server.BaseHTTPRequestHandler):
def finish(self):
if self.INTERNET_ACTIVE:
super().finish()
def do_GET(self):
url = f'https://api.mapbox.com{self.path}'
@ -50,7 +50,7 @@ class MapBoxInternetDisabledRequestHandler(http.server.BaseHTTPRequestHandler):
self.send_response(r.status_code)
self.end_headers()
self.wfile.write(r.content)
def log_message(self, *args: Any) -> None:
return
@ -62,13 +62,13 @@ class MapBoxInternetDisabledServer(threading.Thread):
def run(self):
self.server = http.server.HTTPServer(("127.0.0.1", 5000), MapBoxInternetDisabledRequestHandler)
self.server.serve_forever()
def stop(self):
self.server.shutdown()
def disable_internet(self):
MapBoxInternetDisabledRequestHandler.INTERNET_ACTIVE = False
def enable_internet(self):
MapBoxInternetDisabledRequestHandler.INTERNET_ACTIVE = True
@ -110,7 +110,7 @@ class TestMapRenderer(unittest.TestCase):
assert self.vipc.connect(False)
self.vipc.recv()
def _run_test(self, expect_valid, location=LOCATION1):
starting_frame_id = None
@ -127,7 +127,7 @@ class TestMapRenderer(unittest.TestCase):
else:
prev_valid = self.sm.valid['mapRenderState']
prev_frame_id = self.sm['mapRenderState'].frameId
if starting_frame_id is None:
starting_frame_id = prev_frame_id
@ -172,7 +172,7 @@ class TestMapRenderer(unittest.TestCase):
self.server.disable_internet()
self._setup_test()
self._run_test(False)
def test_recover_from_no_internet(self):
self._setup_test()
self._run_test(True)

@ -22,7 +22,7 @@ class FdRedirect:
def read(self) -> bytes:
with open(self.dest_fname, "rb") as f:
return f.read() or b""
def link(self) -> None:
os.dup2(self.dest_fd, self.source_fd)
@ -39,7 +39,7 @@ class ProcessOutputCapture:
@no_type_check # ipython classes have incompatible signatures
def link_with_current_proc(self) -> None:
try:
try:
# prevent ipykernel from redirecting stdout/stderr of python subprocesses
from ipykernel.iostream import OutStream
if isinstance(sys.stdout, OutStream):

@ -20,13 +20,13 @@ def migrate_cameraStates(lr):
for msg in lr:
if msg.which() not in ["roadEncodeIdx", "wideRoadEncodeIdx", "driverEncodeIdx"]:
continue
encode_index = getattr(msg, msg.which())
meta = meta_from_encode_index(msg.which())
assert encode_index.segmentId < 1200, f"Encoder index segmentId greater that 1200: {msg.which()} {encode_index.segmentId}"
frame_to_encode_id[meta.camera_state][encode_index.frameId] = encode_index.segmentId
for msg in lr:
if msg.which() not in ["roadCameraState", "wideRoadCameraState", "driverCameraState"]:
all_msgs.append(msg)

@ -52,7 +52,7 @@ class ReplayContext:
self.main_pub_drained = cfg.main_pub_drained
self.unlocked_pubs = cfg.unlocked_pubs
assert(len(self.pubs) != 0 or self.main_pub is not None)
def __enter__(self):
self.open()
@ -82,7 +82,7 @@ class ReplayContext:
@property
def all_recv_called_events(self):
return [man.recv_called_event for man in self.events.values()]
@property
def all_recv_ready_events(self):
return [man.recv_ready_event for man in self.events.values()]
@ -142,7 +142,7 @@ class ProcessContainer:
self.cnt = 0
self.pm: Optional[messaging.PubMaster] = None
self.sockets: Optional[List[messaging.SubSocket]] = None
self.rc: Optional[ReplayContext] = None
self.rc: Optional[ReplayContext] = None
self.vipc_server: Optional[VisionIpcServer] = None
self.capture: Optional[ProcessOutputCapture] = None
@ -199,8 +199,8 @@ class ProcessContainer:
self.process.start()
def start(
self, params_config: Dict[str, Any], environ_config: Dict[str, Any],
all_msgs: Union[LogReader, List[capnp._DynamicStructReader]],
self, params_config: Dict[str, Any], environ_config: Dict[str, Any],
all_msgs: Union[LogReader, List[capnp._DynamicStructReader]],
fingerprint: Optional[str], capture_output: bool
):
with self.prefix as p:
@ -335,7 +335,7 @@ def get_car_params_callback(rc, pm, msgs, fingerprint):
def controlsd_rcv_callback(msg, cfg, frame):
# no sendcan until controlsd is initialized
if msg.which() != "can":
return False
return False
socks = [
s for s in cfg.subs if
@ -406,7 +406,7 @@ class FrequencyBasedRcvCallback:
if frame % max(1, int(service_list[msg.which()].frequency / service_list[s].frequency)) == 0
]
return bool(len(resp_sockets))
def controlsd_config_callback(params, cfg, lr):
controlsState = None
@ -436,7 +436,7 @@ def laikad_config_pubsub_callback(params, cfg, lr):
def locationd_config_pubsub_callback(params, cfg, lr):
ublox = params.get_bool("UbloxAvailable")
sub_keys = ({"gpsLocation", } if ublox else {"gpsLocationExternal", })
cfg.pubs = set(cfg.pubs) - sub_keys
@ -494,7 +494,7 @@ CONFIGS = [
ProcessConfig(
proc_name="locationd",
pubs=[
"cameraOdometry", "accelerometer", "gyroscope", "gpsLocationExternal",
"cameraOdometry", "accelerometer", "gyroscope", "gpsLocationExternal",
"liveCalibration", "carState", "carParams", "gpsLocation"
],
subs=["liveLocationKalman"],
@ -576,7 +576,7 @@ def get_process_config(name: str) -> ProcessConfig:
def get_custom_params_from_lr(lr: Union[LogReader, List[capnp._DynamicStructReader]], initial_state: str = "first") -> Dict[str, Any]:
"""
Use this to get custom params dict based on provided logs.
Use this to get custom params dict based on provided logs.
Useful when replaying following processes: calibrationd, paramsd, torqued
The params may be based on first or last message of given type (carParams, liveCalibration, liveParameters, liveTorqueParameters) in the logs.
"""
@ -618,7 +618,7 @@ def replay_process_with_name(name: Union[str, Iterable[str]], lr: Union[LogReade
def replay_process(
cfg: Union[ProcessConfig, Iterable[ProcessConfig]], lr: Union[LogReader, List[capnp._DynamicStructReader]], frs: Optional[Dict[str, Any]] = None,
cfg: Union[ProcessConfig, Iterable[ProcessConfig]], lr: Union[LogReader, List[capnp._DynamicStructReader]], frs: Optional[Dict[str, Any]] = None,
fingerprint: Optional[str] = None, return_all_logs: bool = False, custom_params: Optional[Dict[str, Any]] = None,
captured_output_store: Optional[Dict[str, Dict[str, str]]] = None, disable_progress: bool = False
) -> List[capnp._DynamicStructReader]:
@ -658,7 +658,7 @@ def _replay_multi_process(
for cfg in cfgs:
if len(cfg.vision_pubs) == 0:
continue
assert frs is not None, "frs must be provided when replaying process using vision streams"
assert all(meta_from_camera_state(st) is not None for st in cfg.vision_pubs),f"undefined vision stream spotted, probably misconfigured process: {cfg.vision_pubs}"
assert all(st in frs for st in cfg.vision_pubs), f"frs for this process must contain following vision streams: {cfg.vision_pubs}"
@ -719,7 +719,7 @@ def generate_params_config(lr=None, CP=None, fingerprint=None, custom_params=Non
"DisengageOnAccelerator": True,
"DisableLogging": False,
}
if custom_params is not None:
params_dict.update(custom_params)
if lr is not None:
@ -766,7 +766,7 @@ def generate_environ_config(CP=None, fingerprint=None, log_dir=None) -> Dict[str
else:
environ_dict["SKIP_FW_QUERY"] = ""
environ_dict["FINGERPRINT"] = ""
return environ_dict

@ -15,7 +15,7 @@ from tools.lib.helpers import save_log
def regen_segment(
lr: Union[LogReader, List[capnp._DynamicStructReader]], frs: Optional[Dict[str, Any]] = None,
lr: Union[LogReader, List[capnp._DynamicStructReader]], frs: Optional[Dict[str, Any]] = None,
daemons: Union[str, Iterable[str]] = "all", disable_tqdm: bool = False
) -> List[capnp._DynamicStructReader]:
if not isinstance(daemons, str) and not hasattr(daemons, "__iter__"):

@ -41,23 +41,23 @@ source_segments = [
]
segments = [
("BODY", "aregenECF15D9E559|2023-05-10--14-26-40--0"),
("HYUNDAI", "aregenAB9F543F70A|2023-05-10--14-28-25--0"),
("HYUNDAI2", "aregen39F5A028F96|2023-05-10--14-31-00--0"),
("TOYOTA", "aregen8D6A8B36E8D|2023-05-10--14-32-38--0"),
("TOYOTA2", "aregenB1933C49809|2023-05-10--14-34-14--0"),
("TOYOTA3", "aregen5D9915223DC|2023-05-10--14-36-43--0"),
("HONDA", "aregen484B732B675|2023-05-10--14-38-23--0"),
("HONDA2", "aregenAF6ACED4713|2023-05-10--14-40-01--0"),
("CHRYSLER", "aregen99B094E1E2E|2023-05-10--14-41-40--0"),
("RAM", "aregen5C2487E1EEB|2023-05-10--14-44-09--0"),
("SUBARU", "aregen98D277B792E|2023-05-10--14-46-46--0"),
("GM", "aregen377BA28D848|2023-05-10--14-48-28--0"),
("GM2", "aregen7CA0CC0F0C2|2023-05-10--14-51-00--0"),
("NISSAN", "aregen7097BF01563|2023-05-10--14-52-43--0"),
("VOLKSWAGEN", "aregen765AF3D2CB5|2023-05-10--14-54-23--0"),
("MAZDA", "aregen3053762FF2E|2023-05-10--14-56-53--0"),
("FORD", "aregenDDE0F89FA1E|2023-05-10--14-59-26--0"),
("BODY", "aregenECF15D9E559|2023-05-10--14-26-40--0"),
("HYUNDAI", "aregenAB9F543F70A|2023-05-10--14-28-25--0"),
("HYUNDAI2", "aregen39F5A028F96|2023-05-10--14-31-00--0"),
("TOYOTA", "aregen8D6A8B36E8D|2023-05-10--14-32-38--0"),
("TOYOTA2", "aregenB1933C49809|2023-05-10--14-34-14--0"),
("TOYOTA3", "aregen5D9915223DC|2023-05-10--14-36-43--0"),
("HONDA", "aregen484B732B675|2023-05-10--14-38-23--0"),
("HONDA2", "aregenAF6ACED4713|2023-05-10--14-40-01--0"),
("CHRYSLER", "aregen99B094E1E2E|2023-05-10--14-41-40--0"),
("RAM", "aregen5C2487E1EEB|2023-05-10--14-44-09--0"),
("SUBARU", "aregen98D277B792E|2023-05-10--14-46-46--0"),
("GM", "aregen377BA28D848|2023-05-10--14-48-28--0"),
("GM2", "aregen7CA0CC0F0C2|2023-05-10--14-51-00--0"),
("NISSAN", "aregen7097BF01563|2023-05-10--14-52-43--0"),
("VOLKSWAGEN", "aregen765AF3D2CB5|2023-05-10--14-54-23--0"),
("MAZDA", "aregen3053762FF2E|2023-05-10--14-56-53--0"),
("FORD", "aregenDDE0F89FA1E|2023-05-10--14-59-26--0"),
]
# dashcamOnly makes don't need to be tested until a full port is done

@ -177,23 +177,23 @@ class TestPowerMonitoring(unittest.TestCase):
if i % 10 == 0:
self.assertFalse(pm.should_shutdown(ignition, False, ssb, False))
self.assertFalse(pm.should_shutdown(ignition, False, ssb, False))
def test_delay_shutdown_time(self):
pm = PowerMonitoring()
pm.car_battery_capacity_uWh = 0
ignition = False
in_car = True
in_car = True
offroad_timestamp = ssb
started_seen = True
pm.calculate(VOLTAGE_BELOW_PAUSE_CHARGING, ignition)
while ssb < offroad_timestamp + DELAY_SHUTDOWN_TIME_S:
self.assertFalse(pm.should_shutdown(ignition, in_car,
offroad_timestamp,
started_seen),
self.assertFalse(pm.should_shutdown(ignition, in_car,
offroad_timestamp,
started_seen),
f"Should not shutdown before {DELAY_SHUTDOWN_TIME_S} seconds offroad time")
self.assertTrue(pm.should_shutdown(ignition, in_car,
offroad_timestamp,
self.assertTrue(pm.should_shutdown(ignition, in_car,
offroad_timestamp,
started_seen),
f"Should shutdown after {DELAY_SHUTDOWN_TIME_S} seconds offroad time")

@ -444,7 +444,7 @@ def main() -> None:
if not system_time_valid():
wait_helper.sleep(60)
continue
update_failed_count += 1
# check for update

@ -255,7 +255,7 @@ position_report = """
uint32 q_FltRawAlt; /* Raw height-above-ellipsoid altitude in meters as computed by WLS */
uint32 q_FltRawAltSigma; /* Gaussian 1-sigma value for raw height-above-ellipsoid altitude in meters */
uint32 align_Flt[14];
uint32 q_FltPdop; /* 3D position dilution of precision as computed from the unweighted
uint32 q_FltPdop; /* 3D position dilution of precision as computed from the unweighted
uint32 q_FltHdop; /* Horizontal position dilution of precision as computed from the unweighted least-squares covariance matrix */
uint32 q_FltVdop; /* Vertical position dilution of precision as computed from the unweighted least-squares covariance matrix */
uint8 u_EllipseConfidence; /* Statistical measure of the confidence (percentage) associated with the uncertainty ellipse values */

Loading…
Cancel
Save