Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using DummyVideo when restructuring #2040

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sleap/io/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading