mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-30 00:33:41 +08:00
Keep FLM profile suggestions separate from automatic fit eligibility
This commit is contained in:
@@ -969,12 +969,12 @@ class OffroadWorker:
|
||||
continue
|
||||
report.setdefault('original_source_requalification', []).append(contract)
|
||||
for cohort in group['cohorts']:
|
||||
if not all(role in cohort for role in ('training', 'heldout')):
|
||||
continue
|
||||
if 'qualification_roles' in cohort and any(len(cohort['qualification_roles'][role]['windows']) < 3 for role in ('training', 'heldout')):
|
||||
if not all(3 <= len(cohort.get(role, {}).get('windows', ())) <= 12 for role in ('training', 'heldout')):
|
||||
continue
|
||||
proposal, proof = selector.propose(group, cohort)
|
||||
report['stable_profile_reports'].append({'context': group['original_context_sha256'], 'cohort': cohort['cohort'], **proof})
|
||||
if 'qualification_roles' in cohort and any(len(cohort['qualification_roles'][role]['windows']) < 3 for role in ('training', 'heldout')):
|
||||
continue # Keep the observed suggestion; do not enqueue an automatic fit.
|
||||
if proposal is not None:
|
||||
choices.append((group, {**cohort, 'stable_profile_proof': proof}, proposal))
|
||||
for alternative in proof.get('coordinate_candidates', []):
|
||||
@@ -994,13 +994,13 @@ class OffroadWorker:
|
||||
for cohort in group['cohorts']:
|
||||
if cohort['cohort'].rsplit(':', 1)[-1] not in ('steady', 'turn_in', 'unwind'):
|
||||
continue
|
||||
if not all(role in cohort for role in ('training', 'heldout')):
|
||||
continue
|
||||
roles = cohort.get('qualification_roles', cohort)
|
||||
if any(not 3 <= len(roles[role]['windows']) <= 12 for role in ('training', 'heldout')):
|
||||
if not all(3 <= len(cohort.get(role, {}).get('windows', ())) <= 12 for role in ('training', 'heldout')):
|
||||
continue
|
||||
_, proof = selector.propose(group, cohort)
|
||||
report['short_turn_profile_reports'].append({'context': group['original_context_sha256'], 'cohort': cohort['cohort'], **proof})
|
||||
roles = cohort.get('qualification_roles', cohort)
|
||||
if any(not 3 <= len(roles[role]['windows']) <= 12 for role in ('training', 'heldout')):
|
||||
continue
|
||||
for alternative in proof.get('coordinate_candidates', []):
|
||||
choices.append((group, {**cohort, 'stable_profile_proof': proof}, alternative))
|
||||
|
||||
|
||||
@@ -702,7 +702,7 @@ class TestShortTurnProposalCoverage(unittest.TestCase):
|
||||
self.assertEqual(set(selector.spans), {w['identity'] for g in (short, stable) for w in g['selected_original_windows']})
|
||||
self.assertEqual(len(selector.spans), 12)
|
||||
|
||||
def dispatch(self, *, training_count=3, overlap=False):
|
||||
def dispatch(self, *, training_count=3, overlap=False, native_count=None):
|
||||
from types import SimpleNamespace
|
||||
from openpilot.starpilot.flm import offroad_worker as module
|
||||
from openpilot.starpilot.flm.offroad_processor import CompletedAssessment
|
||||
@@ -713,6 +713,8 @@ class TestShortTurnProposalCoverage(unittest.TestCase):
|
||||
roles = {'training': {'windows': ids[:training_count], 'reference_rms': 0.1}, 'heldout': {'windows': ids[3:], 'reference_rms': 0.1}}
|
||||
metadata = {'route_values': tuple(values().items()), 'route_revision': REVISION, 'controller_mode': 'starpilot', 'route_scope': scope().key()}
|
||||
short = {'cohort': '2:left:turn_in', 'whole_windows': 6, 'proposal': None, **roles}
|
||||
if native_count is not None:
|
||||
short['qualification_roles'] = {'training': {'windows': ids[:training_count][:native_count]}, 'heldout': {'windows': ids[3:][:native_count]}}
|
||||
original = [{'identity': wid, 'segment': 0, 'start_ns': (100 + i * 10) * 10**9, 'end_ns': (102 + i * 10) * 10**9} for i, wid in enumerate(ids)]
|
||||
group = {'original_metadata': metadata, 'original_context_sha256': 'f' * 64, 'cohorts': [short], 'selected_original_windows': original}
|
||||
selected = values()
|
||||
@@ -724,6 +726,8 @@ class TestShortTurnProposalCoverage(unittest.TestCase):
|
||||
long_ids = tuple(str(i) * 64 for i in range(1, 7))
|
||||
long_roles = {'training': {'windows': long_ids[:3], 'reference_rms': 0.6}, 'heldout': {'windows': long_ids[3:], 'reference_rms': 0.6}}
|
||||
long_cohort = {'cohort': '2:both:center', 'whole_windows': 6, **long_roles}
|
||||
if native_count is not None:
|
||||
long_cohort['qualification_roles'] = {'training': {'windows': long_ids[:3][:native_count]}, 'heldout': {'windows': long_ids[3:][:native_count]}}
|
||||
long_original = [{'identity': wid, 'segment': 0, 'start_ns': i * 10**10, 'end_ns': i * 10**10 + 6 * 10**9} for i, wid in enumerate(long_ids)]
|
||||
stable_groups = (dict(group, cohorts=[long_cohort], selected_original_windows=long_original),)
|
||||
for i in range(3):
|
||||
@@ -740,9 +744,11 @@ class TestShortTurnProposalCoverage(unittest.TestCase):
|
||||
|
||||
def propose(self, actual_group, cohort):
|
||||
events.append(('profile', cohort['cohort']))
|
||||
proof = {'coordinate_candidates': [proposal], 'roles': {role: {'original_windows': cohort[role]['windows'],
|
||||
'coordinate_candidates': [proposal]} for role in ('training', 'heldout')}}
|
||||
if cohort['cohort'].endswith('center'):
|
||||
return proposal, {'coordinate_candidates': []}
|
||||
return None, {'coordinate_candidates': [proposal]}
|
||||
return proposal, dict(proof, frozen_training_profile=proposal, coordinate_candidates=[])
|
||||
return None, proof
|
||||
|
||||
def assessed(params, root, previous, *, permitted):
|
||||
previous(cp)
|
||||
@@ -776,6 +782,7 @@ class TestShortTurnProposalCoverage(unittest.TestCase):
|
||||
assessor=assessed, checker=refused, scope_for=lambda cp, params: scope()).run_once()
|
||||
self.assertFalse(result['configuration_changed'])
|
||||
self.assertIsNone(params.get(KEY), 'A proposal or mocked native refusal cannot save an automatic tune')
|
||||
self.last_result = result
|
||||
return events
|
||||
|
||||
def test_short_turn_reaches_original_native_refusal_only_with_both_full_partitions(self):
|
||||
|
||||
@@ -48,3 +48,16 @@ def test_checkpoint_never_fabricates_or_extends_preroll():
|
||||
outputs = [NS(control_ns=1_999_999_999, carrier_observed_ns=2_990_000_000)]
|
||||
assert original_checkpoint(controls, outputs, 3_000_000_000) is None
|
||||
assert original_checkpoint([], outputs, 3_000_000_000) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('stable', (False, True))
|
||||
def test_provisional_profiles_remain_visible_without_automatic_fit_partitions(stable):
|
||||
from openpilot.starpilot.flm.tests.test_offroad_coordinate_policy import TestShortTurnProposalCoverage
|
||||
|
||||
case = TestShortTurnProposalCoverage()
|
||||
events = case.dispatch(native_count=0, overlap=stable)
|
||||
assert events == ([('profile', '2:both:center')] if stable else []) + [('profile', '2:left:turn_in')]
|
||||
assert case.last_result['configuration_changed'] is False
|
||||
assert case.last_result['recommendation_count'] == 1
|
||||
assert case.last_result['recommendations'][0]['parameter'] == 'turn_in_boost_left'
|
||||
assert case.last_result['recommendations'][0]['target'] == .005
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "aa8ef45fd68935ebf9b0f9885dcc6862763a00b0f3fa35f7f69ccfc6e515ce6a", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "c5548704326c0edae2bccba640c5ed181b0ad99f017e42e613081355593f3412", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user