mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-15 03:53:58 +08:00
stop lying on my chestnut
This commit is contained in:
committed by
firestar5683
parent
688631b6bd
commit
7a7b391656
@@ -265,6 +265,25 @@ def model_accelerator_artifact_installed(model_key: str, accelerator: str = MODE
|
||||
)
|
||||
|
||||
|
||||
def selected_chestnut_artifacts_ready(params) -> bool:
|
||||
"""Return whether the selected Chestnut workload is installed for offroad diagnostics."""
|
||||
big_model_id, _, _ = get_model_profile(params, "big")
|
||||
if big_model_id and file_chunked_exists(MODELS_PATH / driving_artifact_filename(big_model_id)):
|
||||
return True
|
||||
|
||||
config = load_model_lab_config(params)
|
||||
lateral_model_id = canonical_model_key(config["lateralModel"])
|
||||
longitudinal_model_id = canonical_model_key(config["longitudinalModel"])
|
||||
return bool(
|
||||
config["enabled"] and
|
||||
lateral_model_id and
|
||||
longitudinal_model_id and
|
||||
lateral_model_id != longitudinal_model_id and
|
||||
model_accelerator_artifact_installed(lateral_model_id) and
|
||||
model_accelerator_artifact_installed(longitudinal_model_id)
|
||||
)
|
||||
|
||||
|
||||
def external_gpu_available() -> bool:
|
||||
"""Return whether the supported external GPU link is ready for modeld."""
|
||||
try:
|
||||
|
||||
@@ -211,6 +211,61 @@ def test_disabled_big_profile_does_not_migrate_from_legacy_selection(tmp_path, m
|
||||
assert "ActiveBigModelVersion" not in params.values
|
||||
|
||||
|
||||
def test_selected_chestnut_artifacts_ready_ignores_cleared_runtime_flag(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(model_manager, "MODELS_PATH", tmp_path)
|
||||
(tmp_path / model_manager.ARTIFACT_METADATA_CACHE).write_text(json.dumps({
|
||||
"big-one": {"uses_external_gpu": True},
|
||||
}))
|
||||
(tmp_path / "big-one_driving_tinygrad.pkl").write_bytes(b"compiled")
|
||||
|
||||
class FakeParams:
|
||||
def __init__(self):
|
||||
self.values = {
|
||||
"ActiveBigModel": "big-one",
|
||||
"ActiveBigModelName": "Big One",
|
||||
"ActiveBigModelVersion": "v16",
|
||||
"UsbGpuCompiled": False,
|
||||
}
|
||||
|
||||
def get(self, key):
|
||||
return self.values.get(key)
|
||||
|
||||
params = FakeParams()
|
||||
assert not params.get("UsbGpuCompiled")
|
||||
assert model_manager.selected_chestnut_artifacts_ready(params)
|
||||
|
||||
(tmp_path / "big-one_driving_tinygrad.pkl").unlink()
|
||||
assert not model_manager.selected_chestnut_artifacts_ready(params)
|
||||
|
||||
|
||||
def test_selected_chestnut_artifacts_ready_accepts_model_lab_pair(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(model_manager, "MODELS_PATH", tmp_path)
|
||||
(tmp_path / model_manager.ARTIFACT_METADATA_CACHE).write_text(json.dumps({
|
||||
model_id: {
|
||||
"uses_external_gpu": False,
|
||||
"accelerator_artifacts": {"chestnut": {"execution_device": "AMD"}},
|
||||
}
|
||||
for model_id in ("lateral", "longitudinal")
|
||||
}))
|
||||
for model_id in ("lateral", "longitudinal"):
|
||||
(tmp_path / f"{model_id}_driving_chestnut_tinygrad.pkl").write_bytes(b"compiled")
|
||||
|
||||
class FakeParams:
|
||||
def get(self, key):
|
||||
return {
|
||||
"ActiveBigModel": "none",
|
||||
"ModelLabConfig": {
|
||||
"enabled": True,
|
||||
"lateralModel": "lateral",
|
||||
"longitudinalModel": "longitudinal",
|
||||
},
|
||||
}.get(key)
|
||||
|
||||
assert model_manager.selected_chestnut_artifacts_ready(FakeParams())
|
||||
(tmp_path / "longitudinal_driving_chestnut_tinygrad.pkl").unlink()
|
||||
assert not model_manager.selected_chestnut_artifacts_ready(FakeParams())
|
||||
|
||||
|
||||
def test_runtime_model_metadata_does_not_overwrite_model_profiles(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(model_manager, "MODELS_PATH", tmp_path)
|
||||
(tmp_path / model_manager.ARTIFACT_METADATA_CACHE).write_text(json.dumps({
|
||||
|
||||
@@ -39,6 +39,7 @@ from openpilot.system.hardware.chestnut.status import ChestnutStatus
|
||||
from openpilot.system.version import terms_version, training_version
|
||||
from openpilot.system.athena.registration import UNREGISTERED_DONGLE_ID
|
||||
|
||||
from openpilot.starpilot.assets.model_manager import selected_chestnut_artifacts_ready
|
||||
from openpilot.starpilot.common.starpilot_variables import get_starpilot_toggles
|
||||
|
||||
ThermalStatus = log.DeviceState.ThermalStatus
|
||||
@@ -434,6 +435,9 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
)
|
||||
chestnut_state = sm["chestnutState"]
|
||||
chestnut_valid = sm.alive["chestnutState"] and sm.valid["chestnutState"]
|
||||
compiled = params.get_bool("UsbGpuCompiled")
|
||||
if started_ts is None:
|
||||
compiled = selected_chestnut_artifacts_ready(params)
|
||||
chestnut_status.update(
|
||||
started_ts is None,
|
||||
chestnut_expected,
|
||||
@@ -441,7 +445,7 @@ def hardware_thread(end_event, hw_queue) -> None:
|
||||
chestnut.failed,
|
||||
params.get_bool("UsbGpuLoading"),
|
||||
params.get("UsbGpuActive"),
|
||||
params.get_bool("UsbGpuCompiled"),
|
||||
compiled,
|
||||
chestnut_state if chestnut_valid else None,
|
||||
set_offroad_alert_if_changed,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user