mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 03:13:48 +08:00
Coast Toggle
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -36,6 +36,7 @@ LEGACY_BOLT_FP_MIGRATION_FLAG = Path("/data") / "legacy_bolt_fp_migration_v1"
|
||||
STARPILOT_DEFAULTS_PARITY_MIGRATION_FLAG = Path("/data") / "starpilot_defaults_parity_v1"
|
||||
STARPILOT_HUMANLIKE_DISABLE_MIGRATION_FLAG = Path("/data") / "starpilot_humanlike_disable_v1"
|
||||
STARPILOT_CLUSTER_OFFSET_MIGRATION_FLAG = Path("/data") / "starpilot_cluster_offset_v1"
|
||||
STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG = Path("/data") / "starpilot_coast_up_to_leads_v1"
|
||||
STARPILOT_PARAM_RENAME_MIGRATION_FLAG = Path("/data") / "starpilot_param_rename_v1"
|
||||
STARPILOT_PARAM_CANONICALIZATION_MIGRATION_FLAG = Path("/data") / "starpilot_param_canonicalization_v1"
|
||||
STARPILOT_PC_ROOT_MIGRATION_FLAG = Path("/data") / "starpilot_pc_root_v1"
|
||||
@@ -433,6 +434,22 @@ def migrate_cluster_offset_default(params: Params, params_cache: Params) -> None
|
||||
cloudlog.exception(f"Failed to write migration flag: {STARPILOT_CLUSTER_OFFSET_MIGRATION_FLAG}")
|
||||
|
||||
|
||||
def migrate_coast_up_to_leads_default(params: Params, params_cache: Params) -> None:
|
||||
if STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG.exists():
|
||||
return
|
||||
|
||||
if not _has_persisted_param_file(params, "CoastUpToLeads") and not _has_persisted_param_file(params_cache, "CoastUpToLeads"):
|
||||
params.put_bool("CoastUpToLeads", True)
|
||||
params_cache.put_bool("CoastUpToLeads", True)
|
||||
cloudlog.warning("Seeded CoastUpToLeads to default enabled")
|
||||
|
||||
try:
|
||||
STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG.parent.mkdir(parents=True, exist_ok=True)
|
||||
STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG.write_text(f"{datetime.datetime.now(datetime.UTC).isoformat()}\n")
|
||||
except Exception:
|
||||
cloudlog.exception(f"Failed to write migration flag: {STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG}")
|
||||
|
||||
|
||||
def _read_raw_param_bytes(params: Params, key: str | bytes):
|
||||
try:
|
||||
path = params.get_param_path(key)
|
||||
@@ -601,6 +618,7 @@ def manager_init() -> None:
|
||||
migrate_starpilot_default_parity(params, params_cache)
|
||||
migrate_disable_humanlike_defaults(params, params_cache)
|
||||
migrate_cluster_offset_default(params, params_cache)
|
||||
migrate_coast_up_to_leads_default(params, params_cache)
|
||||
|
||||
# set unset params to their default value
|
||||
for k in params.all_keys():
|
||||
|
||||
@@ -217,6 +217,29 @@ class TestManager:
|
||||
assert params.get("ClusterOffset") == "1.02"
|
||||
assert params_cache.get("ClusterOffset") is None
|
||||
|
||||
def test_migrate_coast_up_to_leads_default_seeds_enabled(self, tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(manager, "STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG", tmp_path / "starpilot_coast_up_to_leads_v1")
|
||||
|
||||
params = FileBackedFakeParams(tmp_path / "params", {})
|
||||
params_cache = FileBackedFakeParams(tmp_path / "cache", {})
|
||||
|
||||
manager.migrate_coast_up_to_leads_default(params, params_cache)
|
||||
|
||||
assert params.get_bool("CoastUpToLeads")
|
||||
assert params_cache.get_bool("CoastUpToLeads")
|
||||
|
||||
def test_migrate_coast_up_to_leads_default_preserves_existing_values(self, tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(manager, "STARPILOT_COAST_UP_TO_LEADS_MIGRATION_FLAG", tmp_path / "starpilot_coast_up_to_leads_v1")
|
||||
|
||||
params = FileBackedFakeParams(tmp_path / "params", {
|
||||
"CoastUpToLeads": False,
|
||||
})
|
||||
params_cache = FileBackedFakeParams(tmp_path / "cache", {})
|
||||
|
||||
manager.migrate_coast_up_to_leads_default(params, params_cache)
|
||||
|
||||
assert not params.get_bool("CoastUpToLeads")
|
||||
|
||||
@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