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

Fix GT label changing to Manual in Ground Truth Job #8938

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

rahulharpal1603
Copy link

@rahulharpal1603 rahulharpal1603 commented Jan 13, 2025

Motivation and context

Fixes #8874

How has this been tested?

Here is a demo video showing that the GT label doesn't change to Manual in a Ground Truth Job:
In this video, I have also shown that the Ground Truth label is assigned only when we are annotating in the ground truth job. When we are annotating in a normal job, the annotation has a Manual label or any other depending on the source.

2025-01-13.19-21-19.mp4

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

  • Bug Fixes
    • Fixed an issue where the Ground Truth (GT) label would unexpectedly change to manual during annotation editing
    • Ensured GT label remains consistent when making modifications to annotations

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

The pull request addresses an issue with Ground Truth (GT) job label handling during annotation editing. Specifically, the changes focus on preventing the unexpected transformation of the GT label to manual when modifying annotations. The modification occurs in the computeNewSource function within the annotations-objects.ts file, ensuring that the GT source remains consistent during edit operations.

Changes

File Change Summary
cvat-core/src/annotations-objects.ts Modified computeNewSource function to explicitly return Source.GT when the current source is GT, preventing unintended source changes
changelog.d/20250113_214825_rahulharpal91_GT_Job_Error.md Added changelog entry documenting the GT label handling fix

Assessment against linked issues

Objective Addressed Explanation
Prevent GT source changing to manual during annotation edit [#8874]
Maintain Ground Truth source consistency

Poem

🐰 In the realm of labels, a rabbit's delight,
GT stays true, no manual's might!
With code so precise, a source that won't sway,
Annotations dance their ground truth way! 🏷️
Hop, hop, hooray! 🎉

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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

🧹 Nitpick comments (2)
cvat-core/src/annotations-objects.ts (2)

57-59: Add explanatory comment for GT source preservation.

Consider adding a comment to explain why GT source needs to be preserved, making the intention clear for future maintenance.

    if ([Source.AUTO, Source.SEMI_AUTO].includes(currentSource)) {
        return Source.SEMI_AUTO;
    }
+   // Preserve Ground Truth source to prevent GT labels from changing to Manual
    if (currentSource === Source.GT) {
        return Source.GT;
    }

Line range hint 4-4: Add unit tests for computeNewSource function.

The function lacks unit tests to verify its behavior with different source types, especially the GT source preservation logic.

Consider adding tests like:

describe('computeNewSource', () => {
    it('should preserve GT source', () => {
        expect(computeNewSource(Source.GT)).toBe(Source.GT);
    });

    it('should convert AUTO to SEMI_AUTO', () => {
        expect(computeNewSource(Source.AUTO)).toBe(Source.SEMI_AUTO);
    });

    it('should preserve SEMI_AUTO source', () => {
        expect(computeNewSource(Source.SEMI_AUTO)).toBe(Source.SEMI_AUTO);
    });

    it('should default to MANUAL for other sources', () => {
        expect(computeNewSource(Source.MANUAL)).toBe(Source.MANUAL);
    });
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42bc345 and 4891616.

📒 Files selected for processing (2)
  • changelog.d/20250113_214825_rahulharpal91_GT_Job_Error.md (1 hunks)
  • cvat-core/src/annotations-objects.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • changelog.d/20250113_214825_rahulharpal91_GT_Job_Error.md
🔇 Additional comments (2)
cvat-core/src/annotations-objects.ts (2)

57-59: LGTM! The fix correctly preserves GT source.

The implementation properly maintains the Ground Truth source during annotation modifications, which should fix the issue where GT labels were incorrectly changing to Manual.


57-59: Verify the fix in different editing scenarios.

While the implementation looks correct, please verify that the GT source is preserved in various editing scenarios:

  • Modifying points/boundaries
  • Rotating shapes
  • Changing attributes
  • Moving annotations
✅ Verification successful

GT source preservation verified across all editing scenarios

The implementation correctly preserves GT source across all shape modifications including points/boundaries, rotation, attributes, and movement operations. The source field is properly protected and tracked in the history for undo/redo operations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all places where computeNewSource is used to ensure consistent behavior

# Search for direct function calls
echo "Direct function calls:"
rg "computeNewSource" -A 3

# Search for source modifications in shape operations
echo "\nShape operations affecting source:"
ast-grep --pattern 'this.source = $_'

Length of output: 9531

@rahulharpal1603
Copy link
Author

@zhiltsov-max I have added the patch for the issue #8874. Should I also add tests for this fix? Or it is not necessary ?

@zhiltsov-max zhiltsov-max requested review from klakhov and removed request for bsekachev and nmanovic January 14, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editing / redo-ing annotation edit in the GT job changes the shape source from "ground truth" to "manual"
1 participant