Closed roomrys closed 3 months ago
Recent changes enhance the sleap/io/video.py
functionality by refactoring the fixup_video
function to streamline the handling of video file paths and backend configurations. The test suite in tests/io/test_dataset.py
was also updated to better align with expected video formats. These modifications improve clarity, maintainability, and the overall efficiency of the codebase.
Files | Change Summary |
---|---|
sleap/io/video.py |
Refactored fixup_video function to improve path handling and backend registration; updated type annotations. |
tests/io/test_dataset.py |
Updated filename parameter in removal_test_labels fixture to "test.mp4" for better test accuracy. |
sequenceDiagram
participant User
participant VideoHandler
participant MediaBackend
User->>VideoHandler: Request video processing
VideoHandler->>MediaBackend: Retrieve backend info
MediaBackend-->>VideoHandler: Provide backend configuration
VideoHandler->>VideoHandler: Fix video paths
VideoHandler-->>User: Return processed video
🐰 "In the code where bunnies hop,
A path was fixed, not a single flop!
With video flows so neat and fine,
Our tests now dance, oh how they shine!
Hooray for changes, clear and bright,
Let’s code and play, from day to night!" 🐇
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 74.49%. Comparing base (
7ed1229
) to head (ae341cc
). Report is 31 commits behind head on develop.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
When upgrading dependencies in a downstream branch, we are running into problems with
cattrs
inferring theVideo.backend
type. This PR fixes this issue by using theVideo.from_filename
function to determine the Video backend.Prior to this, just the attributes in the serialized "backend" dictionary were used by
cattrs
to automatically infer whichVideo.backend
type to use. Thus, we had a test fixture with theVideo.filename == "test"
which would fail with our new way of structuring (since there are no extensions on the filename). I don't foresee this being a problem as all videos should have correct filenames (even pkg.slp format converts the.
filename: https://github.com/talmolab/sleap/blob/076f3dda2036c5833dec35ff4479d3ae1c7f7f55/sleap/io/format/hdf5.py#L100-L101 to the extension expected by theHDF5Video
backend: https://github.com/talmolab/sleap/blob/efdf3faa87019b070438eddbde1f917433aeff9a/sleap/io/video.py#L47-L66 https://github.com/talmolab/sleap/blob/efdf3faa87019b070438eddbde1f917433aeff9a/sleap/io/video.py#L1265-L1266 ), but please double check me.Types of changes
Does this address any currently open issues?
1841
Outside contributors checklist
Thank you for contributing to SLEAP!
:heart:
Summary by CodeRabbit
Refactor
Tests