From 8d6010cc6da0f3fa7f4c4810aa99f3a45c3ca3f0 Mon Sep 17 00:00:00 2001 From: roomrys <38435167+roomrys@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:35:45 -0700 Subject: [PATCH 1/3] Improve error message for detecting video backend --- sleap/io/video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sleap/io/video.py b/sleap/io/video.py index f8af330ec..4ef669ec2 100644 --- a/sleap/io/video.py +++ b/sleap/io/video.py @@ -1273,7 +1273,7 @@ def from_filename(cls, filename: str, *args, **kwargs) -> "Video": elif filename.lower().endswith(SingleImageVideo.EXTS): backend_class = SingleImageVideo else: - raise ValueError("Could not detect backend for specified filename.") + raise ValueError(f"Could not detect backend for specified filename: {filename}") kwargs["filename"] = filename From 1a53ec27da80629dd9750f32449b8f4c039c4329 Mon Sep 17 00:00:00 2001 From: roomrys <38435167+roomrys@users.noreply.github.com> Date: Tue, 8 Aug 2023 08:36:28 -0700 Subject: [PATCH 2/3] Lint --- sleap/io/video.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sleap/io/video.py b/sleap/io/video.py index 4ef669ec2..b73569fa0 100644 --- a/sleap/io/video.py +++ b/sleap/io/video.py @@ -1273,7 +1273,9 @@ def from_filename(cls, filename: str, *args, **kwargs) -> "Video": elif filename.lower().endswith(SingleImageVideo.EXTS): backend_class = SingleImageVideo else: - raise ValueError(f"Could not detect backend for specified filename: {filename}") + raise ValueError( + f"Could not detect backend for specified filename: {filename}" + ) kwargs["filename"] = filename From f9790450e82471763189b1524aaa241e8ec5f2be Mon Sep 17 00:00:00 2001 From: roomrys <38435167+roomrys@users.noreply.github.com> Date: Tue, 8 Aug 2023 16:10:37 -0700 Subject: [PATCH 3/3] Add small test --- tests/io/test_video.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/io/test_video.py b/tests/io/test_video.py index 9361f393b..4c3f8a5e9 100644 --- a/tests/io/test_video.py +++ b/tests/io/test_video.py @@ -37,6 +37,9 @@ def test_from_filename(hdf5_file_path, small_robot_mp4_path): == SingleImageVideo ) + with pytest.raises(ValueError): + Video.from_filename("this_has_no_video_extension") + def test_backend_extra_kwargs(hdf5_file_path, small_robot_mp4_path): Video.from_filename(hdf5_file_path, grayscale=True, another_kwarg=False)