diff --git a/openpilot/sunnypilot/models/manager.py b/openpilot/sunnypilot/models/manager.py index 7ba805ff95..8ca8775875 100644 --- a/openpilot/sunnypilot/models/manager.py +++ b/openpilot/sunnypilot/models/manager.py @@ -143,13 +143,17 @@ class ModelManagerSP: is_cached = False if len(artifact.chunks) > 0: from openpilot.common.file_chunker import get_chunk_name + num_chunks = len(artifact.chunks) chunks_valid = True for i, chunk in enumerate(artifact.chunks): - chunk_path = get_chunk_name(full_path, i, len(artifact.chunks)) + chunk_path = get_chunk_name(full_path, i, num_chunks) if not await verify_file(chunk_path, chunk.sha256): chunks_valid = False break - if chunks_valid and len(artifact.chunks) > 0: + artifact.downloadProgress.progress = ((i + 1) / num_chunks) * 100 + self._sync_artifact_progress(artifact) + self._report_status() + if chunks_valid and num_chunks > 0: is_cached = True else: if await verify_file(full_path, expected_hash): @@ -216,6 +220,9 @@ class ModelManagerSP: """Downloads all models in a bundle""" self.selected_bundle = model_bundle self.selected_bundle.status = custom.ModelManagerSP.DownloadStatus.downloading + for model in self.selected_bundle.models: + model.artifact.downloadProgress.status = custom.ModelManagerSP.DownloadStatus.downloading + self._report_status() os.makedirs(destination_path, exist_ok=True) try: @@ -260,7 +267,9 @@ class ModelManagerSP: self.active_bundle = get_active_bundle(self.params) if (index_to_download := self.params.get("ModelManager_DownloadIndex")) is not None: - if model_to_download := next((model for model in self.available_models if model.index == index_to_download), None): + if self.active_bundle and self.active_bundle.index == index_to_download: + self.params.remove("ModelManager_DownloadIndex") + elif model_to_download := next((model for model in self.available_models if model.index == index_to_download), None): try: self.download(model_to_download, Paths.model_root()) except Exception as e: diff --git a/openpilot/sunnypilot/sunnylink/athena/sunnylinkd.py b/openpilot/sunnypilot/sunnylink/athena/sunnylinkd.py index c0534a76bf..27be6e24ed 100755 --- a/openpilot/sunnypilot/sunnylink/athena/sunnylinkd.py +++ b/openpilot/sunnypilot/sunnylink/athena/sunnylinkd.py @@ -28,7 +28,8 @@ from websocket import (ABNF, WebSocket, WebSocketException, WebSocketTimeoutExce create_connection, WebSocketConnectionClosedException) import openpilot.cereal.messaging as messaging -from openpilot.sunnypilot.models.default_model import get_default_model +from openpilot.selfdrive.modeld.helpers import usbgpu_present, usbgpu_compiled +from openpilot.sunnypilot.models.model_name import DEFAULT_MODEL, DEFAULT_BIG_MODEL from openpilot.sunnypilot.selfdrive.car.sync_sunnylink_params import update_car_list_param from openpilot.sunnypilot.sunnylink.api import SunnylinkApi from openpilot.sunnypilot.sunnylink.utils import sunnylink_need_register, sunnylink_ready, get_param_as_byte, save_param_from_base64_encoded_string @@ -181,7 +182,10 @@ def getParamsMetadata() -> str: schema = generate_schema() schema["capabilities"] = generate_capabilities() schema["capability_labels"] = CAPABILITY_LABELS - schema["default_model"] = get_default_model() + # mirrors get_default_model() — ui_state unavailable in sunnylinkd process + show_big = (usbgpu_present() and usbgpu_compiled() + and (params.get_bool("UsbGpuActive") or params.get_bool("UsbGpuLoading") or params.get_bool("IsOffroad"))) + schema["default_model"] = DEFAULT_BIG_MODEL if show_big else DEFAULT_MODEL raw = json.dumps(schema, separators=(",", ":")).encode("utf-8") return base64.b64encode(gzip.compress(raw)).decode("utf-8") except Exception: