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

Optimize annotations import #8226

Merged
merged 6 commits into from
Jul 31, 2024
Merged

Conversation

Bobronium
Copy link
Contributor

@Bobronium Bobronium commented Jul 29, 2024

Motivation and context

Decided to split changes in this PR: #8223

  1. Annotations import (this PR)
  2. Array fields optimization (Lazy list for array field #8229)
  3. Logging function optimization (Remove deepcopy from handle_annotations_change #8228)

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

    • Improved data type consistency for shape points during the annotation loading process, ensuring all coordinates are treated as numeric values.
    • Enhanced clarity and reliability in loading various shape types (box, ellipse, cuboid, mask) by converting relevant attributes to floats.
  • Bug Fixes

    • Removed redundant database initialization calls during annotation import, potentially improving the efficiency of the import process.

@Bobronium Bobronium requested a review from zhiltsov-max as a code owner July 29, 2024 13:28
Copy link
Contributor

coderabbitai bot commented Jul 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 recent changes enhance the processing and type consistency of shape annotations within the CVAT dataset management system. By refining the way points are handled—specifically converting them to floats—they improve the clarity and maintainability of the code. Additionally, alterations in initialization logic for task and job annotations streamline the import process, potentially optimizing performance while ensuring reliable data handling.

Changes

Files Change Summary
cvat/apps/dataset_manager/bindings.py
cvat/apps/dataset_manager/formats/cvat.py
Updated methods to ensure shape points are explicitly converted to floats for consistency and reliability across different shape types, enhancing maintainability.
cvat/apps/dataset_manager/task.py Removed init_from_db() calls from the import_task_annotations and import_job_annotations functions, altering the initialization logic for annotations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Importer
    participant AnnotationDB

    User->>Importer: Start Annotation Import
    Importer->>AnnotationDB: Fetch Annotations
    AnnotationDB-->>Importer: Return Annotations
    Importer->>Importer: Convert Points to Floats
    Importer->>User: Complete Import
Loading

🐰 In the code garden where annotations play,
The points now float, come what may!
With clarity shining, bugs kept at bay,
Oh joyful changes, hip-hip-hooray!
Each shape a delight, in its numeric array!


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 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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9306dce and 146cfdc.

Files selected for processing (3)
  • cvat/apps/dataset_manager/bindings.py (2 hunks)
  • cvat/apps/dataset_manager/formats/cvat.py (2 hunks)
  • cvat/apps/dataset_manager/task.py (2 hunks)
Additional comments not posted (9)
cvat/apps/dataset_manager/task.py (2)

Line range hint 686-686:
Verify the initialization logic for TaskAnnotation.

The removal of init_from_db() suggests a change in how TaskAnnotation objects are initialized. Ensure that the necessary data is being handled correctly elsewhere.


Line range hint 699-699:
Verify the initialization logic for JobAnnotation.

The removal of init_from_db() suggests a change in how JobAnnotation objects are initialized. Ensure that the necessary data is being handled correctly elsewhere.

cvat/apps/dataset_manager/formats/cvat.py (7)

1226-1229: Ensure consistent float conversion for box shape points.

The conversion of xtl, ytl, xbr, and ybr to floats ensures type consistency.


1231-1234: Ensure consistent float conversion for ellipse shape points.

The conversion of cx, cy, rx, and ry to floats ensures type consistency.


1236-1252: Ensure consistent float conversion for cuboid shape points.

The conversion of xtl1, ytl1, xbl1, ybl1, xtr1, ytr1, xbr1, ybr1, xtl2, ytl2, xbl2, ybl2, xtr2, ytr2, xbr2, and ybr2 to floats ensures type consistency.


1285-1288: Ensure consistent float conversion for box shape points.

The conversion of xtl, ytl, xbr, and ybr to floats ensures type consistency.


1290-1293: Ensure consistent float conversion for ellipse shape points.

The conversion of cx, cy, rx, and ry to floats ensures type consistency.


1295-1299: Ensure consistent float conversion for mask shape points.

The conversion of rle, left, top, width, and height to floats ensures type consistency.


1301-1317: Ensure consistent float conversion for cuboid shape points.

The conversion of xtl1, ytl1, xbl1, ybl1, xtr1, ytr1, xbr1, ybr1, xtl2, ytl2, xbl2, ybl2, xtr2, ytr2, xbr2, and ybr2 to floats ensures type consistency.

cvat/apps/dataset_manager/bindings.py Outdated Show resolved Hide resolved
cvat/apps/dataset_manager/bindings.py Outdated Show resolved Hide resolved
@Bobronium Bobronium changed the title Optimize annotatiosn import Optimize annotations import Jul 29, 2024
@Bobronium Bobronium mentioned this pull request Jul 29, 2024
7 tasks
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 44.06780% with 33 lines in your changes missing coverage. Please review.

Project coverage is 83.33%. Comparing base (9306dce) to head (bf024aa).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8226      +/-   ##
===========================================
+ Coverage    83.30%   83.33%   +0.02%     
===========================================
  Files          388      388              
  Lines        41352    41353       +1     
  Branches      3856     3856              
===========================================
+ Hits         34450    34462      +12     
+ Misses        6902     6891      -11     
Components Coverage Δ
cvat-ui 79.68% <ø> (+0.05%) ⬆️
cvat-server 86.60% <44.06%> (+<0.01%) ⬆️

@Bobronium Bobronium mentioned this pull request Jul 29, 2024
7 tasks
zhiltsov-max pushed a commit that referenced this pull request Jul 31, 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
Decided to split changes in this PR:
#8223

1. Annotations import (#8226)
2. Array fields optimization (#8229)
3. Logging function optimization (this PR)

### 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! -->
- [x] 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

- [x] 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

- **Bug Fixes**
- Improved data integrity by ensuring annotations change handling occurs
every time an item is deleted.

- **New Features**
- Enhanced data filtering logic for annotations, allowing for more
efficient processing without unnecessary deep copies.
- Introduced a new function for streamlined filtering of track data,
simplifying data management.

- **Refactor**
- Consolidated data filtering into reusable functions for better
maintainability and clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Copy link

@zhiltsov-max zhiltsov-max merged commit cfce7be into develop Jul 31, 2024
33 checks passed
zhiltsov-max pushed a commit that referenced this pull request Aug 6, 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
Decided to split changes in this PR:
#8223

1. Annotations import (#8226)
2. Array fields optimization (this PR)
3. Logging function optimization
(#8228)

### 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! -->
- [x] 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

- [x] 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**
- Introduced the `LazyList` class for efficient, on-demand parsing of
list elements from strings.
- Added support for custom transformations through a converter function.
- Enhanced lazy evaluation with new decorators for improved performance
on list operations.
  
- **Tests**
- Implemented a comprehensive test suite for the `LazyList` class,
validating core functionalities and ensuring robustness.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@bsekachev bsekachev deleted the dont-load-annotations-on-import branch August 12, 2024 09:08
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