Files
StarPilot/selfdrive/test/process_replay/regen_all.py
T
Kacper Rączy 2878a3a876 CI: add regen job (#30157)
* Ability to whitelist/blacklist cars in regen_all

* Add CI job for regen, running on 2 segments

* Run regen_all, not regen

* Use coverage run

* Add test_regen

* Use test_regen in ci test

* Add test case names

* ONNXCPU = 1

* Add mazda segment

* Use RUN_CL

* build cl image before running

* unset PYTHONWARNINGS

* Create regen cache

* Replace daemons with processes

* Skip ford

* Skip mazda

* Add comment about commented segments

* Update selfdrive/test/process_replay/test_regen.py

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* Remove unset pythonwarnings

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 3aa74c28fcd426f73da2201b2fdd7ac2be21ba71
2023-10-05 13:59:00 -07:00

55 lines
2.3 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import concurrent.futures
import os
import random
import traceback
from tqdm import tqdm
from openpilot.common.prefix import OpenpilotPrefix
from openpilot.selfdrive.test.process_replay.regen import regen_and_save
from openpilot.selfdrive.test.process_replay.test_processes import FAKEDATA, source_segments as segments
from openpilot.tools.lib.route import SegmentName
def regen_job(segment, upload, disable_tqdm):
with OpenpilotPrefix():
sn = SegmentName(segment[1])
fake_dongle_id = 'regen' + ''.join(random.choice('0123456789ABCDEF') for _ in range(11))
try:
relr = regen_and_save(sn.route_name.canonical_name, sn.segment_num, upload=upload, use_route_meta=False,
outdir=os.path.join(FAKEDATA, fake_dongle_id), disable_tqdm=disable_tqdm)
relr = '|'.join(relr.split('/')[-2:])
return f' ("{segment[0]}", "{relr}"), '
except Exception as e:
err = f" {segment} failed: {str(e)}"
err += traceback.format_exc()
err += "\n\n"
return err
if __name__ == "__main__":
all_cars = {car for car, _ in segments}
parser = argparse.ArgumentParser(description="Generate new segments from old ones")
parser.add_argument("-j", "--jobs", type=int, default=1)
parser.add_argument("--no-upload", action="store_true")
parser.add_argument("--whitelist-cars", type=str, nargs="*", default=all_cars,
help="Whitelist given cars from the test (e.g. HONDA)")
parser.add_argument("--blacklist-cars", type=str, nargs="*", default=[],
help="Blacklist given cars from the test (e.g. HONDA)")
args = parser.parse_args()
tested_cars = set(args.whitelist_cars) - set(args.blacklist_cars)
tested_cars = {c.upper() for c in tested_cars}
tested_segments = [(car, segment) for car, segment in segments if car in tested_cars]
with concurrent.futures.ProcessPoolExecutor(max_workers=args.jobs) as pool:
p = pool.map(regen_job, tested_segments, [not args.no_upload] * len(tested_segments), [args.jobs > 1] * len(tested_segments))
msg = "Copy these new segments into test_processes.py:"
for seg in tqdm(p, desc="Generating segments", total=len(tested_segments)):
msg += "\n" + str(seg)
print()
print()
print(msg)