You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
openadapt.replay.replay() forwards every keyword argument it receives to the chosen strategy’s constructor.
Kwargs that belong only to replay() itself—e.g. recording_id, timestamp, capture, status_pipe—end up in the strategy __init__, which usually does not accept them, raising:
TypeError: VisualReplayStrategy.__init__() got an unexpected keyword argument 'recording_id'
Expected behaviour
replay() should strip its own kwargs and pass only the ones intended for the strategy constructor.
Actual behaviour
Internal kwargs are forwarded wholesale, triggering the TypeError above whenever the strategy doesn’t accept them.
Root cause (code)
openadapt/replay.py, inside replay() :
strategy = strategy_class(recording, **kwargs) # kwargs still includes recording_id, etc.
Proposed fix
A deny‑list works, but an allow‑list derived from the strategy signature is maintenance‑free:
import inspect
init_params = set(inspect.signature(strategy_class.init).parameters) - {"self"}
strategy_kwargs = {k: v for k, v in kwargs.items() if k in init_params}
strategy = strategy_class(recording, **strategy_kwargs)
logger.debug("Passing to %s: %s", strategy_class.name, strategy_kwargs)
ai-yann
changed the title
[Bug]: Bug: replay() leaks its own kwargs into strategy causing TypeError
[Bug]: replay() leaks its own kwargs into strategy causing TypeError
Apr 17, 2025
Describe the bug
openadapt.replay.replay()
forwards every keyword argument it receives to the chosen strategy’s constructor.Kwargs that belong only to
replay()
itself—e.g.recording_id
,timestamp
,capture
,status_pipe
—end up in the strategy__init__
, which usually does not accept them, raising:Expected behaviour
replay()
should strip its own kwargs and pass only the ones intended for the strategy constructor.Actual behaviour
Internal kwargs are forwarded wholesale, triggering the
TypeError
above whenever the strategy doesn’t accept them.Root cause (code)
openadapt/replay.py
, insidereplay()
:Proposed fix
A deny‑list works, but an allow‑list derived from the strategy signature is maintenance‑free:
Environment
Workaround
Subclass the strategy so it absorbs unexpected kwargs:
Pass
"PatchedVisualReplayStrategy"
toreplay()
until the fix lands.Thanks for maintaining OpenAdapt—happy to open a PR with the patch!
To Reproduce
Minimal repro
Any strategy whose constructor lacks recording_id (or **kwargs) will fail identically.
The text was updated successfully, but these errors were encountered: