openpilot icon indicating copy to clipboard operation
openpilot copied to clipboard

tools: add --auto flag to replay and cabana for loading routes from auto source

Open deanlee opened this issue 9 months ago • 14 comments

Added the --auto flag to cabana and replay, allowing routes to be loaded from the most suitable source based on logreader.py's auto-sourcing logic.

Usage example for loading a specified route with auto-sourcing:

cabana --auto <route> replay --auto <route>

deanlee avatar Mar 14 '25 08:03 deanlee

could this instead be default behavior instead of behind a flag?

greatgitsby avatar Mar 14 '25 20:03 greatgitsby

I agree, can we replace the C++ implementation of finding sources with this?

sshane avatar Mar 14 '25 20:03 sshane

It's better to hide this feature behind a flag for now. While --auto offers a convenient option, it doesn’t replace the default route-loading behavior in replay&cabana.

The current auto-sourcing implementation has significant limitations. It only loads rlogs and fails to manage non-contiguous segments, which undermines its compatibility with key replay and Cabana features. These require smooth transitions between rlog/qlog, HEVC/qcam, and reliable handling of segment gaps.

Additionally, the auto-sourcing process is inefficient. It validates every source file with file_exists, triggering excessive HTTP calls that slow down startup—often taking more than 10 seconds on my laptop. I've also encountered frequent DNS errors, even when using a VPN.

The --auto flag should be removed once these issues and limitations are resolved.

deanlee avatar Mar 15 '25 04:03 deanlee

Using /a handles missing rlogs in the middle of segments btw

sshane avatar Mar 15 '25 05:03 sshane

Getting

  File "/home/batman/openpilot/tools/cabana/../lib/logreader.py", line 240, in auto_source
    raise LogsUnavailable("auto_source could not find any valid source, exceptions for sources:\n  - " +
LogsUnavailable: auto_source could not find any valid source, exceptions for sources:
  - internal_source: Exception('unable to get max_segment_number. ensure you have access to this route or the route is public.')
  - internal_source_zst: Exception('unable to get max_segment_number. ensure you have access to this route or the route is public.')
  - openpilotci_source: Exception('unable to get max_segment_number. ensure you have access to this route or the route is public.')
  - openpilotci_source_zst: Exception('unable to get max_segment_number. ensure you have access to this route or the route is public.')
  - comma_api_source: UnauthorizedError('Unauthorized. Authenticate with tools/lib/auth.py')
  - comma_car_segments_source: Exception('unable to get max_segment_number. ensure you have access to this route or the route is public.')
  - testing_closet_source: Exception('Internal source not available')

but I'm authenticated

sshane avatar Mar 15 '25 05:03 sshane

@sshane fixed. cabana use OPENPILOT_PREFIX to run multiple instances simultaneously. This was causing the path to auth.json to be prefixed, making it unreadable.

deanlee avatar Mar 15 '25 17:03 deanlee

Tried it with a route from test_models:

batman@workstation-shane:~/openpilot$ cabana 0c94aa1e1296d7c6/2021-05-05--19-48-37/2 --auto
active services: can, carParams, driverEncodeIdx, roadEncodeIdx, wideRoadEncodeIdx
loading route 
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 5) > this->size() (which is 4)
Aborted (core dumped)

sshane avatar Mar 24 '25 22:03 sshane

This PR has had no activity for 9 days. It will be automatically closed in 2 days if there is no activity.

github-actions[bot] avatar Apr 03 '25 02:04 github-actions[bot]

I tested the command cabana 0c94aa1e1296d7c6/2021-05-05--19-48-37/2 --auto and was able to run it successfully, with the messages displaying correctly in Cabana. However, it seems there’s still an underlying bug causing this issue.

deanlee avatar Apr 04 '25 04:04 deanlee

This PR has had no activity for 9 days. It will be automatically closed in 2 days if there is no activity.

github-actions[bot] avatar Apr 14 '25 02:04 github-actions[bot]

It works for me, can we merge?

sshane avatar Apr 14 '25 20:04 sshane

This doesnt work for me, SegmentManager successfully loads the route, but cabana is stuck on "Loading segment data..." dialog

fredyshox avatar Apr 21 '25 23:04 fredyshox

This PR has had no activity for 9 days. It will be automatically closed in 2 days if there is no activity.

github-actions[bot] avatar May 01 '25 02:05 github-actions[bot]

This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes.

github-actions[bot] avatar May 04 '25 02:05 github-actions[bot]

ty! this is a nice improvement

sshane avatar May 05 '25 23:05 sshane