From d0e0fc5d29a451f9abf3e415480b7a029592f3c0 Mon Sep 17 00:00:00 2001 From: roomrys <38435167+roomrys@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:03:24 -0800 Subject: [PATCH] Allow using DummyVideo when restructuring --- sleap/io/video.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sleap/io/video.py b/sleap/io/video.py index c8272cfbd..df99996bc 100644 --- a/sleap/io/video.py +++ b/sleap/io/video.py @@ -1547,12 +1547,16 @@ def cattr(): # Use from_filename to fixup the video path and determine backend def fixup_video(x: dict, cl: Video): - backend_dict = x.pop("backend") + backend_dict: dict = x.pop("backend") + + # If the backend is a DummyVideo + if backend_dict.get("dummy", False): + return cl(backend=cl.make_specific_backend(DummyVideo, backend_dict)) + filename = backend_dict.pop("filename", None) or backend_dict.pop( "file", None ) - - return Video.from_filename(filename, **backend_dict) + return cl.from_filename(filename, **backend_dict) vid_cattr = cattr.Converter() vid_cattr.register_structure_hook(Video, fixup_video)