talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
427 stars 97 forks source link

(3a -> 3) Add `FrameGroup` fixture #1753

Closed roomrys closed 5 months ago

roomrys commented 5 months ago

Description

This PR adds a Labels fixture called multiview_min_session_frame_groups which builds off of multiview_min_session_user_labels to include FrameGroups in the RecordingSession where all user-labeled Instances are now in an InstanceGroup.

Types of changes

Does this address any currently open issues?

[list open issues here]

Outside contributors checklist

Thank you for contributing to SLEAP!

:heart:

Summary by CodeRabbit

coderabbitai[bot] commented 5 months ago

Walkthrough

The recent updates across multiple files in the SLEAP project focus on refining the codebase by enhancing representation methods, streamlining data handling processes, and improving integration tests. Changes include the removal of redundant code, simplification of data structures, and addition of new test fixtures to ensure robustness in multi-view session handling.

Changes

File Path Change Summary
.../cameras.py, .../labels_json.py Enhanced __repr__ methods, streamlined instance and session handling, removed unused logging.
.../dataset.py Simplified data indexing in to_dict, updated return type in load_file.
.../hdf5.py Reorganized imports, modified data deserialization for better session and frame group handling.
.../fixtures/datasets.py Added new fixture for testing minimal session frame groups.
.../test_cameras.py New integration test for session, frame group, and instance group handling; updated representation tests.

🐇✨ In the code's garden, fresh changes bloom, Refining the flow, giving bugs less room. A rabbit hops through, with a code-filled cheer, Celebrating the updates, so crisp and clear. Hop, hop, hooray, for the code so bright, Under the moon's soft, silvery light. 🌟🐰


Recent Review Details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between b1d2372946ab84fce4431665b1b721fc17bedea3 and 37ed92aceb0cbdb60c41743228cc0cd3546ccd2a.
Files selected for processing (6) * sleap/io/cameras.py (6 hunks) * sleap/io/dataset.py (2 hunks) * sleap/io/format/hdf5.py (3 hunks) * sleap/io/format/labels_json.py (5 hunks) * tests/fixtures/datasets.py (1 hunks) * tests/io/test_cameras.py (3 hunks)
Additional Context Used
Ruff (30)
sleap/io/cameras.py (7)
79-79: f-string without any placeholders --- 80-80: f-string without any placeholders --- 81-81: f-string without any placeholders --- 448-448: Undefined name `Skeleton` --- 601-601: Undefined name `Skeleton` --- 828-828: Do not use bare `except` --- 1002-1002: Undefined name `Labels`
sleap/io/dataset.py (16)
55-55: Redefinition of unused `Callable` from line 45 --- 61-61: `h5py` imported but unused --- 69-69: Do not use bare `except` --- 70-70: `typing._ForwardRef` imported but unused --- 365-365: Do not assign a `lambda` expression, use a `def` --- 367-370: Do not assign a `lambda` expression, use a `def` --- 372-375: Do not assign a `lambda` expression, use a `def` --- 934-934: Do not compare types, use `isinstance()` --- 1454-1454: Do not compare types, use `isinstance()` --- 2359-2359: Undefined name `glob` --- 2454-2454: Avoid equality comparisons to `False`; use `if not ret:` for false checks --- 2542-2542: Avoid equality comparisons to `False`; use `if not ret:` for false checks --- 2557-2557: Undefined name `sleap` --- 2647-2647: Do not compare types, use `isinstance()` --- 2650-2650: Local variable `e` is assigned to but never used --- 2652-2652: f-string without any placeholders
sleap/io/format/labels_json.py (6)
154-154: Local variable `ex` is assigned to but never used --- 224-224: Local variable `ex` is assigned to but never used --- 379-379: Do not compare types, use `isinstance()` --- 404-404: Do not use bare `except` --- 408-408: Do not use bare `except` --- 428-428: Local variable `new_skel` is assigned to but never used
tests/fixtures/datasets.py (1)
1-1: `os` imported but unused
Additional comments not posted (4)
tests/fixtures/datasets.py (1)
`291-296`: The new fixture `multiview_min_session_frame_groups` is correctly implemented and follows the established pattern for loading label files.
tests/io/test_cameras.py (3)
`322-358`: Verify the logic for adding instances to frame and instance groups. Ensure that the logic correctly handles the scenarios where no labeled frames are found (line 346) and properly adds instances to the correct groups (line 352-357). --- `359-366`: Check the assertions for correctness. Confirm that the assertions (lines 359-366) accurately test the expected outcomes of the operations performed in the test, such as the correct number of frame groups and instance groups, and the expected number of instances in each group. --- `368-394`: Review the save and load functionality of labels. Ensure that the labels are correctly saved to and loaded from a temporary file (lines 368-394), and that the integrity of the data is maintained throughout this process.
--- 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?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 88.23529% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.49%. Comparing base (b1d2372) to head (37ed92a).

Files Patch % Lines
sleap/io/format/hdf5.py 85.71% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## liezl/asc-initial-update-instances-across-views #1753 +/- ## =================================================================================== + Coverage 73.35% 73.49% +0.14% =================================================================================== Files 135 135 Lines 24875 24882 +7 =================================================================================== + Hits 18247 18288 +41 + Misses 6628 6594 -34 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

roomrys commented 5 months ago

Note: the mac test is failing because of the rollout of macos-14 (M1) to replace macos-latest. Previously, we were using a non-GPU mac runner, but the m1 runner is breaking some of our tests (from trying to switch to CPU only during runtime). A PR was already merged into develop to fix this in d4ad3.