Closed roomrys closed 5 months ago
The recent updates introduce significant enhancements to the handling and management of FrameGroup
objects in both the GUI and I/O components of the software. Key modifications include the transition from FrameGroup
to InstanceGroup
in the GUI, along with expanded functionalities in the cameras.py
module to better manage instances and labeled frames across different views.
Files | Change Summary |
---|---|
sleap/gui/commands.py sleap/io/cameras.py |
Updated FrameGroup to InstanceGroup in GUI commands and added new functionalities for managing FrameGroup objects in I/O cameras. |
tests/gui/test_commands.py tests/io/test_cameras.py |
Removed outdated tests in GUI related to triangulation and updated tests in I/O to cover new FrameGroup functionalities. |
๐๐
In the land of code where the data hops,
A change was made at the treetops.
FrameGroup
dances, nowInstanceGroup
sings,
Across the wires, data flutters its wings.
Cheers to the bytes, in harmony they mesh,
For in this update, our systems refresh.
๐ผ๐
tests/io/test_cameras.py (1)
`418-447`: The tests for `FrameGroup` correctly verify the creation from instance groups and the management of frame indices. Ensure that the shared registry of frame indices behaves as expected in concurrent scenarios.Verification successful
--- The search results from the script provide insights into the usage of `_frame_idx_registry` within the codebase. The references found in `tests/io/test_cameras.py` and `sleap/io/cameras.py` indicate that `_frame_idx_registry` is used to track frame indices across different instances of `FrameGroup` and within the `RecordingSession` context. From the output: 1. In `test_cameras.py`, the tests verify the behavior of `_frame_idx_registry` by asserting its contents after creating `FrameGroup` instances. This confirms that the test checks the shared registry behavior as intended. 2. In `cameras.py`, `_frame_idx_registry` is initialized as an empty dictionary and is used to add frame indices as they are processed. This suggests that the class handles the addition of new frame indices and ensures that they are tracked correctly across sessions. Given this information, the implementation and testing of `_frame_idx_registry` appear to be consistent with the expectations set in the review comment. The tests in `test_cameras.py` are aligned with the implementation in `cameras.py`, verifying the correct behavior of the frame index registry.Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Search for any concurrent modifications to `_frame_idx_registry` across the codebase. rg --type python '_frame_idx_registry' --context 5 ``` Length of output: 81 --- --- Script: ```shell #!/bin/bash # Corrected search for any concurrent modifications to `_frame_idx_registry` across the codebase. rg '_frame_idx_registry' --type py --context 5 ``` Length of output: 3968tests/gui/test_commands.py (1)
Line range hint `227-299`: The tests for `ExportAnalysisFile` cover various scenarios effectively, including different file formats and conditions with no labeled frames. Ensure that the export functionality handles edge cases as expected.Verification successful
It appears that the previous script failed due to an unrecognized file type specification for `rg`. The correct usage should not specify the file type as `python` since `rg` does not recognize it by default. Instead, we should use a more general approach or specify the file extensions directly. Let's correct this and rerun the script to ensure we can verify the usage of `ExportAnalysisFile` across the codebase effectively. --- The search results confirm the usage of `ExportAnalysisFile` within the `tests/gui/test_commands.py` and `sleap/gui/commands.py` files. The test cases in `test_commands.py` extensively use the `ExportAnalysisFile` class to test various scenarios, including exporting with different parameters and handling different file formats. The class is also referenced in `sleap/gui/commands.py` where it is used to execute export operations with specific parameters. From the output, it is evident that the `ExportAnalysisFile` class is integral to the functionality of exporting analysis files in different formats and is well-integrated into the GUI command structure. The tests cover a wide range of scenarios ensuring that the functionality behaves as expected under various conditions. Given this comprehensive integration and testing, the changes in the `test_ExportAnalysisFile` function and the usage of `ExportAnalysisFile` across the codebase are verified to be consistent and correctly implemented.Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Search for any additional usage of `ExportAnalysisFile` that might affect its behavior in edge cases. rg --type python 'ExportAnalysisFile' --context 5 ``` Length of output: 80 --- --- Script: ```shell #!/bin/bash # Search for any additional usage of `ExportAnalysisFile` that might affect its behavior in edge cases. rg 'ExportAnalysisFile' --context 5 --type py ``` Length of output: 12138sleap/gui/commands.py (3)
Line range hint `1712-1712`: Avoid using bare `except` statements. Specify the exception types to handle specific errors appropriately. --- Line range hint `1733-1733`: Avoid using bare `except` statements. It's a good practice to specify the exceptions you are catching. --- Line range hint `3145-3145`: Avoid using bare `except` statements. It's a good practice to specify the exceptions you are catching.
Attention: Patch coverage is 46.15385%
with 133 lines
in your changes are missing coverage. Please review.
Project coverage is 73.60%. Comparing base (
95071c1
) to head (a99cef5
).:exclamation: Current head a99cef5 differs from pull request most recent head ff0924e. Consider uploading reports for the commit ff0924e to get more accurate results
Files | Patch % | Lines |
---|---|---|
sleap/io/cameras.py | 46.15% | 133 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Description
This PR adds the
FrameGroup
class which is akin to aLabeledFrame
but across all views in aRecordingSession
. The tasks to do here are:FrameGroup
classRecordingSession
FrameGroup
FrameGroup
FrameGroup
hypotheses generation methodAdd
FrameGroup
classFrameGroup
to theRecordingSession
through aFrameGroup.session
instance attributeFrameGroup.frame_idx
instance attribute_frame_idx_registry
class attribute to ensure theFrameGroup
is unique perRecordingSession
andframe_idx
frame_idx
andsession
are unique to thisFrameGroup
upon initializationInstanceGroup
s in the currentFrameGroup
viaFrameGroup.instance_groups
_labeled_frames_by_cam: Dict[Camcorder, LabeledFrame]
_labeled_frames_by_cam
each time aLabeledFrame
is added/removed from theFrameGroup.session.labels: Labels
object_labeled_frames_by_cam
each time aVideo
is added/removed from theFrameGroup.session: RecordingSession
object_labeled_frames_by_cam
to return a list ofLabeledFrame
s in thelabeled_frames
property_labeled_frames_by_cam
to return a list ofCamcorders
in thecameras
propertyFrameGroup
from aList[InstanceGroup]
(andRecordingSession
andframe_idx
)FrameGroup
from aDict[Camcorder, List[Instance]]
(andRecordingSession
andframe_idx
)Integrate with
RecordingSession
RecordingSession._frame_group_by_frame_idx: Dict[int, FrameGroup]
attribute to store all knownFrameGroup
s by theirframe_idx
(also used to ensure uniqueness ofFrameGroup
s)RecordingSesssion._frame_group_by_frame_idx
in aRecordingSession.frame_group -> Dict[int, FrameGroup]
propertyRecordingSesssion._frame_group_by_frame_idx
in aRecordingSession.frame_inds -> List[int]
propertyfrom_session_dict
method to reconstructFrameGroup
sto_session_dict
method to write aFrameGroup
to an slpSerialize/Deserialize
FrameGroup
FrameGroup.make_cattr
methodLabeledFrame.instances
RecordingSession
supdate_locked_instances_by_cam
Add a hypothesis generation with
FrameGroup.generate_hypotheses
InstanceGroup
s are locked (or set by the user) inFrameGroup._locked_instance_groups: List[InstanceGroup]
FrameGroup._locked_instance_groups
whenever anInstanceGroup
is added/removed/locked/unlockedCamcorder
s to include in theFrameGroup
as a class attributeFrameGroup._cams_to_include: Optional[List[Camcorder]]
_cams_to_include
in thecams_to_include
property to return either the list ofCamcorder
s in_cams_to_include
or the list ofCamcorder
s inFrameGroup.session.camera_cluster.cameras
_instances_by_cam: Dict[Camcorder, Set[Instance]]
as an instance attribute_instances_by_cam
similarly to_labeled_frames_by_cam
_instances_by_cam
in theinstances_by_cams_to_include
property to only returnDict[Camcorder, Set[Instance]]
from thecams_to_include
generate_hypotheses
method which usesinstances_by_cams_to_include
to gather all unlocked instances across views, fill in the "missing" instances in each view, permute all unlocked instances, take products of unlocked instances, and reorganize products intogrouping_hypotheses: Dict[frame_id: int, List[InstanceGroup]]
ORgrouping_hypotheses: Dict[frame_id: int, Dict[Camcorder, List[Instance]]]
Use
FrameGroup
hypotheses generation methodTriangulateSession
with thesession.frame_group[frame_idx].generate_hypotheses()
TriangulateSession
uses the "cached" reprojections from all hypotheses to just update theInstance
s inTriangulateSession.do_action()
, but we also need a way to trangulate, reproject, and updateInstance
s without doing hypothesis testingOthers (not needed for this PR, but got distracted and added anyway)
RecordingSession.linked_cameras
s.t. the ordering followsRecordingSession.cameras
RecordingSession.unlinked_cameras
s.t. the ordering followsRecordingSession.cameras
RecordingSession.camera_cluster._videos_by_session[RecordingSession]
s.t. the ordering followsRecordingSession.cameras
(this is useful when navigating through views in the GUI)Fig 1: Three different flavors of the flow chart plan with the middle plan being the most complete, but the top being the easiest (the bottom is just unneeded work).
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