ui: Display default driving model name (#623)
* ui: Display default driving model if in use * add ref commit and tests * fix commit * update msg * update msg * fix lint * use sha256 hash instead
This commit is contained in:
1
common/model.h
Normal file
1
common/model.h
Normal file
@@ -0,0 +1 @@
|
||||
#define DEFAULT_MODEL "Notre Dame (Default)"
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <algorithm>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "common/model.h"
|
||||
|
||||
/**
|
||||
* @brief Constructs the software panel with model bundle selection functionality
|
||||
* @param parent Parent widget
|
||||
@@ -105,7 +107,7 @@ QString SoftwarePanelSP::GetActiveModelName() {
|
||||
return QString::fromStdString(model_manager.getActiveBundle().getDisplayName());
|
||||
}
|
||||
|
||||
return "";
|
||||
return DEFAULT_MODEL;
|
||||
}
|
||||
|
||||
void SoftwarePanelSP::updateModelManagerState() {
|
||||
|
||||
1
sunnypilot/modeld/tests/model_hash
Normal file
1
sunnypilot/modeld/tests/model_hash
Normal file
@@ -0,0 +1 @@
|
||||
39786068cae1ed8c0dc34ef80c281dfcc67ed18a50e06b90765c49bcfdbf7db4
|
||||
34
sunnypilot/modeld/tests/test_default_model.py
Normal file
34
sunnypilot/modeld/tests/test_default_model.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
|
||||
MODEL_HASH_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
class TestDefaultModel:
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
cls.onnx_path = os.path.join(BASEDIR, "selfdrive", "modeld", "models", "supercombo.onnx")
|
||||
cls.current_hash_path = os.path.join(MODEL_HASH_DIR, "model_hash")
|
||||
|
||||
@staticmethod
|
||||
def get_hash(path: str) -> str:
|
||||
sha256_hash = hashlib.sha256()
|
||||
with open(path, "rb") as f:
|
||||
for byte_block in iter(lambda: f.read(4096), b""):
|
||||
sha256_hash.update(byte_block)
|
||||
return sha256_hash.hexdigest()
|
||||
|
||||
def test_compare_onnx_hashes(self):
|
||||
new_hash = self.get_hash(str(self.onnx_path))
|
||||
|
||||
with open(self.current_hash_path) as f:
|
||||
current_hash = f.read().strip()
|
||||
|
||||
assert new_hash == current_hash, (
|
||||
"Driving model updated!\n" +
|
||||
f"Current hash: {current_hash}\n" +
|
||||
f"New hash: {new_hash}\n" +
|
||||
"Please update common/model.h if the default driving model name has changed."
|
||||
)
|
||||
Reference in New Issue
Block a user