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

Update Datumaro format #7125

Merged
merged 36 commits into from
Nov 25, 2024
Merged

Update Datumaro format #7125

merged 36 commits into from
Nov 25, 2024

Conversation

zhiltsov-max
Copy link
Contributor

@zhiltsov-max zhiltsov-max commented Nov 10, 2023

Motivation and context

Fixes #5424
Fixes #7375
Fixes #8700

Depends on cvat-ai/datumaro#34

This PR improves quality of life when using Datumaro format.

  • Added support for direct .json uploading of annotations, similarly to the COCO and CVAT formats
  • Added image metadata when exporting in the Datumaro format without images
  • For related images in 3d tasks, datumaro export without images will include only the basenames (before: absolute server paths were exported)
  • Refactored conv_mask_to_poly uses to avoid code and logic duplication (will be in another PR)

How has this been tested?

Unit tests

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
    • Introduced support for direct .json file import in Datumaro format.
  • Bug Fixes
    • Fixed an issue where exporting without images in Datumaro format now correctly includes image information.
  • Refactor
    • Renamed classes and methods in dataset management to support a broader range of media types, enhancing the system's flexibility.
  • Tests
    • Added new tests to verify the behavior of importing and exporting in Datumaro format, ensuring robustness in dataset handling.

Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #7125 (6e08d4b) into develop (c87cb3b) will decrease coverage by 0.01%.
Report is 1 commits behind head on develop.
The diff coverage is 96.29%.

@@             Coverage Diff             @@
##           develop    #7125      +/-   ##
===========================================
- Coverage    82.58%   82.57%   -0.01%     
===========================================
  Files          362      362              
  Lines        39264    39264              
  Branches      3578     3578              
===========================================
- Hits         32426    32424       -2     
- Misses        6838     6840       +2     
Components Coverage Δ
cvat-ui 77.66% <ø> (-0.10%) ⬇️
cvat-server 87.02% <96.29%> (+0.07%) ⬆️

@zhiltsov-max zhiltsov-max removed the request for review from azhavoro November 28, 2023 08:33
@zhiltsov-max zhiltsov-max marked this pull request as draft November 29, 2023 18:48
zhiltsov-max added a commit that referenced this pull request Apr 5, 2024
<!-- Raise an issue to propose your change
(https://github.com/opencv/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://opencv.github.io/cvat/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. -->

Closes #7703
Related: #7258
Related: #7125
Related: #7699

Changes:
cvat-ai/datumaro@8a14a99...82982b1

- Fixed WiderFace dataset example
- Fixed export without images in Datumaro format - no empty `media` and
`point_cloud` fields should be in the results

### 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/opencv/cvat/tree/develop/cvat-canvas#versioning),

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

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

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

### License

- [ ] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
@zhiltsov-max zhiltsov-max marked this pull request as ready for review April 5, 2024 15:01
@nmanovic
Copy link
Contributor

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Apr 25, 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 updates enhance the CVAT tool by introducing support for JSON imports in Datumaro format and improving media handling capabilities. Changes include renaming classes to support various media types, refining error handling in export/import functions, and adding new test methods to ensure robustness in handling Datumaro files.

Changes

File Change Summary
changelog.d/20231110_175126_mzhiltso_update_dm_export-added.md
changelog.d/20231110_175127_mzhiltso_update_dm_export-fixed.md
Introduced support for direct .json file import in Datumaro format. Fixed exporting without images in Datumaro format to include image information.
cvat/apps/dataset_manager/bindings.py Renamed classes and methods from "Image" to "Media" to support various media types.
cvat/apps/dataset_manager/formats/datumaro.py Enhanced handling of ZIP and JSON files in export and import functions; added zipfile import.
tests/python/rest_api/test_projects.py
tests/python/rest_api/test_tasks.py
Added tests to verify Datumaro JSON import functionality and image information inclusion in exports without annotations.

Assessment against linked issues

Objective Addressed Explanation
Image size included in Datumaro format when exported without images (#5424) The issue was addressed by fixing the export to include image information even when exporting without images.
Related images included when exporting 3D datasets (#7375) The changes related to 3D dataset exports were not explicitly mentioned in the provided summaries. Further inspection in the code is needed to confirm if this issue has been fully addressed.

Poem

🐰✨
In the land of code where the data hops around,
A rabbit tweaked the tools found on the ground.
From images to media, the changes do spread,
JSON dances in, with new tests ahead.
Celebrate the updates, oh how they gleam—
In the world of CVAT, a coder's dream! 🌟🎉
🐰✨


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.

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

Out of diff range and nitpick comments (3)
cvat/apps/dataset_manager/bindings.py (1)

Line range hint 1926-1926: Change the membership test from not in to in to correct the logic.

- if not frame_number in instance_data.frame_info:
+ if frame_number not in instance_data.frame_info:
tests/python/rest_api/test_tasks.py (2)

775-821: LGTM! The test method test_datumaro_export_without_annotations_includes_image_info is well-structured and covers the necessary checks.

Consider adding a comment explaining the selection criteria for the task in the setup phase to enhance readability and maintainability.


2722-2757: LGTM! The test method test_can_import_datumaro_json correctly tests the import functionality for the Datumaro JSON format.

Consider adding a comment explaining the selection criteria for the task in the setup phase to enhance readability and maintainability.

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

Out of diff range and nitpick comments (2)
cvat/apps/dataset_manager/bindings.py (1)

Line range hint 1927-1927: Use not in for membership testing.

- if not frame_number in instance_data.frame_info:
+ if frame_number not in instance_data.frame_info:
tests/python/rest_api/test_tasks.py (1)

59-62: Consider adding a docstring to _DATUMARO_FORMAT_FOR_DIMENSION for better code documentation.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 082caf1 and e43f131.
Files selected for processing (2)
  • cvat/apps/dataset_manager/bindings.py (13 hunks)
  • tests/python/rest_api/test_tasks.py (3 hunks)
Additional Context Used
Ruff (11)
cvat/apps/dataset_manager/bindings.py (1)

1927-1927: Test for membership should be not in

tests/python/rest_api/test_tasks.py (10)

350-350: f-string without any placeholders


1136-1136: f-string without any placeholders


1703-1703: f-string without any placeholders


1829-1829: Ambiguous variable name: l


1849-1849: Ambiguous variable name: l


1850-1850: Ambiguous variable name: l


1865-1865: Ambiguous variable name: l


1876-1876: Ambiguous variable name: l


1890-1890: Ambiguous variable name: l


2379-2379: f-string without any placeholders

Additional comments not posted (25)
tests/python/rest_api/test_tasks.py (25)

Line range hint 63-67: LGTM! The function get_cloud_storage_content is concise and appears to handle cloud storage content retrieval effectively.


Line range hint 69-74: LGTM! The method _test_task_list_200 effectively tests the task list retrieval functionality.


Line range hint 76-86: LGTM! The method _test_users_to_see_task_list correctly implements visibility checks for task lists based on user roles.


Line range hint 88-98: LGTM! The method _test_assigned_users_to_see_task_data effectively tests the visibility of task data for assigned users.


Line range hint 100-112: LGTM! The method test_project_tasks_visibility correctly tests the visibility of project tasks based on user roles and permissions.


Line range hint 114-122: LGTM! The method test_task_assigned_to_see_task effectively tests the visibility of assigned tasks to specific users.


Line range hint 124-138: LGTM! The method test_org_project_tasks_visibility correctly tests the visibility of organizational project tasks based on user roles.


Line range hint 140-148: LGTM! The method test_org_task_assigneed_to_see_task effectively tests the visibility of assigned tasks to specific users in an organization.


Line range hint 150-160: LGTM! The method test_can_get_job_validation_summary correctly tests the retrieval of job validation summaries.


Line range hint 162-172: LGTM! The method test_can_get_job_completed_summary correctly tests the retrieval of job completion summaries.


Line range hint 174-186: LGTM! The method test_can_remove_owner_and_fetch_with_sdk effectively tests the removal of a task owner and subsequent data retrieval.


Line range hint 188-194: LGTM! The method setup correctly sets up the testing environment for the class TestListTasksFilters.


Line range hint 196-200: LGTM! The method test_can_use_simple_filter_for_object_list effectively tests the functionality of simple filters for object lists.


Line range hint 202-207: LGTM! The method _test_create_task_201 effectively tests the creation of a task with a 201 status code.


Line range hint 209-214: LGTM! The method _test_create_task_403 effectively tests the creation of a task with a 403 status code, indicating forbidden access.


Line range hint 216-226: LGTM! The method _test_users_to_create_task_in_project effectively tests whether different users can create tasks within a project based on their roles and permissions.


Line range hint 228-238: LGTM! The method test_users_to_create_task_in_project correctly tests the ability of users to create tasks in a project based on their roles.


Line range hint 240-250: LGTM! The method test_worker_cannot_create_task_in_project_without_ownership effectively tests whether workers can create tasks in a project without having ownership.


Line range hint 252-262: LGTM! The method test_create_response_matches_get effectively tests whether the response from creating a task matches the data retrieved from a subsequent GET request.


Line range hint 264-286: LGTM! The method test_can_create_task_with_skeleton effectively tests the creation of a task with complex skeleton annotations.


Line range hint 288-299: LGTM! The method test_frame_content_type effectively tests the content type of frames retrieved from tasks.


Line range hint 301-307: LGTM! The method _test_check_response effectively checks the response status and data after patching task annotations.


Line range hint 309-319: LGTM! The method request_data effectively prepares data for patching task annotations by modifying points and incrementing the version.


Line range hint 321-339: LGTM! The method test_user_update_task_annotations effectively tests the ability of users to update task annotations based on their privileges and roles.


Line range hint 341-359: LGTM! The method test_member_update_task_annotation effectively tests the ability of organization members to update task annotations based on their roles.

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 73.33333% with 24 lines in your changes missing coverage. Please review.

Project coverage is 74.18%. Comparing base (3eec9fe) to head (ea91c87).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #7125   +/-   ##
========================================
  Coverage    74.18%   74.18%           
========================================
  Files          401      401           
  Lines        43510    43523   +13     
  Branches      3950     3950           
========================================
+ Hits         32278    32288   +10     
- Misses       11232    11235    +3     
Components Coverage Δ
cvat-ui 78.55% <ø> (+0.05%) ⬆️
cvat-server 70.45% <73.33%> (-0.05%) ⬇️

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
4.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@zhiltsov-max zhiltsov-max requested review from Eldies and removed request for nmanovic November 19, 2024 15:16
@zhiltsov-max zhiltsov-max merged commit d79e056 into develop Nov 25, 2024
33 of 34 checks passed
@zhiltsov-max zhiltsov-max deleted the zm/update-dm-format branch November 25, 2024 13:50
@cvat-bot cvat-bot bot mentioned this pull request Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants