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

Improved Ground truth tags #8586

Merged
merged 8 commits into from
Oct 29, 2024
Merged

Improved Ground truth tags #8586

merged 8 commits into from
Oct 29, 2024

Conversation

klakhov
Copy link
Contributor

@klakhov klakhov commented Oct 23, 2024

Motivation and context

Fixed several issues:

  • GT tags are rendered with (GT) mark inside of GT job which is not correct
  • GT tags can not be deleted via x button inside the GT job

Other improvements:

  • Refactored frame-tags component code
  • Improved styles for gt/non-gt tags, as they are too close:
    image
    ->
    image

Related #8547

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features

    • Enhanced state management in the FrameTags component for improved performance and readability.
    • Introduced a new CSS class to manage spacing in the tag annotation workspace.
  • Bug Fixes

    • Updated tag filtering logic to improve accuracy in displaying tags.
  • Refactor

    • Simplified component structure by utilizing hooks for state management.
    • Optimized rendering logic and performance with memoization.

@klakhov klakhov requested a review from bsekachev as a code owner October 23, 2024 08:55
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes in this pull request involve modifications to the FrameTags component in the frame-tags.tsx file, transitioning from react-redux's connect to hooks like useDispatch and useSelector. This simplifies state management by removing mapStateToProps and mapDispatchToProps. Additionally, a new CSS class is introduced in the styles.scss file to manage spacing for the canvas annotation frame tags, while existing styles remain unchanged.

Changes

File Path Change Summary
cvat-ui/src/components/annotation-page/tag-annotation-workspace/frame-tags.tsx Transitioned to useDispatch and useSelector, removed mapStateToProps and mapDispatchToProps, updated onRemoveState, added tagClassName function, and exported component using React.memo.
cvat-ui/src/components/annotation-page/tag-annotation-workspace/styles.scss Added new CSS class .cvat-canvas-annotation-frame-tags with margin-bottom property.

Poem

In the workspace where tags do play,
A rabbit hops and shouts hooray! 🐇
With hooks and styles, the code's refined,
A cleaner path for all to find.
Margins set, the tags align,
A joyful leap, all things divine! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@klakhov klakhov added the ui/ux label Oct 23, 2024
Copy link
Contributor

@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)
cvat-ui/src/components/annotation-page/tag-annotation-workspace/styles.scss (1)

100-102: LGTM! Consider adding a comment for better maintainability.

The new class appropriately uses the design system's grid unit for consistent spacing and follows the project's naming conventions.

Consider adding a brief comment to document the purpose of this class:

+// Adds vertical spacing between frame tags in the canvas annotation view
.cvat-canvas-annotation-frame-tags {
    margin-bottom: $grid-unit-size;
}
cvat-ui/src/components/annotation-page/tag-annotation-workspace/frame-tags.tsx (2)

Line range hint 19-41: Consider adding explicit return type for tagClassName

The implementation looks good, but we could improve type safety slightly.

-    const tagClassName = useCallback((tag: ObjectState) => {
+    const tagClassName = useCallback((tag: ObjectState): string => {

Line range hint 61-78: Add missing closable prop for GT tags

The GT tags are missing the closable prop which is needed to show the delete button. This might be why GT tags couldn't be deleted as mentioned in the PR objectives.

                         <Tag
                             className={tagClassName(tag)}
                             color={tag.label.color}
                             onClose={() => {
                                 onRemoveState(tag);
                             }}
                             key={tag.clientID}
+                            closable
                         >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6a26362 and 9cfe0c8.

📒 Files selected for processing (2)
  • cvat-ui/src/components/annotation-page/tag-annotation-workspace/frame-tags.tsx (4 hunks)
  • cvat-ui/src/components/annotation-page/tag-annotation-workspace/styles.scss (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
cvat-ui/src/components/annotation-page/tag-annotation-workspace/frame-tags.tsx (4)

8-16: LGTM: Clean migration to React hooks

The transition from Redux connect HOC to hooks (useDispatch, useSelector) improves code maintainability and follows modern React practices.


Line range hint 44-60: LGTM: Proper handling of regular tags

The implementation correctly filters and renders non-GT tags with proper removal functionality.


84-84: LGTM: Proper use of React.memo

Good optimization to prevent unnecessary re-renders of the component.


45-45: Verify styling improvements

The PR objectives mention improvements to GT and non-GT tag styling. Let's verify the CSS classes are properly styled.

Also applies to: 62-62

✅ Verification successful

Let me try a different search strategy to find the styling information.


Based on the search results, I can now generate a final response as we have found the styling information in the codebase.

Styling improvements are properly implemented

The styling changes are well-structured and properly implemented in cvat-ui/src/components/annotation-page/tag-annotation-workspace/styles.scss:

  • Base tag styling with .cvat-frame-tags class provides consistent layout with centered content
  • .cvat-frame-tag and .cvat-frame-tag-highlighted classes handle tag appearance and hover effects
  • .cvat-canvas-annotation-frame-tags provides proper spacing with margin
  • The styling supports both GT and non-GT tags through proper class inheritance
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related CSS classes in styles.scss files
rg -l "cvat-canvas-annotation-frame-tags|cvat-canvas-ground-truth-frame-tags|cvat-frame-tag" --type scss

Length of output: 135


Script:

#!/bin/bash
# Search for related CSS classes in all files, not limiting to scss
rg -l "cvat-canvas-annotation-frame-tags|cvat-canvas-ground-truth-frame-tags|cvat-frame-tag"

# Also search for any style-related content for these classes
rg "\.cvat-canvas-annotation-frame-tags|\.cvat-canvas-ground-truth-frame-tags|\.cvat-frame-tag" -A 5

Length of output: 4935

@klakhov klakhov requested a review from nmanovic as a code owner October 23, 2024 09:30
@klakhov klakhov removed the request for review from nmanovic October 23, 2024 09:31
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.28%. Comparing base (37586c0) to head (ab1f74e).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8586      +/-   ##
===========================================
+ Coverage    74.25%   74.28%   +0.03%     
===========================================
  Files          403      403              
  Lines        43315    43315              
  Branches      3914     3914              
===========================================
+ Hits         32162    32177      +15     
+ Misses       11153    11138      -15     
Components Coverage Δ
cvat-ui 78.77% <ø> (+0.07%) ⬆️
cvat-server 70.47% <ø> (ø)

Copy link

@klakhov klakhov merged commit 251054b into develop Oct 29, 2024
34 checks passed
@klakhov klakhov deleted the kl/improve-gt-tags branch October 29, 2024 11:19
@cvat-bot cvat-bot bot mentioned this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants