Skip to content

Commit

Permalink
process_replay: ignore unknown members in the migration code (#34382)
Browse files Browse the repository at this point in the history
* Fix the migration for the events

* clean up

clean up

clean up

* no continue

---------

Co-authored-by: Shane Smiskol <[email protected]>
  • Loading branch information
fredyshox and sshane authored Jan 15, 2025
1 parent 8eebce7 commit ea4a127
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions selfdrive/test/process_replay/migration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from collections import defaultdict
from collections.abc import Callable
import functools
import capnp
import functools
import traceback

from cereal import messaging, car, log
from opendbc.car.fingerprints import MIGRATION
Expand Down Expand Up @@ -424,13 +425,19 @@ def migrate_sensorEvents(msgs):
def migrate_onroadEvents(msgs):
ops = []
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.valid = msg.valid
new_msg.logMonoTime = msg.logMonoTime

# 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')]
new_msg.onroadEvents = onroadEvents
ops.append((index, new_msg.as_reader()))

return ops, [], []
Expand All @@ -441,10 +448,16 @@ def migrate_driverMonitoringState(msgs):
ops = []
for index, msg in msgs:
msg = msg.as_builder()
# dict converts name enum into string representation
msg.driverMonitoringState.events = [log.OnroadEvent(**event.to_dict()) for event in
msg.driverMonitoringState.eventsDEPRECATED if
not str(event.name).endswith('DEPRECATED')]
events = []
for event in msg.driverMonitoringState.eventsDEPRECATED:
try:
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()))

return ops, [], []

0 comments on commit ea4a127

Please sign in to comment.