Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process_replay: strict migration #34388

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions selfdrive/test/process_replay/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
## 3. product is the message type created by the migration function, and the function will be skipped if product type already exists in lr
## 4. it must return a list of operations to be applied to the logreader (replace, add, delete)
## 5. all migration functions must be independent of each other
def migrate_all(lr: LogIterable, manager_states: bool = False, panda_states: bool = False, camera_states: bool = False):
def migrate_all(lr: LogIterable, manager_states: bool = False, panda_states: bool = False, camera_states: bool = False, strict: bool = True):
migrations = [
migrate_sensorEvents,
migrate_carParams,
Expand All @@ -51,10 +51,10 @@ def migrate_all(lr: LogIterable, manager_states: bool = False, panda_states: boo
if camera_states:
migrations.append(migrate_cameraStates)

return migrate(lr, migrations)
return migrate(lr, migrations, strict)


def migrate(lr: LogIterable, migration_funcs: list[MigrationFunc]):
def migrate(lr: LogIterable, migration_funcs: list[MigrationFunc], strict: bool):
lr = list(lr)
grouped = defaultdict(list)
for i, msg in enumerate(lr):
Expand All @@ -68,10 +68,15 @@ def migrate(lr: LogIterable, migration_funcs: list[MigrationFunc]):

sorted_indices = sorted(ii for i in migration.inputs for ii in grouped[i])
msg_gen = [(i, lr[i]) for i in sorted_indices]
r_ops, a_ops, d_ops = migration(msg_gen)
replace_ops.extend(r_ops)
add_ops.extend(a_ops)
del_ops.extend(d_ops)
try:
r_ops, a_ops, d_ops = migration(msg_gen)
replace_ops.extend(r_ops)
add_ops.extend(a_ops)
del_ops.extend(d_ops)
except Exception:
if strict:
raise
traceback.print_exc()

for index, msg in replace_ops:
lr[index] = msg
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/ui/tests/test_ui/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def create_screenshots():
segnum = 2
lr = LogReader(route.qlog_paths()[segnum])
DATA['carParams'] = next((event.as_builder() for event in lr if event.which() == 'carParams'), None)
for event in migrate(lr, [migrate_controlsState, migrate_carState]):
for event in migrate(lr, [migrate_controlsState, migrate_carState], True):
if event.which() in DATA:
DATA[event.which()] = event.as_builder()

Expand Down
Loading