process_replay: ignore unknown members in the migration code (#34382)

* Fix the migration for the events

* clean up

clean up

clean up

* no continue

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
migration-strict-mode
Kacper Rączy 3 months ago committed by GitHub
parent 8eebce75ac
commit ea4a127ab8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 31
      selfdrive/test/process_replay/migration.py

@ -1,7 +1,8 @@
from collections import defaultdict from collections import defaultdict
from collections.abc import Callable from collections.abc import Callable
import functools
import capnp import capnp
import functools
import traceback
from cereal import messaging, car, log from cereal import messaging, car, log
from opendbc.car.fingerprints import MIGRATION from opendbc.car.fingerprints import MIGRATION
@ -424,13 +425,19 @@ def migrate_sensorEvents(msgs):
def migrate_onroadEvents(msgs): def migrate_onroadEvents(msgs):
ops = [] ops = []
for index, msg in msgs: for index, msg in msgs:
onroadEvents = []
for event in msg.onroadEventsDEPRECATED:
try:
if not str(event.name).endswith('DEPRECATED'):
# dict converts name enum into string representation
onroadEvents.append(log.OnroadEvent(**event.to_dict()))
except RuntimeError: # Member was null
traceback.print_exc()
new_msg = messaging.new_message('onroadEvents', len(msg.onroadEventsDEPRECATED)) new_msg = messaging.new_message('onroadEvents', len(msg.onroadEventsDEPRECATED))
new_msg.valid = msg.valid new_msg.valid = msg.valid
new_msg.logMonoTime = msg.logMonoTime new_msg.logMonoTime = msg.logMonoTime
new_msg.onroadEvents = onroadEvents
# dict converts name enum into string representation
new_msg.onroadEvents = [log.OnroadEvent(**event.to_dict()) for event in msg.onroadEventsDEPRECATED if
not str(event.name).endswith('DEPRECATED')]
ops.append((index, new_msg.as_reader())) ops.append((index, new_msg.as_reader()))
return ops, [], [] return ops, [], []
@ -441,10 +448,16 @@ def migrate_driverMonitoringState(msgs):
ops = [] ops = []
for index, msg in msgs: for index, msg in msgs:
msg = msg.as_builder() msg = msg.as_builder()
# dict converts name enum into string representation events = []
msg.driverMonitoringState.events = [log.OnroadEvent(**event.to_dict()) for event in for event in msg.driverMonitoringState.eventsDEPRECATED:
msg.driverMonitoringState.eventsDEPRECATED if try:
not str(event.name).endswith('DEPRECATED')] if not str(event.name).endswith('DEPRECATED'):
# dict converts name enum into string representation
events.append(log.OnroadEvent(**event.to_dict()))
except RuntimeError: # Member was null
traceback.print_exc()
msg.driverMonitoringState.events = events
ops.append((index, msg.as_reader())) ops.append((index, msg.as_reader()))
return ops, [], [] return ops, [], []

Loading…
Cancel
Save