Repository navigation
driver: construct real CameraFrame instances instead of plain tuples - #148
amtellezfernandez wants to merge 1 commit into
Conversation
|
Closing this after a harder look at necessity: no current consumer is actually affected. Every in-tree model unpacks positionally (which NamedTuple preserves), and external policies — including ours, which is how this was originally noticed — have long since added positional fallbacks. Without a live consumer relying on the declared type, this is contract hygiene rather than a needed fix, and it isn't worth review bandwidth right now. Happy to reopen if the declared |
|
Reopening: the case is stronger stated purely in terms of this repo, and does not depend on any downstream project.
Separately, as a downstream data point: the mismatch has required compatibility handling in AlpaBridge, which registers through the |
CameraImages is typed as dict[str, list[CameraFrame]], but _prepare_camera_images builds plain positional tuples, so every PredictionInput.camera_images value a model receives is a bare tuple at runtime, not a real CameraFrame - attribute access (frame.timestamp_us, frame.image) raises AttributeError. Construct real CameraFrame instances; since NamedTuple is a tuple subclass, this is purely additive for existing positional-unpacking consumers. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
291227d to
72235fc
Compare
|
We hit the same thing: a driver plugin of ours read frame.timestamp_us from camera_images and got "AttributeError: 'tuple' object has no attribute 'timestamp_us'", so we're unpacking by position for now. This PR would make it match the CameraFrame type declared in models/base.py. Thanks for the fix! |
models/base.pydeclares what a model receives:EgoDriverService._prepare_camera_imagesis the only place those values get built, and it emits plain tuples.CameraFrameisn't referenced anywhere else inmain.pyoutside a docstring:So code written against the declared interface gets an object that doesn't satisfy it:
This patch makes the emitted objects satisfy the declared type.
No in-tree behaviour changes. Every built-in model and the transfuser plugin do
for ts, img in frames, andCameraFrameis aNamedTuple, so positional unpacking keeps working. What changes is thatisinstance(frame, CameraFrame)becomes True, as the annotation already claims.The mismatch has also needed compatibility handling downstream: AlpaBridge registers through the
alpasim.modelsentry-point group and currently accepts both representations (1, 2).Four lines at one site. The other way to resolve it is to weaken the annotation to plain tuples, which drops a documented guarantee.