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

fixing problems with skeleton tracks with missing points #8377

Merged
merged 13 commits into from
Sep 5, 2024

Conversation

Eldies
Copy link
Contributor

@Eldies Eldies commented Aug 29, 2024

Motivation and context

fixing #7783
also fixing related problem - some jobs from the issue can not be opened in ui due to missing shapes

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 data integrity in annotation processing by adding filtering steps before sorting.
    • New entries for "many jobs skeleton tracks with missing shapes" and "many jobs skeleton" added to the dataset, improving job tracking capabilities and complex job definitions.
    • Introduced a new static method for annotation creation, improving code modularity and reusability.
  • Bug Fixes

    • Improved error handling in annotation functions to prevent runtime errors when accessing potentially undefined variables.
  • Tests

    • Expanded the testing framework with new tests for annotation creation scenarios, ensuring comprehensive coverage.

Copy link
Contributor

coderabbitai bot commented Aug 29, 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 involve modifications to the annotation processing logic in the CVAT codebase. Key updates include adding filtering steps to prevent errors when sorting annotations, enhancing safety checks in functions handling shapes, and introducing new entries in JSON files to support skeleton tracks. Additionally, the test suite has been refactored to improve annotation creation logic and to add tests for new functionalities.

Changes

Files Change Summary
cvat-core/src/annotations-objects.ts Updated SkeletonTrack class to filter out falsy annotation values before sorting.
cvat/apps/dataset_manager/annotation.py Enhanced has_overlap and _modify_unmatched_object functions with additional safety checks.
cvat/apps/dataset_manager/tests/assets/annotations.json Added new entry for "many jobs skeleton tracks with missing shapes" to support skeleton tracking.
cvat/apps/dataset_manager/tests/assets/tasks.json Added new entry "many jobs skeleton" with detailed label and sublabel definitions.
cvat/apps/dataset_manager/tests/test_rest_api_formats.py Introduced _make_annotations_for_task method and refactored annotation creation tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AnnotationManager
    participant AnnotationProcessor

    User->>AnnotationManager: Create task
    AnnotationManager->>AnnotationProcessor: Process annotations
    AnnotationProcessor->>AnnotationProcessor: Filter out falsy values
    AnnotationProcessor->>AnnotationProcessor: Sort valid annotations
    AnnotationProcessor->>AnnotationManager: Return processed annotations
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent import crash when skeleton track has no shapes (#7783)
Enhance safety checks in annotation processing logic (#7783)
Ensure comprehensive testing of annotation creation process (#7783)

Poem

🐇
In fields of code, I hop with glee,
Changes made, oh what a spree!
Skeleton tracks now dance and play,
Safe from crashes, come what may!
With tests to guard, our work is bright,
Hooray for fixes, all feels right!
🌼


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

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 61a7f34 and 168d512.

Files selected for processing (5)
  • cvat-core/src/annotations-objects.ts (1 hunks)
  • cvat/apps/dataset_manager/annotation.py (2 hunks)
  • cvat/apps/dataset_manager/tests/assets/annotations.json (1 hunks)
  • cvat/apps/dataset_manager/tests/assets/tasks.json (1 hunks)
  • cvat/apps/dataset_manager/tests/test_rest_api_formats.py (3 hunks)
Additional comments not posted (9)
cvat/apps/dataset_manager/tests/assets/tasks.json (1)

341-381: LGTM!

The new entry "many jobs skeleton" is well-structured and consistent with the existing entries in the file.

cvat/apps/dataset_manager/tests/assets/annotations.json (1)

419-462: LGTM!

The new entry "many jobs skeleton tracks with missing shapes" is well-structured and consistent with the existing entries in the file.

cvat/apps/dataset_manager/annotation.py (2)

94-94: LGTM!

The change ensures that the function first verifies that prev_shape is not None before attempting to access its properties, thereby preventing potential runtime errors when prev_shape is undefined.


555-556: LGTM!

The addition of the guard clause enhances the robustness of the function by ensuring it handles cases where there are no shapes gracefully.

cvat/apps/dataset_manager/tests/test_rest_api_formats.py (4)

Line range hint 239-304: LGTM!

The static method _make_annotations_for_task is correctly implemented and encapsulates the logic for creating annotations based on a task.


306-309: LGTM!

The refactoring of the _create_annotations method to utilize the new static method _make_annotations_for_task improves code clarity and reduces redundancy.


312-314: LGTM!

The refactoring of the _create_annotations_in_job method to call the new static method _make_annotations_for_task improves code clarity and reduces redundancy.


1266-1302: LGTM!

The new test method test_api_v2_check_skeleton_tracks_with_missing_shapes is comprehensive and covers various scenarios for validating the functionality of creating annotations in tasks with specific conditions.

cvat-core/src/annotations-objects.ts (1)

2921-2921: LGTM!

The change to filter out falsy values from the annotations array before sorting enhances the robustness of the sorting operation.

@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.59%. Comparing base (d80a574) to head (2caddcc).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8377      +/-   ##
===========================================
+ Coverage    83.57%   83.59%   +0.01%     
===========================================
  Files          396      396              
  Lines        41898    41900       +2     
  Branches      3881     3881              
===========================================
+ Hits         35018    35028      +10     
+ Misses        6880     6872       -8     
Components Coverage Δ
cvat-ui 79.56% <100.00%> (+0.03%) ⬆️
cvat-server 87.18% <100.00%> (+<0.01%) ⬆️

@Bobronium
Copy link
Member

Seems like SonarCloud Code Analysis is failing because of the addition of _make_annotations_for_task. Now, I see that it actually reduced complexity compared to previous implementation, however since it's technically a new function, SonarCloud feels entitled to complain.

I suggest either refactoring this function further to meet the complexity criteria: Refactor this function to reduce its Cognitive Complexity from 75 to the 15 allowed., or figuring out the way to suppress the warning. I couldn't quickly find it, but I imagine there has to be one.

Otherwise LGTM!

@Bobronium Bobronium self-requested a review September 2, 2024 09:19
@Eldies Eldies force-pushed the dl/skeleton_tracks_with_missing_shapes branch from 805e08b to 8d7053a Compare September 2, 2024 10:44
@Eldies
Copy link
Contributor Author

Eldies commented Sep 3, 2024

I suggest either refactoring this function

refactored it

Copy link

sonarcloud bot commented Sep 4, 2024

@Eldies Eldies merged commit 510fd98 into develop Sep 5, 2024
33 checks passed
@Eldies Eldies deleted the dl/skeleton_tracks_with_missing_shapes branch September 5, 2024 08:59
@cvat-bot cvat-bot bot mentioned this pull request Sep 9, 2024
@cvat-bot cvat-bot bot mentioned this pull request Sep 10, 2024
bschultz96 pushed a commit to bschultz96/cvat that referenced this pull request Sep 12, 2024
<!-- Raise an issue to propose your change
(https://github.com/cvat-ai/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution guide](https://docs.cvat.ai/docs/contributing/).
-->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->
fixing cvat-ai#7783
also fixing related problem - some jobs from the issue can not be opened
in ui due to missing shapes

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [ ] I submit my changes into the `develop` branch
- [ ] I have created a changelog fragment <!-- see top comment in
CHANGELOG.md -->
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning))

### License

- [ ] I submit _my code changes_ under the same [MIT License](
https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced data integrity in annotation processing by adding filtering
steps before sorting.
- New entries for "many jobs skeleton tracks with missing shapes" and
"many jobs skeleton" added to the dataset, improving job tracking
capabilities and complex job definitions.
- Introduced a new static method for annotation creation, improving code
modularity and reusability.

- **Bug Fixes**
- Improved error handling in annotation functions to prevent runtime
errors when accessing potentially undefined variables.

- **Tests**
- Expanded the testing framework with new tests for annotation creation
scenarios, ensuring comprehensive coverage.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

4 participants