IQ.Pilot Release Commit @ d23cc80

This commit is contained in:
IQ.Lvbs CI [bot]
2026-07-27 18:01:16 -05:00
parent 46277b19ec
commit a70938008a
74 changed files with 715 additions and 1296 deletions

View File

@@ -12,11 +12,11 @@ _ANGLE = _dbc.CarParams.SteerControlType.angle
# Port tunables surfaced to the fingerprint step, flat so the read is one pass.
_TUNABLES = (
"HyundaiLongitudinalTuning",
"SubaruStopAndGo",
"SubaruStopAndGoManualParkingBrake",
"TeslaCoopSteering",
"ToyotaEnforceStockLongitudinal",
"IQHyundaiLongTune",
"IQSubaruCreepAssist",
"IQSubaruCreepAssistManualBrake",
"IQTeslaTorqueBlend",
"IQToyotaFactoryLong",
"ToyotaSnGHack",
)

View File

@@ -81,5 +81,5 @@ def _write(vehicles: dict[str, dict], basedir: str = BASEDIR) -> str:
if __name__ == "__main__":
from iqdbc.lvbs.car.platform_list import get_car_list
print("wrote", _write(get_car_list()))
from iqdbc.lvbs.car.car_catalog import build_car_catalog
print("wrote", _write(build_car_catalog()))

View File

@@ -43,6 +43,7 @@ from openpilot.iqpilot.selfdrive.iqmodeld.models.helpers import (
bundle_files_ready,
get_active_bundle,
get_runtime_bundle_upgrade,
is_default_bundle,
persist_active_bundle,
)
@@ -56,6 +57,7 @@ class IQModelManager(_BaseIQModelManager):
def __init__(self):
super().__init__()
self._validated_active_key: tuple[tuple[str, str], ...] | None = None
self._manifest_refresh_key: tuple[tuple[str, str], ...] | None = None
@staticmethod
def _bundle_index(bundle) -> int | None:
@@ -190,6 +192,58 @@ class IQModelManager(_BaseIQModelManager):
if bundle_index is not None and self._download_index() is None:
self.params.put(_DOWNLOAD_INDEX_KEY, bundle_index)
def _find_manifest_counterpart(self, target):
# never match by index: indexes shift between manifest generations, and a
# positional match could redownload a different model than the user selected
for attr in ("ref", "internalName", "displayName"):
value = getattr(target, attr, None)
if not value:
continue
for bundle in self.available_models:
if getattr(bundle, attr, None) == value:
return bundle
return None
def _queue_active_manifest_refresh(self) -> None:
active = self.active_bundle
if active is None or is_default_bundle(active):
return
if self._download_index() is not None:
return
counterpart = self._find_manifest_counterpart(active)
if counterpart is None:
return
counterpart_index = self._bundle_index(counterpart)
if counterpart_index is None:
return
active_files = dict(self._bundle_files(active))
stale = False
for filename, sha in self._bundle_files(counterpart):
if not sha:
continue
active_sha = active_files.get(filename)
# an empty recorded hash can't prove a mismatch, so it never triggers a redownload
if active_sha is None or (active_sha and active_sha.lower() != sha.lower()):
stale = True
break
if not stale:
self._manifest_refresh_key = None
return
# the manifest may be an expired offline cache, so keep the active bundle and its
# files in place: the download flow replaces artifacts atomically and only persists
# the counterpart as active once everything landed. One attempt per bundle per run
# so a dead network doesn't turn the 1Hz loop into a download-retry storm.
key = self._bundle_validation_key(active)
if key == self._manifest_refresh_key:
return
self._manifest_refresh_key = key
cloudlog.warning(f"Active model {_display_bundle_name(active)} artifacts are stale vs current manifest; queueing redownload")
self.params.put(_DOWNLOAD_INDEX_KEY, counterpart_index)
async def _download_file(self, url: str, path: str, model) -> None:
temp_path = f"{path}.download"
self._download_start_times[model.fileName] = time.monotonic()
@@ -302,6 +356,7 @@ class IQModelManager(_BaseIQModelManager):
self.active_bundle = get_active_bundle(self.params)
self._queue_active_redownload_if_invalid()
self._queue_tinygrad_upgrade()
self._queue_active_manifest_refresh()
if (index_to_download := self._download_index()) is not None:
if model_to_download := next((model for model in self.available_models if model.index == index_to_download), None):

View File

@@ -0,0 +1,150 @@
"""
Copyright (c) IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
"""
from dataclasses import dataclass, field
from openpilot.iqpilot.selfdrive.iqmodeld.models.manager import IQModelManager, _DOWNLOAD_INDEX_KEY
@dataclass
class _DownloadUri:
sha256: str = ""
uri: str = ""
@dataclass
class _Artifact:
fileName: str = ""
downloadUri: _DownloadUri = field(default_factory=_DownloadUri)
@dataclass
class _Model:
artifact: _Artifact = field(default_factory=_Artifact)
metadata: _Artifact | None = None
@dataclass
class _Bundle:
index: int = 0
ref: str = ""
internalName: str = ""
displayName: str = ""
models: list = field(default_factory=list)
class _FakeParams:
def __init__(self):
self.store = {}
def get(self, key):
return self.store.get(key)
def put(self, key, value):
self.store[key] = value
def remove(self, key):
self.store.pop(key, None)
def _bundle(index, name, sha, filename="driving_vision_test_tinygrad.pkl"):
return _Bundle(
index=index,
ref=f"ref-{name}",
internalName=name,
displayName=f"{name} display",
models=[_Model(artifact=_Artifact(fileName=filename, downloadUri=_DownloadUri(sha256=sha)))],
)
def _manager(active, available):
mgr = IQModelManager.__new__(IQModelManager)
mgr.params = _FakeParams()
mgr.active_bundle = active
mgr.available_models = available
mgr._validated_active_key = None
mgr._manifest_refresh_key = None
return mgr
def test_stale_active_bundle_queues_redownload_at_current_index():
active = _bundle(55, "WMIV12", "a" * 64)
counterpart = _bundle(12, "WMIV12", "b" * 64)
mgr = _manager(active, [counterpart])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 12
assert mgr.active_bundle is active
def test_matching_shas_do_not_queue():
active = _bundle(55, "WMIV12", "a" * 64)
counterpart = _bundle(12, "WMIV12", "A" * 64)
mgr = _manager(active, [counterpart])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
def test_retired_bundle_is_left_alone():
active = _bundle(55, "WMIV12", "a" * 64)
mgr = _manager(active, [_bundle(12, "OtherModel", "b" * 64)])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
assert mgr.active_bundle is active
def test_default_bundle_is_never_refreshed():
active = _bundle(0, "Default", "a" * 64)
active.ref = "default"
mgr = _manager(active, [_bundle(0, "Default", "b" * 64)])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
def test_pending_download_blocks_refresh():
active = _bundle(55, "WMIV12", "a" * 64)
mgr = _manager(active, [_bundle(12, "WMIV12", "b" * 64)])
mgr.params.put(_DOWNLOAD_INDEX_KEY, 3)
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 3
def test_empty_manifest_hash_never_triggers():
active = _bundle(55, "WMIV12", "a" * 64)
mgr = _manager(active, [_bundle(12, "WMIV12", "")])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
def test_refresh_queued_once_per_run():
active = _bundle(55, "WMIV12", "a" * 64)
mgr = _manager(active, [_bundle(12, "WMIV12", "b" * 64)])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 12
mgr.params.remove(_DOWNLOAD_INDEX_KEY)
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) is None
def test_counterpart_matched_by_name_not_index():
active = _bundle(55, "WMIV12", "a" * 64)
imposter = _bundle(55, "OtherModel", "c" * 64)
counterpart = _bundle(12, "WMIV12", "b" * 64)
mgr = _manager(active, [imposter, counterpart])
mgr._queue_active_manifest_refresh()
assert mgr.params.get(_DOWNLOAD_INDEX_KEY) == 12

View File

@@ -337,6 +337,13 @@ _NOTICE_EVENTS: EVENTS_IQ_TYPE = {
Priority.MID, VisualAlert.none, AudibleAlert.prompt, 3.),
},
# outranks the generic processNotRunning alert so the driver sees why engagement is blocked
EventNameIQ.modelUpdating: {
ET.NO_ENTRY: NoEntryAlert("Update finishes while parked with internet",
alert_text_1="Driving Model Updating",
priority=Priority.MID),
},
}
EVENTS_IQ: EVENTS_IQ_TYPE = {**_GUIDANCE_EVENTS, **_ENGAGE_EVENTS, **_CABIN_BLOCK_EVENTS, **_NOTICE_EVENTS}