From 7e91d045c48a25bf326d9823b3fa173165cc81fe Mon Sep 17 00:00:00 2001 From: Talmo Pereira Date: Sat, 28 Sep 2024 16:24:26 -0700 Subject: [PATCH] Dependency management (#118) * Drop `av` as a hard dependency * Remove av and fix tests * Remove livecov from dev tools * Pin ndx-pose * Pin ndx-pose * Bump to 0.1.9 --- environment.yml | 3 +-- pyproject.toml | 11 ++-------- sleap_io/version.py | 2 +- tests/io/test_video_backends.py | 36 ++++++++++++++++++++------------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/environment.yml b/environment.yml index 33344f92..d8c3de97 100644 --- a/environment.yml +++ b/environment.yml @@ -8,7 +8,6 @@ dependencies: - ffmpeg - imageio - imageio-ffmpeg >=0.5.0 - - av - attrs - pandas - simplejson @@ -17,7 +16,7 @@ dependencies: - numpy - opencv - pynwb - - ndx-pose + - ndx-pose<0.2.0 - pytest - pytest-cov - black diff --git a/pyproject.toml b/pyproject.toml index 8292f6c5..d9ceecfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,12 +24,11 @@ dependencies = [ "attrs", "h5py>=3.8.0", "pynwb", - "ndx-pose", + "ndx-pose<0.2.0", "pandas", "simplejson", "imageio", - "imageio-ffmpeg>=0.5.0", - "av"] + "imageio-ffmpeg>=0.5.0"] dynamic = ["version", "readme"] [tool.setuptools.dynamic] @@ -67,9 +66,3 @@ line-length = 88 [pydocstyle] convention = "google" match-dir = "sleap_io" - -[tool.coverage.run] -source = ["livecov"] - -[tool.pytest.ini_options] -addopts = "--cov sleap_io --cov-report=lcov:lcov.info --cov-report=term" diff --git a/sleap_io/version.py b/sleap_io/version.py index 635a3289..c653016f 100644 --- a/sleap_io/version.py +++ b/sleap_io/version.py @@ -2,4 +2,4 @@ # Define package version. # This is read dynamically by setuptools in pyproject.toml to determine the release version. -__version__ = "0.1.8" +__version__ = "0.1.9" diff --git a/tests/io/test_video_backends.py b/tests/io/test_video_backends.py index 06f22050..f3ef60da 100644 --- a/tests/io/test_video_backends.py +++ b/tests/io/test_video_backends.py @@ -59,6 +59,7 @@ def test_get_frame(centered_pair_low_quality_path): @pytest.mark.parametrize("keep_open", [False, True]) def test_mediavideo(centered_pair_low_quality_path, keep_open): + # Test with FFMPEG backend backend = VideoBackend.from_filename( centered_pair_low_quality_path, plugin="FFMPEG", keep_open=keep_open ) @@ -74,21 +75,28 @@ def test_mediavideo(centered_pair_low_quality_path, keep_open): else: assert backend._open_reader is None - backend = VideoBackend.from_filename( - centered_pair_low_quality_path, plugin="pyav", keep_open=keep_open - ) - assert type(backend) == MediaVideo - assert backend.filename == centered_pair_low_quality_path - assert backend.shape == (1100, 384, 384, 1) - assert backend[0].shape == (384, 384, 1) - assert backend[:3].shape == (3, 384, 384, 1) - if keep_open: - assert backend._open_reader is not None - assert backend[0].shape == (384, 384, 1) - assert type(backend._open_reader).__name__ == "PyAVPlugin" - else: - assert backend._open_reader is None + # Test with pyav backend (if installed) + try: + import av + backend = VideoBackend.from_filename( + centered_pair_low_quality_path, plugin="pyav", keep_open=keep_open + ) + assert type(backend) == MediaVideo + assert backend.filename == centered_pair_low_quality_path + assert backend.shape == (1100, 384, 384, 1) + assert backend[0].shape == (384, 384, 1) + assert backend[:3].shape == (3, 384, 384, 1) + if keep_open: + assert backend._open_reader is not None + assert backend[0].shape == (384, 384, 1) + assert type(backend._open_reader).__name__ == "PyAVPlugin" + else: + assert backend._open_reader is None + except ImportError: + pass + + # Test with opencv backend backend = VideoBackend.from_filename( centered_pair_low_quality_path, plugin="opencv", keep_open=keep_open )