talmolab / sleap

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

(3a -> 3) Debug `TriangulateSession` command #1755

Closed roomrys closed 5 months ago

roomrys commented 5 months ago

Description

This PR debugs the TriangulateSession command and adds a few fixes to the relevant InstanceGroup and FrameGroup methods.

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 focus on refining the triangulateSession functionality across several files in the SLEAP project. The key adjustments include parameter optimization, enhanced method handling, and improved testing protocols. These changes streamline the process of session handling and instance management within the software, ensuring more robust and error-resistant performance.

Changes

File Path Change Summary
sleap/gui/app.py, sleap/gui/commands.py Updated triangulateSession to use session directly, adjusted parameters, and enhanced testing.
sleap/io/cameras.py Improved error handling, parameter naming, and added comprehensive tests for new functionalities.

🐇✨ A hop, a skip, a code deploy, In the fields of SLEAP, we enjoy. Triangulate with less ado, Bugs beware, we're coming through! 🌟🐰


Recent Review Details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 0d26728978939b9e9d5fdcc514b9be0aa5772d76 and e2dcd8b3624316bf215a9b19f9d3f970051fd807.
Files selected for processing (5) * sleap/gui/app.py (1 hunks) * sleap/gui/commands.py (5 hunks) * sleap/io/cameras.py (7 hunks) * tests/gui/test_commands.py (3 hunks) * tests/io/test_cameras.py (3 hunks)
Additional Context Used
Ruff (32)
sleap/gui/app.py (1)
261-261: Local variable `filename` is assigned to but never used
sleap/gui/commands.py (11)
38-38: `itertools.permutations` imported but unused --- 38-38: `itertools.product` imported but unused --- 40-40: `typing.cast` imported but unused --- 57-57: `sleap.io.cameras.Camcorder` imported but unused --- 196-196: Undefined name `MainWindow` --- 834-834: Local variable `file_dir` is assigned to but never used --- 1708-1708: Do not use bare `except` --- 1729-1729: Do not use bare `except` --- 2466-2466: f-string without any placeholders --- 2798-2798: f-string without any placeholders --- 3141-3141: Do not use bare `except`
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` --- 829-829: Do not use bare `except` --- 1003-1003: Undefined name `Labels`
tests/gui/test_commands.py (13)
75-75: Ambiguous variable name: `l` --- 82-82: Ambiguous variable name: `l` --- 227-227: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 236-236: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 244-244: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 253-253: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 265-265: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 274-274: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 281-281: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 299-299: Avoid equality comparisons to `True`; use `if okay:` for truth checks --- 360-360: Local variable `last_lf_frame` is assigned to but never used --- 368-368: Avoid equality comparisons to `True`; use `if video.backend.grayscale:` for truth checks --- 528-528: f-string without any placeholders
Additional comments not posted (9)
tests/io/test_cameras.py (2)
`451-453`: Ensure the new parameter `multiview_min_session_frame_groups` is utilized effectively in the tests. --- `597-599`: Ensure the new parameter `multiview_min_session_frame_groups` is utilized effectively in the tests.
tests/gui/test_commands.py (2)
`7-7`: Added imports for `numpy` and `pytest`. Ensure these are used appropriately in the tests to avoid unnecessary imports. --- `21-21`: `TriangulateSession` added to public entities. Confirm that this is intended for external use and documented accordingly.
sleap/gui/app.py (1)
`1242-1244`: Update to session management in `triangulateSession` looks good. Please ensure that the new session retrieval and passing mechanism is thoroughly tested, especially in scenarios with multiple videos or sessions.
sleap/io/cameras.py (2)
`1069-1076`: Ensure correct sorting and updating of excluded views in `RecordingSession`. The changes correctly sort the `cams_to_include` based on their order in the `CameraCluster` and update the `excluded_views` accordingly. This is crucial for maintaining consistency in the views handled by the session. --- `739-741`: Add a null check before appending to the `instances` list in `InstanceGroup`. The addition of a null check before appending instances to the list is a crucial improvement that prevents potential errors from operating on null instances. This change enhances the robustness of the method.
sleap/gui/commands.py (2)
`619-626`: The method `triangulateSession` has been updated to include a new `session` parameter and remove `video` and `cams_to_include` parameters. Ensure that all calls to this method are updated to pass the correct parameters. --- `3470-3486`: > :memo: **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [3473-3497] The method `has_enough_instances` now provides default values for `instance_groups`, `frame_idx`, and `instance`. This change improves the method's flexibility and error handling by providing sensible defaults.
--- 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 80.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.84%. Comparing base (0d26728) to head (e2dcd8b).

Files Patch % Lines
sleap/gui/app.py 0.00% 2 Missing :warning:
sleap/gui/commands.py 81.81% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## liezl/asc-initial-update-instances-across-views #1755 +/- ## =================================================================================== + Coverage 73.49% 73.84% +0.34% =================================================================================== Files 135 135 Lines 24882 24890 +8 =================================================================================== + Hits 18287 18379 +92 + Misses 6595 6511 -84 ```

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