driver: construct real CameraFrame instances instead of plain tuples - #148
driver: construct real CameraFrame instances instead of plain tuples#148amtellezfernandez wants to merge 1 commit into
Conversation
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>
|
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 |
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.