tools/lib: add auto_camera_source for multi-source camera file resolution#38103
Open
Ininsico wants to merge 1 commit into
Open
tools/lib: add auto_camera_source for multi-source camera file resolution#38103Ininsico wants to merge 1 commit into
Ininsico wants to merge 1 commit into
Conversation
94e6744 to
c018128
Compare
Contributor
Process replay diff reportReplays driving segments through this PR and compares the behavior to master. ✅ 0 changed, 66 passed, 0 errors |
…tion
Implements the TODO at logreader.py:149 ('this should apply to camera
files as well') by introducing auto_camera_source(), the camera
equivalent of the existing auto_source() for log files.
- New auto_camera_source() function resolves fcamera/dcamera/ecamera/
qcamera files across multiple sources with fallback, matching the
pattern used for rlog/qlog resolution
- Extended comma_api_source() in file_sources.py to serve all four
camera file types through the Route API
- Added ValueError guard for unknown file types
- 12 new tests covering single/multi-segment resolution, source
fallback, error recovery, full-route parsing, and comma_api_source
integration
c018128 to
13c059d
Compare
Contributor
|
This PR has had no activity for 24 days. It will be automatically closed in 7 days if there is no activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
auto_camera_source()— the camera equivalent of the existingauto_source()for logs — enabling smart multi-source resolution of camera files (fcamera, dcamera, ecamera, qcamera) across all data sources.Motivation
Resolves the TODO at
tools/lib/logreader.py:149:Previously, camera file resolution had no multi-source fallback mechanism. Tools like
replay,clip, andcabanahad to construct camera file URLs manually throughRoute, without any of the smart fallback behavior that logs already enjoyed (rlog → qlog across internal API, comma API, openpilot CI, commaCarSegments).Changes
tools/lib/file_sources.pyExtended
comma_api_source()to serve all four camera file types through the Route API:FileName.FCAMERA→route.camera_paths()FileName.DCAMERA→route.dcamera_paths()FileName.ECAMERA→route.ecamera_paths()FileName.QCAMERA→route.qcamera_paths()The previous
elsebranch (which handled both QLOG and unknown types) is now explicit per type, with aValueErrorraised for truly unknown file types.tools/lib/logreader.pyAdded
auto_camera_source(identifier, sources, camera_type)function that:/slice,--segment, pipe|, etc.)LogsUnavailablewith a descriptive error (including per-source exception details) when files can't be foundtools/lib/tests/test_logreader.pyAdded
TestCameraSourceclass with 12 test cases:test_auto_camera_source_no_sourcetest_auto_camera_source_no_source_default_cameratest_auto_camera_source_foundtest_auto_camera_source_multiple_segmentstest_auto_camera_source_source_fallbacktest_auto_camera_source_partial_fallbacktest_auto_camera_source_error_then_successtest_auto_camera_source_all_failtest_auto_camera_source_route_with_slashtest_auto_camera_source_route_with_segment--Nsegment notationtest_comma_api_source_extendedtest_comma_api_source_unknown_typeCompatibility
auto_camera_source()works with all existing sources (comma_api_source,openpilotci_source,internal_source) — they already construct URLs from theFileNamestuple parametercomma_car_segments_sourceis unaffected (it doesn't use thefnsparameter)comma_api_sourcecallers passing RLOG/QLOG see zero behavior changeUsage Example
Verification
All 12 new tests exercise the function logic through mocks. The
test_comma_api_source_extendedtest validates thatcomma_api_sourcecorrectly dispatches toRoute.camera_paths(),Route.dcamera_paths(),Route.ecamera_paths(), andRoute.qcamera_paths().