Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ramizhajj1
Copy link

@ramizhajj1 ramizhajj1 commented May 6, 2024

Description

Set SessionsDock.unlinked_videos_table.is_activatable = True so that state["unlinked_video"] is updated to the selected Video item in the SessionDock.unlinked_videos_table. Also make the callback for state[unlinked_video"] just update the state["video"] essentially making these states have the same callbacks.

Types of changes

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

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!

❤️

@ramizhajj1 ramizhajj1 changed the title Ramiz/add doubleclick functionality unlinkvideotable Add double click functionality to unlink video table May 7, 2024
@ramizhajj1 ramizhajj1 changed the title Add double click functionality to unlink video table Add double click functionality to UnlinkVideoTable May 7, 2024
@ramizhajj1 ramizhajj1 changed the base branch from develop to liezl/add-gui-elements-for-sessions May 7, 2024 17:02
@roomrys roomrys added the MultiView Stack This PR is part of the MultView stacked PRs. label May 8, 2024
@roomrys roomrys changed the title Add double click functionality to UnlinkVideoTable (4a -> 4) Add double click functionality to UnlinkVideoTable May 8, 2024
Copy link
Contributor

@roomrys roomrys left a comment

Choose a reason for hiding this comment

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

There must be something up with the load_video in videos.py. I would expect the unlinked_video to load, but it doesn't appear to be loading!

ellipsis_left=True,
)
self.unlinked_videos_table = GenericTableView(
is_activatable= True,
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure to lint your files before pushing with

black <path/to/file>

so

black sleap/gui/widgets/docks.py

@ramizhajj1
Copy link
Author

I re-encoded the video.mp4 files using this command: ffmpeg -y -i "input.mp4" -c:v libx264 -pix_fmt yuv420p -preset superfast -crf 23 "output.mp4" and it seems that the videos are correctly loading when I double click them on the unlinked videos table.

Screen.Recording.2024-05-17.at.4.01.03.PM.mov

@coderabbitai
Copy link

coderabbitai bot commented May 17, 2024

Warning

Rate Limit Exceeded

@roomrys has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 9 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 561df75 and 05889f9.

Walkthrough

The recent updates encompass various enhancements and modifications across multiple files in the SLEAP GUI application. These changes include improvements to video handling and GUI updates, addition of new encoding functions, and minor tweaks like adding print statements and blank lines. The modifications aim to improve functionality, maintainability, and user experience.

Changes

File(s) Change Summary
Anaconda3-2023.04-MacOSX-x86_64.sh Returns a 404 Not Found error message with details about the missing key.
sleap/gui/app.py Added methods for video handling and GUI updates, initialized GUI components, and set environment variables.
sleap/gui/commands.py Added an extra blank line at the end of the file.
sleap/gui/dataviews.py Added a print statement in the activateSelected method to display activation details.
sleap/gui/scripts/reencoder.py Introduced functions to encode videos using ffmpeg with specified parameters.
sleap/gui/widgets/docks.py Added is_activatable=True attribute to unlinked_videos_table and updated double-click handling.
sleap/gui/widgets/video.py Connected update_selection_state to "unlinked_video" signal and added a blank line in load_video.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant GUI
    participant VideoHandler
    participant Encoder

    User->>GUI: Opens video file
    GUI->>VideoHandler: Load video
    VideoHandler->>GUI: Update GUI with video

    User->>Encoder: Encode video
    Encoder->>User: Provide encoded video
Loading

Poem

In the code where pixels play,
Videos dance and signals sway.
GUI refreshed, with views anew,
Encoding magic, just for you.
A rabbit hops in lines so neat,
Making SLEAP a coder's treat.
🌟✨🐇


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 5

Out of diff range and nitpick comments (9)
sleap/gui/dataviews.py (1)

349-349: Consider replacing print statements with logging.

While the print statement in activateSelected aids in debugging, it's generally a good practice to use logging instead of printing in production code. This allows better control over the output and integrates well with different logging systems.

sleap/gui/widgets/video.py (3)

Line range hint 27-75: Move module-level imports to the top of the file for better readability and compliance with Python standards.

+ import atexit
+ import math
+ import time
+ from typing import Callable, List, Optional, Union
+ import numpy as np
+ import qimage2ndarray
+ from qtpy import QtCore, QtWidgets
+ from qtpy.QtCore import QLineF, QMarginsF, QPointF, QRectF, Qt
+ from qtpy.QtGui import (
+     QBrush,
+     QColor,
+     QCursor,
+     QFont,
+     QImage,
+     QKeyEvent,
+     QKeySequence,
+     QMouseEvent,
+     QPainter,
+     QPainterPath,
+     QPen,
+     QPixmap,
+     QPolygonF,
+     QTransform,
+ )
+ from qtpy.QtWidgets import (
+     QApplication,
+     QGraphicsEllipseItem,
+     QGraphicsItem,
+     QGraphicsObject,
+     QGraphicsPolygonItem,
+     QGraphicsRectItem,
+     QGraphicsScene,
+     QGraphicsTextItem,
+     QGraphicsView,
+     QShortcut,
+     QVBoxLayout,
+     QWidget,
+ )
+ import sleap
+ from sleap.gui.color import ColorManager
+ from sleap.gui.shortcuts import Shortcuts
+ from sleap.gui.state import GuiState
+ from sleap.gui.widgets.slider import VideoSlider
+ from sleap.instance import Instance, Point, PredictedInstance
+ from sleap.io.video import Video
+ from sleap.prefs import prefs
+ from sleap.skeleton import Node

Line range hint 307-307: Specify exception types in the except block to avoid masking unexpected errors.

- except:
+ except SpecificExceptionType:

Line range hint 1471-1471: Remove the unused variable in_bounds to clean up the code.

- in_bounds = True
sleap/gui/commands.py (5)

Line range hint 56-56: Remove unused import of Camcorder.

- from sleap.io.cameras import Camcorder, FrameGroup, InstanceGroup, RecordingSession
+ from sleap.io.cameras import FrameGroup, InstanceGroup, RecordingSession

Line range hint 196-196: Undefined reference to MainWindow. Ensure that MainWindow is defined or imported correctly.


Line range hint 868-868: The local variable file_dir is assigned but never used. Consider removing it if it's unnecessary.

- file_dir = os.path.dirname(filename)

Line range hint 1761-1761: Avoid using bare except statements. Specify exception types to handle specific exceptions appropriately.

- except:
+ except Exception as e:

Also applies to: 1782-1782, 3354-3354


Line range hint 2555-2555: These f-strings do not contain placeholders. If dynamic string formatting is not needed, consider using regular strings.

- f"This video type {type(video.backend)} for video at index {idx} "
- f"does not support grayscale yet."
+ "This video type does not support grayscale yet."

Also applies to: 2991-2991

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 45eeea7 and ab2f363.
Files ignored due to path filters (12)
  • tests/data/videos/centered_pair_small_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/dance_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_backL_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_back_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_midL_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_mid_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_sideL_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_side_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_topL_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_top_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/small_robot_3_frame_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/small_robot_encoded.mp4 is excluded by !**/*.mp4, !**/*.mp4
Files selected for processing (7)
  • Anaconda3-2023.04-MacOSX-x86_64.sh (1 hunks)
  • sleap/gui/app.py (2 hunks)
  • sleap/gui/commands.py (1 hunks)
  • sleap/gui/dataviews.py (1 hunks)
  • sleap/gui/scripts/reencoder.py (1 hunks)
  • sleap/gui/widgets/docks.py (2 hunks)
  • sleap/gui/widgets/video.py (2 hunks)
Additional Context Used
ShellCheck (3)
Anaconda3-2023.04-MacOSX-x86_64.sh (3)

[info] 1-1: The mentioned syntax error was in this simple command.


[error] 1-1: Couldn't parse this redirection. Fix to allow more checks.


[error] 1-1: Fix any mentioned problems and try again.

Ruff (39)
sleap/gui/app.py (1)

261-261: Local variable filename is assigned to but never used

sleap/gui/commands.py (8)

56-56: sleap.io.cameras.Camcorder imported but unused


196-196: Undefined name MainWindow


868-868: Local variable file_dir is assigned to but never used


1761-1761: Do not use bare except


1782-1782: Do not use bare except


2555-2555: f-string without any placeholders


2991-2991: f-string without any placeholders


3354-3354: Do not use bare except

sleap/gui/dataviews.py (6)

25-25: typing.Dict imported but unused


25-25: typing.Type imported but unused


29-29: sleap.gui.color.ColorManager imported but unused


30-30: sleap.io.dataset.Labels imported but unused


31-31: sleap.instance.Instance imported but unused


118-118: Do not use bare except

sleap/gui/widgets/docks.py (3)

15-15: Redefinition of unused QLabel from line 12


16-16: Redefinition of unused QComboBox from line 8


18-18: Redefinition of unused QGroupBox from line 10

sleap/gui/widgets/video.py (21)

27-27: Module level import not at top of file


28-28: Module level import not at top of file


29-29: Module level import not at top of file


30-30: Module level import not at top of file


32-32: Module level import not at top of file


33-33: Module level import not at top of file


34-34: Module level import not at top of file


35-35: Module level import not at top of file


36-51: Module level import not at top of file


52-65: Module level import not at top of file


67-67: Module level import not at top of file


68-68: Module level import not at top of file


69-69: Module level import not at top of file


70-70: Module level import not at top of file


71-71: Module level import not at top of file


72-72: Module level import not at top of file


73-73: Module level import not at top of file


74-74: Module level import not at top of file


75-75: Module level import not at top of file


307-307: Do not use bare except


1471-1471: Local variable in_bounds is assigned to but never used

Additional comments not posted (2)
sleap/gui/widgets/docks.py (1)

674-675: Verify the impact of removing double-click functionality from unlinked_videos_table.

The method on_unlinked_video_double_clicked was commented out, and the table was made activatable. Please ensure that this change does not negatively affect the user experience, especially if the double-click functionality was used for important features.

sleap/gui/widgets/video.py (1)

409-409: Check for potential issues with video loading logic.

Verification successful

Verify handling of None video in load_video method

The load_video method implementations in sleap/gui/widgets/video.py and sleap/gui/dialogs/importvideos.py handle the None video case appropriately.

Key Findings:

  • sleap/gui/widgets/video.py:
    • The method checks if self.video is None and calls self.reset() if true.
    • This ensures that the application handles the None video case gracefully.
  • sleap/gui/dialogs/importvideos.py:
    • The method does not explicitly check for None video, but it sets the video and frame index, and updates the label and plot accordingly.

Recommendations:

  • Ensure that all usages of load_video in sleap/gui/dialogs/importvideos.py handle the None video case if necessary.

Code Locations:

  • sleap/gui/widgets/video.py:
    def load_video(self, video: Video, plot=True):
        self.video = video
        if self.video is None:
            self.reset()
        else:
            self.view.scene.setSceneRect(0, 0, video.width, video.height)
            self.seekbar.setMinimum(0)
            self.seekbar.setMaximum(self.video.last_frame_idx)
            self.seekbar.setEnabled(True)
            self.seekbar.resizeEvent()
        if plot:
            self.plot()
  • sleap/gui/dialogs/importvideos.py:
    def load_video(self, video: Video, initial_frame=0, plot=True):
        self.video = video
        self.frame_idx = initial_frame
        label = "(%d, %d), %d f, %d c" % (
            self.video.width,
            self.video.height,
            self.video.frames,
            self.video.channels,
        )
        self.video_label.setText(label)
        if plot:
            self.plot(initial_frame)
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the video loading logic handles all edge cases, especially when video is `None`.

# Test: Search for other usages of `load_video` method to ensure consistency. Expect: Consistent handling of `None` video across the application.
rg --type python $'load_video'

Length of output: 60



Script:

#!/bin/bash
# Description: Verify that the video loading logic handles all edge cases, especially when video is `None`.

# Test: Search for other usages of `load_video` method to ensure consistency. Expect: Consistent handling of `None` video across the application.
rg 'load_video' --glob '*.py'

Length of output: 1196



Script:

#!/bin/bash
# Description: Extract the `load_video` method implementations to verify handling of `None` video.

# Extract the `load_video` method from `sleap/gui/widgets/video.py`
ast-grep --lang python --pattern $'def load_video($_, $_):\n    $$$' sleap/gui/widgets/video.py

# Extract the `load_video` method from `sleap/gui/dialogs/importvideos.py`
ast-grep --lang python --pattern $'def load_video($_, $_, $_):\n    $$$' sleap/gui/dialogs/importvideos.py

# Extract the `load_video` method from `sleap/io/video.py`
ast-grep --lang python --pattern $'def load_video($_, $_):\n    $$$' sleap/io/video.py

Length of output: 289



Script:

#!/bin/bash
# Description: Extract the `load_video` method implementations to verify handling of `None` video.

# Extract the `load_video` method from `sleap/gui/widgets/video.py`
ast-grep --lang python --pattern $'def load_video(self, video: Video, plot=True):\n    $$$' sleap/gui/widgets/video.py

# Extract the `load_video` method from `sleap/gui/dialogs/importvideos.py`
ast-grep --lang python --pattern $'def load_video(self, video: Video, initial_frame=0, plot=True):\n    $$$' sleap/gui/dialogs/importvideos.py

# Extract the `load_video` method from `sleap/io/video.py`
ast-grep --lang python --pattern $'def load_video(filename: str, *args, **kwargs):\n    $$$' sleap/io/video.py

Length of output: 2768

sleap/gui/app.py Outdated
Comment on lines 1720 to 1748
# def set_current_video(self, video):
# """Sets the current video and updates the video player and other related UI components."""
# self.state['video'] = video
# self.update_video_player(video) # Make sure this method exists in the player
# self.update_related_views(video) # Update other views that might depend on the video

# def update_video_player(self, video):
# """Updates the video player with a new video."""
# if hasattr(self, 'player') and self.player:
# self.player.set_video(video) # Make sure the video player has this method

# def update_related_views(self, video):
# """Updates other views in the UI that might depend on the video being changed."""
# self.plotFrame() # Refresh the frame view if necessary

# def set_video(self, video):
# """Load video into the video player."""
# self.video_source = video # Store the video source for later use
# self.load_video() # Make sure this method exists in the player

# def set_current_video(self, video):
# """Sets the current video in the state and updates the GUI accordingly."""
# self.state["video"] = video
# self.on_data_update([UpdateTopic.video])

# def reset_views(self):
# """Resets views to their default state."""
# self.player.reset_zoom()

Copy link

Choose a reason for hiding this comment

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

Remove commented-out code for clarity and maintainability.

-    # # Sessions menu double click
-    # def set_current_video(self, video):
-    #     """Sets the current video and updates the video player and other related UI components."""
-    #     self.state['video'] = video
-    #     self.update_video_player(video)  # Make sure this method exists in the player
-    #     self.update_related_views(video)  # Update other views that might depend on the video
-        
-    # def update_video_player(self, video):
-    #     """Updates the video player with a new video."""
-    #     if hasattr(self, 'player') and self.player:
-    #         self.player.set_video(video)  # Make sure the video player has this method
-
-    # def update_related_views(self, video):
-    #     """Updates other views in the UI that might depend on the video being changed."""
-    #     self.plotFrame()  # Refresh the frame view if necessary
-
-    # def set_video(self, video):
-    #     """Load video into the video player."""
-    #     self.video_source = video  # Store the video source for later use
-    #     self.load_video()  # Make sure this method exists in the player
-
-    # def set_current_video(self, video):
-    #     """Sets the current video in the state and updates the GUI accordingly."""
-    #     self.state["video"] = video
-    #     self.on_data_update([UpdateTopic.video])
-
-    # def reset_views(self):
-    #     """Resets views to their default state."""
-    #     self.player.reset_zoom()
-
-    # def _initialize_gui(self):
-    #     """Initial setup for GUI components."""
-    #     self.player = QtVideoPlayer(self)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# def set_current_video(self, video):
# """Sets the current video and updates the video player and other related UI components."""
# self.state['video'] = video
# self.update_video_player(video) # Make sure this method exists in the player
# self.update_related_views(video) # Update other views that might depend on the video
# def update_video_player(self, video):
# """Updates the video player with a new video."""
# if hasattr(self, 'player') and self.player:
# self.player.set_video(video) # Make sure the video player has this method
# def update_related_views(self, video):
# """Updates other views in the UI that might depend on the video being changed."""
# self.plotFrame() # Refresh the frame view if necessary
# def set_video(self, video):
# """Load video into the video player."""
# self.video_source = video # Store the video source for later use
# self.load_video() # Make sure this method exists in the player
# def set_current_video(self, video):
# """Sets the current video in the state and updates the GUI accordingly."""
# self.state["video"] = video
# self.on_data_update([UpdateTopic.video])
# def reset_views(self):
# """Resets views to their default state."""
# self.player.reset_zoom()

Comment on lines 1 to 14
<html>
<head><title>404 Not Found</title></head>
<body>
<h1>404 Not Found</h1>
<ul>
<li>Code: NoSuchKey</li>
<li>Message: The specified key does not exist.</li>
<li>Key: archive/Anaconda3-2023.04-MacOSX-x86_64.sh</li>
<li>RequestId: JN3NZ482V2KEXBWF</li>
<li>HostId: 0GXC8ZHyNDkFKx1qq4jrODGfQsL1teYcmq3W66a2rLSMAgrpIb5V6F3tUmkLB4Bd6VYiTe20VLw=</li>
</ul>
<hr/>
</body>
</html>
Copy link

Choose a reason for hiding this comment

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

The file appears to be an HTML error page instead of a shell script.

This indicates that the script Anaconda3-2023.04-MacOSX-x86_64.sh might not exist at the specified location, leading to a 404 error. Please verify the URL or provide an alternative download source.

Comment on lines 4 to 19
def encode_video(input_file, output_file):
"""Encode a video using ffmpeg with specified parameters."""
command = [
'ffmpeg', '-y',
'-i', input_file,
'-c:v', 'libx264',
'-pix_fmt', 'yuv420p',
'-preset', 'superfast',
'-crf', '23',
output_file
]
try:
subprocess.run(command, check=True)
print(f"Encoding completed: {output_file}")
except subprocess.CalledProcessError:
print(f"An error occurred during encoding: {input_file}")
Copy link

Choose a reason for hiding this comment

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

Enhance error handling in the encode_video function.

Consider raising an exception or returning a status code after an encoding failure, instead of just printing an error message. This would allow calling functions to handle errors more effectively.

Comment on lines 21 to 29
def encode_directory(directory):
"""Encodes all .mp4 files in the specified directory."""
for filename in os.listdir(directory):
if filename.endswith(".mp4"):
input_file = os.path.join(directory, filename)
output_file = os.path.join(directory, os.path.splitext(filename)[0] + '_encoded.mp4')
print(f"Starting encoding: {input_file}")
encode_video(input_file, output_file)

Copy link

Choose a reason for hiding this comment

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

Add error handling for file access issues in encode_directory.

Consider adding error handling for potential exceptions that can arise from os.listdir and file access permissions. This will make the function more robust and prevent it from failing silently in case of issues.

@codecov
Copy link

codecov bot commented May 18, 2024

Codecov Report

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

Project coverage is 74.08%. Comparing base (ddeb083) to head (05889f9).

Files Patch % Lines
sleap/gui/widgets/video.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##           liezl/add-gui-elements-for-sessions    #1763   +/-   ##
====================================================================
  Coverage                                74.07%   74.08%           
====================================================================
  Files                                      135      135           
  Lines                                    25261    25264    +3     
====================================================================
+ Hits                                     18713    18716    +3     
  Misses                                    6548     6548           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

"""
if self.is_activatable:
self.state[self.row_name] = self.getSelectedRowItem()
print("Activated:", self.row_name, self.state[self.row_name])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove debugging print

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.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ab2f363 and 4c2dc0b.
Files selected for processing (1)
  • sleap/gui/scripts/reencoder.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sleap/gui/scripts/reencoder.py

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.

Actionable comments posted: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4c2dc0b and ecb2f87.
Files selected for processing (3)
  • sleap/gui/app.py (1 hunks)
  • sleap/gui/scripts/reencoder.py (1 hunks)
  • sleap/gui/widgets/docks.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • sleap/gui/scripts/reencoder.py
Additional Context Used
Ruff (4)
sleap/gui/app.py (1)

261-261: Local variable filename is assigned to but never used

sleap/gui/widgets/docks.py (3)

15-15: Redefinition of unused QLabel from line 12


16-16: Redefinition of unused QComboBox from line 8


18-18: Redefinition of unused QGroupBox from line 10

Additional comments not posted (2)
sleap/gui/widgets/docks.py (1)

674-674: Double-click functionality added to unlinked_videos_table by making it activatable.

sleap/gui/app.py (1)

1835-1836: Well-implemented drop event handling.

The method effectively parses the filenames and checks for supported file types, raising an appropriate error for unsupported types.

sleap/gui/app.py Outdated
Comment on lines 1835 to 1837
if __name__ == "__main__":
ds = os.environ["dsmview"]
main([ds])
Copy link

Choose a reason for hiding this comment

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

Add error handling for environment variable access.

-    ds = os.environ["dsmview"]
+    ds = os.environ.get("dsmview", "default_value")  # Replace 'default_value' with an appropriate default

Consider adding error handling or a default value when accessing the 'dsmview' environment variable to prevent potential KeyError if it's not set.

Committable suggestion was skipped due low confidence.

Copy link
Contributor

@roomrys roomrys left a comment

Choose a reason for hiding this comment

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

Remove some of the extra files please. Also, I don't see that the videos were reencoded. Can you add the re-encoded videos here (their binaries should have changed which should have been picked up by git).

sleap/gui/app.py Outdated
Comment on lines 1835 to 1837
if __name__ == "__main__":
ds = os.environ["dsmview"]
main([ds])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if __name__ == "__main__":
ds = os.environ["dsmview"]
main([ds])

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.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
sleap/gui/widgets/video.py (3)

Line range hint 27-75: Move module-level imports to the top of the file.

+ from collections import deque
+ import atexit
+ import math
+ import time
+ from typing import Callable, List, Optional, Union
+ import numpy as np
+ import qimage2ndarray
+ from qtpy import QtCore, QtWidgets
+ from qtpy.QtCore import QLineF, QMarginsF, QPointF, QRectF, Qt
+ from qtpy.QtGui import (
+     QBrush,
+     QColor,
+     QCursor,
+     QFont,
+     QImage,
+     QKeyEvent,
+     QKeySequence,
+     QMouseEvent,
+     QPainter,
+     QPainterPath,
+     QPen,
+     QPixmap,
+     QPolygonF,
+     QTransform,
+ )
+ from qtpy.QtWidgets import (
+     QApplication,
+     QGraphicsEllipseItem,
+     QGraphicsItem,
+     QGraphicsObject,
+     QGraphicsPolygonItem,
+     QGraphicsRectItem,
+     QGraphicsScene,
+     QGraphicsTextItem,
+     QGraphicsView,
+     QShortcut,
+     QVBoxLayout,
+     QWidget,
+ )
+ import sleap
+ from sleap.gui.color import ColorManager
+ from sleap.gui.shortcuts import Shortcuts
+ from sleap.gui.state import GuiState
+ from sleap.gui.widgets.slider import VideoSlider
+ from sleap.instance import Instance, Point, PredictedInstance
+ from sleap.io.video import Video
+ from sleap.prefs import prefs
+ from sleap.skeleton import Node

Line range hint 307-307: Replace the bare except with a more specific exception type.

- except:
+ except Exception as e:
+     # Log or handle the exception as needed

Line range hint 1471-1471: Remove the unused local variable in_bounds.

- in_bounds = True
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ecb2f87 and 2abc178.
Files ignored due to path filters (12)
  • tests/data/videos/centered_pair_small.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/dance.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_back.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_backL.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_mid.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_midL.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_side.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_sideL.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_top.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/min_session_topL.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/small_robot.mp4 is excluded by !**/*.mp4, !**/*.mp4
  • tests/data/videos/small_robot_3_frame.mp4 is excluded by !**/*.mp4, !**/*.mp4
Files selected for processing (1)
  • sleap/gui/widgets/video.py (1 hunks)
Additional Context Used
Ruff (21)
sleap/gui/widgets/video.py (21)

27-27: Module level import not at top of file


28-28: Module level import not at top of file


29-29: Module level import not at top of file


30-30: Module level import not at top of file


32-32: Module level import not at top of file


33-33: Module level import not at top of file


34-34: Module level import not at top of file


35-35: Module level import not at top of file


36-51: Module level import not at top of file


52-65: Module level import not at top of file


67-67: Module level import not at top of file


68-68: Module level import not at top of file


69-69: Module level import not at top of file


70-70: Module level import not at top of file


71-71: Module level import not at top of file


72-72: Module level import not at top of file


73-73: Module level import not at top of file


74-74: Module level import not at top of file


75-75: Module level import not at top of file


307-307: Do not use bare except


1471-1471: Local variable in_bounds is assigned to but never used

self.state.connect("show labels", self.plot)
self.state.connect("show edges", self.plot)
self.state.connect("video", self.load_video)
self.state.connect("unlinked_video", self.load_video)
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The signal unlinked_video is not properly defined in the codebase. It is referenced in several places, but there is no definition for it as a signal.

  • sleap/gui/widgets/video.py: self.state.connect("unlinked_video", self.load_video)

Please ensure that unlinked_video is defined as a signal in the appropriate class or module.

Analysis chain

Ensure the unlinked_video signal is properly defined and connected.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the signal 'unlinked_video' is properly defined and used elsewhere in the codebase.

# Test: Search for the definition of 'unlinked_video' as a signal.
rg --type py 'unlinked_video ='

# Test: Search for the connection of 'unlinked_video' signal.
rg --type py 'connect\("unlinked_video"'

Length of output: 270



Script:

#!/bin/bash
# Description: Verify that the signal 'unlinked_video' is properly defined and used elsewhere in the codebase.

# Test: Search for any mention of 'unlinked_video' in the codebase.
rg --type py 'unlinked_video'

Length of output: 2267

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.

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
sleap/gui/widgets/docks.py (3)

Line range hint 15-15: Remove duplicate import of QLabel.

- from qtpy.QtWidgets import QLabel

Line range hint 16-16: Remove duplicate import of QComboBox.

- from qtpy.QtWidgets import QComboBox

Line range hint 18-18: Remove duplicate import of QGroupBox.

- from qtpy.QtWidgets import QGroupBox
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2abc178 and 561df75.
Files selected for processing (1)
  • sleap/gui/widgets/docks.py (1 hunks)
Additional Context Used
Ruff (3)
sleap/gui/widgets/docks.py (3)

15-15: Redefinition of unused QLabel from line 12


16-16: Redefinition of unused QComboBox from line 8


18-18: Redefinition of unused QGroupBox from line 10

Additional comments not posted (1)
sleap/gui/widgets/docks.py (1)

676-676: Ensure the is_activatable attribute is properly utilized in the UnlinkVideoTable.

This change aligns with the PR's objective to enhance the double-click functionality of the UnlinkVideoTable. Make sure to verify that the is_activatable attribute is correctly handled in the event listeners and that it integrates well with the existing GUI logic.

@roomrys roomrys merged commit 00f9a3b into liezl/add-gui-elements-for-sessions May 29, 2024
@roomrys roomrys deleted the ramiz/add-doubleclick-functionality-unlinkvideotable branch May 29, 2024 23:42
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.

4 participants