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

(4->3) Fix (de)serialization of RecordingSession and add Multiview Fixture #1281

Conversation

roomrys
Copy link
Collaborator

@roomrys roomrys commented Apr 18, 2023

Description

This PR adds new test dataset which also revealed some errors in the (de)serialization of RecordingSesssion. Hence, this PR also fixes those errors (and serves to stand as an entry-point for any future (de)serialization fixes for the lifetime of the multi-view mvp stacked prs).

Types of changes

  • Bugfix
  • New feature
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (new fixture)

Does this address any currently open issues?

[list open issues here]

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

Summary by CodeRabbit

  • New Feature: Enhanced the __repr__ method in cameras.py and dataset.py to provide more detailed information about videos, camera clusters, and sessions.
  • Bug Fix: Corrected the handling of dictionary keys in to_session_dict and from_session_dict methods in cameras.py, ensuring proper conversion between integer and string indices.
  • Refactor: Updated the read_headers and append_unique functions in hdf5.py to include the "sessions" key for improved data organization.
  • Test: Added a new fixture multiview_min_session_labels in datasets.py for comprehensive testing. Adjusted test cases in test_cameras.py and test_dataset.py to align with the latest changes.
  • Documentation: Fixed a typo in a comment in hdf5.py.

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

❗ No coverage uploaded for pull request base (liezl/asc-initial-update-instances-across-views@45b8475). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 1d2fb50 differs from pull request most recent head c88b51d. Consider uploading reports for the commit c88b51d to get more accurate results

@@                                Coverage Diff                                 @@
##             liezl/asc-initial-update-instances-across-views    #1281   +/-   ##
==================================================================================
  Coverage                                                   ?   72.82%           
==================================================================================
  Files                                                      ?      134           
  Lines                                                      ?    24101           
  Branches                                                   ?        0           
==================================================================================
  Hits                                                       ?    17551           
  Misses                                                     ?     6550           
  Partials                                                   ?        0           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roomrys roomrys requested a review from talmo April 20, 2023 15:41
@roomrys roomrys marked this pull request as ready for review April 20, 2023 15:41
@roomrys roomrys changed the title Fix (de)serialization of RecordingSession Fix (de)serialization of RecordingSession and add Multiview Fixture Apr 20, 2023
@roomrys roomrys added the MultiView Stack This PR is part of the MultView stacked PRs. label Apr 20, 2023
@roomrys roomrys changed the title Fix (de)serialization of RecordingSession and add Multiview Fixture (4->3) Fix (de)serialization of RecordingSession and add Multiview Fixture Jul 6, 2023
@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2023

Walkthrough

This update enhances the handling of sessions in SLEAP, including better representation of camera and video data, improved session key management, and expanded testing capabilities. It also includes minor comment corrections.

Changes

File(s) Summary
sleap/io/cameras.py Enhanced __repr__ method to include more details. Improved key conversion in to_session_dict and from_session_dict methods.
sleap/io/dataset.py Added sessions attribute to the Labels class's __repr__ method.
sleap/io/format/hdf5.py Included "sessions" key in loops in read_headers and append_unique functions. Fixed a typo in comments.
tests/fixtures/... Added new fixture multiview_min_session_labels for testing.
tests/io/test_cameras.py Added import statement for Labels. Modified assertion in test_camera_cluster. Adjusted dictionary keys in session_dict["camcorder_to_video_idx_map"].
tests/io/test_dataset.py Updated test_save_labels_with_sessions function to handle additional parameter and save modified labels to a new path.

🐇💻

Code refined, tests designed,

Sessions handled, complexities untangled.

In the land of code, where the shadows lie,

We watch the pull requests multiply! 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@roomrys roomrys removed the request for review from talmo September 29, 2023 19:56
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Commits Files that changed from the base of the PR and between 45b8475 and c88b51d.
Files ignored due to filter (9)
  • tests/data/cameras/minimal_session/calibration.toml
  • tests/data/videos/min_session_back.mp4
  • tests/data/videos/min_session_backL.mp4
  • tests/data/videos/min_session_mid.mp4
  • tests/data/videos/min_session_midL.mp4
  • tests/data/videos/min_session_side.mp4
  • tests/data/videos/min_session_sideL.mp4
  • tests/data/videos/min_session_top.mp4
  • tests/data/videos/min_session_topL.mp4
Files selected for processing (6)
  • sleap/io/cameras.py (3 hunks)
  • sleap/io/dataset.py (1 hunks)
  • sleap/io/format/hdf5.py (3 hunks)
  • tests/fixtures/datasets.py (1 hunks)
  • tests/io/test_cameras.py (3 hunks)
  • tests/io/test_dataset.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • sleap/io/dataset.py
Additional comments (Suppressed): 10
tests/fixtures/datasets.py (1)
  • 275-280: The new fixture multiview_min_session_labels loads a minimal session file and searches for videos in the specified directory. Ensure that the path to the .slp file and the video directory are correct and accessible. Also, verify that the loaded labels are used correctly in the tests where this fixture is applied.
tests/io/test_cameras.py (2)
  • 66-66: The number of cameras in the camera cluster has changed from 4 to 8. Please verify if this change is intentional and aligns with the test data.

  • 204-209: The keys of session_dict["camcorder_to_video_idx_map"] have been changed from integers to strings. This could potentially break other parts of the code that expect these keys to be integers. Please ensure that all references to these keys are updated accordingly.

sleap/io/format/hdf5.py (3)
  • 86-91: The "sessions" key has been added to the loop for deserializing metadata from the HDF5 file. Ensure that all existing files that this function will be used on contain the "sessions" key or can handle its absence gracefully.

  • 325-330: The "sessions" key has been added to the loop for serializing metadata into the HDF5 file. This change should be compatible with the deserialization changes made in lines 86-91.

  • 343-346: There's a typo correction in the comment, changing "PredcitedInstances" to "PredictedInstances". This doesn't affect the code execution but improves readability.

sleap/io/cameras.py (3)
  • 762-766: The __repr__ method has been updated to include the number of videos in the representation. This change provides more detailed information about the RecordingSession object, which can be useful for debugging and logging.

  • 828-834: The keys of camcorder_to_video_idx_map are now being converted to strings before assignment. This change seems to be related to serialization/deserialization, as JSON objects only support string keys. However, this could potentially introduce type-related bugs elsewhere in the code if it's expected that these keys are integers. Please verify that all uses of camcorder_to_video_idx_map throughout the codebase have been updated to handle string keys.

- camcorder_to_video_idx_map[cam_idx] = video_idx
+ camcorder_to_video_idx_map[str(cam_idx)] = str(video_idx)
  • 864-869: Similar to the previous comment, the keys of camcorder_to_video_idx_map are now being converted back to integers when retrieving Camcorder and Video objects. Again, please verify that all uses of camcorder_to_video_idx_map throughout the codebase have been updated to handle this change.
- camcorder = session.camera_cluster.cameras[cam_idx]
- video = videos_list[video_idx]
+ camcorder = session.camera_cluster.cameras[int(cam_idx)]
+ video = videos_list[int(video_idx)]
tests/io/test_dataset.py (1)
  • 972-979: The function signature of test_save_labels_with_sessions has been updated to include a new parameter multiview_min_session_labels. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

tests/io/test_cameras.py Show resolved Hide resolved
tests/io/test_dataset.py Show resolved Hide resolved
@roomrys roomrys merged commit ba2df88 into liezl/asc-initial-update-instances-across-views Sep 29, 2023
9 checks passed
@roomrys roomrys deleted the liezl/iuiav-fix-(de)-serialization branch September 29, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MultiView Stack This PR is part of the MultView stacked PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant