mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
day2
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -250,6 +250,21 @@ def migrate_param_type_canonicalization(params: Params) -> None:
|
||||
cloudlog.exception(f"Failed to write migration flag: {STARPILOT_PARAM_CANONICALIZATION_MIGRATION_FLAG}")
|
||||
|
||||
|
||||
def migrate_legacy_experimental_longitudinal(params: Params, params_cache: Params) -> None:
|
||||
legacy_value = params.get("ExperimentalLongitudinalEnabled")
|
||||
if legacy_value is None:
|
||||
return
|
||||
|
||||
if params.get("AlphaLongitudinalEnabled") is None:
|
||||
alpha_long_enabled = params.get_bool("ExperimentalLongitudinalEnabled")
|
||||
params.put_bool("AlphaLongitudinalEnabled", alpha_long_enabled)
|
||||
params_cache.put_bool("AlphaLongitudinalEnabled", alpha_long_enabled)
|
||||
cloudlog.warning("Migrated legacy ExperimentalLongitudinalEnabled to AlphaLongitudinalEnabled")
|
||||
|
||||
params.remove("ExperimentalLongitudinalEnabled")
|
||||
params_cache.remove("ExperimentalLongitudinalEnabled")
|
||||
|
||||
|
||||
def manager_init() -> None:
|
||||
save_bootlog()
|
||||
|
||||
@@ -272,6 +287,9 @@ def manager_init() -> None:
|
||||
cache_params_path = os.path.join(Paths.comma_home(), "cache", "params")
|
||||
params_cache = Params(cache_params_path, return_defaults=True)
|
||||
|
||||
# Preserve StarPilot's legacy longitudinal toggle when switching branches.
|
||||
migrate_legacy_experimental_longitudinal(params, params_cache)
|
||||
|
||||
# Canonicalize legacy string encodings (e.g. INT params stored as "26.000000")
|
||||
# before bulk reads below to avoid repeated cast warnings and UI-side churn.
|
||||
migrate_param_type_canonicalization(params)
|
||||
|
||||
@@ -51,6 +51,40 @@ class TestManager:
|
||||
assert params.get("OpenpilotEnabledToggle")
|
||||
assert params.get("RouteCount") == 0
|
||||
|
||||
def test_migrate_legacy_experimental_longitudinal(self):
|
||||
class FakeParams:
|
||||
def __init__(self, values):
|
||||
self.values = dict(values)
|
||||
|
||||
def get(self, key):
|
||||
return self.values.get(key)
|
||||
|
||||
def get_bool(self, key):
|
||||
value = self.values.get(key)
|
||||
if value is None:
|
||||
return False
|
||||
if isinstance(value, bytes):
|
||||
value = value.decode("utf-8", errors="ignore")
|
||||
if isinstance(value, str):
|
||||
return value.strip().lower() in ("1", "true", "yes", "on")
|
||||
return bool(value)
|
||||
|
||||
def put_bool(self, key, value):
|
||||
self.values[key] = b"1" if value else b"0"
|
||||
|
||||
def remove(self, key):
|
||||
self.values.pop(key, None)
|
||||
|
||||
params = FakeParams({"ExperimentalLongitudinalEnabled": b"1"})
|
||||
params_cache = FakeParams({})
|
||||
|
||||
manager.migrate_legacy_experimental_longitudinal(params, params_cache)
|
||||
|
||||
assert params.get_bool("AlphaLongitudinalEnabled")
|
||||
assert params_cache.get_bool("AlphaLongitudinalEnabled")
|
||||
assert params.get("ExperimentalLongitudinalEnabled") is None
|
||||
assert params_cache.get("ExperimentalLongitudinalEnabled") is None
|
||||
|
||||
@pytest.mark.skip("this test is flaky the way it's currently written, should be moved to test_onroad")
|
||||
def test_clean_exit(self, subtests):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user