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

Remove task_subsets from ProjectWriteSerializer #8492

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

SpecLad
Copy link
Contributor

@SpecLad SpecLad commented Oct 1, 2024

Motivation and context

This is a generated field, so it makes no sense to write it. In practice, attempting to do so when creating a project causes a crash in ProjectWriteSerializer.create, while doing it when updating a project has no effect.

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

    • Introduced new API endpoints for managing cloud storages, comments, issues, jobs, tasks, and webhooks.
    • Enhanced reporting capabilities with updated schemas for Analytics and Quality metrics.
  • Bug Fixes

    • Removed the non-functional task_subsets parameter from project creation and update endpoints to streamline the API.

Copy link
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The changes involve the removal of the task_subsets parameter from project creation and update endpoints, streamlining the API. The ProjectWriteSerializer class has been updated to eliminate the task_subsets field, and the corresponding methods have been adjusted. Additionally, new API endpoints for managing cloud storages, comments, issues, jobs, tasks, and webhooks have been introduced, alongside updates to various schemas to enhance the API's functionality and reporting capabilities.

Changes

Files Change Summary
changelog.d/20241001_131450_roman.md, cvat/apps/engine/serializers.py, cvat/schema.yml Removed task_subsets parameter from project endpoints and ProjectWriteSerializer. Added multiple new API endpoints for managing resources and updated various schemas for enhanced functionality.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant Serializer

    Client->>API: Create/Update Project (without task_subsets)
    API->>Serializer: Validate Data
    Serializer-->>API: Data Validated
    API-->>Client: Response with Project Details
Loading

🐰 In the meadow, changes bloom,
The API sheds its extra gloom.
New paths to follow, clear and bright,
With endpoints ready, what a sight!
Hop along, let’s celebrate,
A simpler code, oh, isn’t it great! 🌼


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.

This is a generated field, so it makes no sense to write it. In practice,
attempting to do so when creating a project causes a crash in
`ProjectWriteSerializer.create`, while doing it when updating a project has
no effect.
@SpecLad SpecLad marked this pull request as ready for review October 1, 2024 10:18
Copy link

sonarqubecloud bot commented Oct 1, 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 (5)
changelog.d/20241001_131450_roman.md (1)

1-5: LGTM with minor suggestions for improvement.

The changelog entry accurately reflects the changes described in the PR objectives. It's concise, clear, and provides a useful reference to the PR.

To make it even more informative, consider:

  1. Briefly mentioning the motivation (e.g., "to prevent crashes and remove ineffective code").
  2. Specifying the affected API or module (e.g., "in the ProjectWriteSerializer").

These additions would provide more context for users and developers reading the changelog.

cvat/apps/engine/serializers.py (4)

Line range hint 1387-1393: Consider adding docstring for better documentation

While the class is well-structured, adding a docstring to explain its purpose and any important details would improve documentation and maintainability.


Line range hint 1455-1460: Consider adding error handling for label updates

While the update_child_objects_on_labels_update method is called when labels are updated, it might be beneficial to add some error handling or logging in case of any issues during the update process.


Line range hint 1517-1522: Consider deprecating the compatibility method

The get_has_related_context method is used for compatibility with version 2.3.0. Consider adding a deprecation warning and plan to remove this in future versions to maintain clean code.

import warnings

@extend_schema_field(serializers.BooleanField)
def get_has_related_context(self, obj: dict) -> bool:
    warnings.warn("get_has_related_context is deprecated and will be removed in future versions", DeprecationWarning)
    return obj['related_files'] != 0

Line range hint 1568-1571: Consider adding type checking in to_internal_value

The to_internal_value method currently converts all values to strings. Consider adding type checking to ensure that only appropriate types are converted, preventing potential issues with unexpected input types.

def to_internal_value(self, data):
    if not isinstance(data['value'], (str, int, float, bool)):
        raise serializers.ValidationError("Invalid type for 'value'")
    data['value'] = str(data['value'])
    return super().to_internal_value(data)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0b7fc51 and 84fdcbb.

📒 Files selected for processing (3)
  • changelog.d/20241001_131450_roman.md (1 hunks)
  • cvat/apps/engine/serializers.py (1 hunks)
  • cvat/schema.yml (0 hunks)
💤 Files with no reviewable changes (1)
  • cvat/schema.yml
🔇 Additional comments (12)
cvat/apps/engine/serializers.py (12)

Line range hint 1381-1385: LGTM: Field definitions are appropriate

The field definitions for ProjectWriteSerializer look good. They include necessary fields like labels, owner_id, assignee_id, and storage-related fields. The use of write_only=True for sensitive fields is a good practice.


Line range hint 1395-1423: LGTM: Create method is well-implemented

The create method is properly implemented with the following good practices:

  1. Use of @transaction.atomic for data consistency.
  2. Proper handling of label creation.
  3. Configuring source/target storages for import/export.
  4. Setting assignee_updated_date when an assignee is provided.

Line range hint 1425-1453: LGTM: Update method handles necessary changes

The update method correctly handles updates to various fields, including labels and assignee. The use of @transaction.atomic ensures data consistency during updates.


Line range hint 1462-1503: LGTM: Validate method ensures proper label mapping

The validate method does a good job of ensuring that all labels can be mapped when moving a project. It checks for both top-level labels and sublabels, which is crucial for maintaining data integrity.


Line range hint 1505-1509: LGTM: AboutSerializer is concise and appropriate

The AboutSerializer is well-defined with appropriate fields and max_lengths for name, description, and version. It's a simple and effective serializer for its purpose.


Line range hint 1511-1515: LGTM: FrameMetaSerializer structure is appropriate

The FrameMetaSerializer is well-structured with relevant fields for frame metadata. The use of IntegerField for width, height, and related_files is appropriate.


Line range hint 1524-1529: LGTM: PluginsSerializer is concise and clear

The PluginsSerializer is well-defined, using boolean fields to represent the status of various plugins. This structure is simple and effective for its purpose.


Line range hint 1531-1556: LGTM: DataMetaReadSerializer is comprehensive and well-structured

The DataMetaReadSerializer provides a thorough representation of data metadata. Notable points:

  1. Appropriate use of FrameMetaSerializer for the 'frames' field.
  2. Clear constraints on fields like 'image_quality'.
  3. Helpful explanation for 'included_frames' using help_text.

The structure effectively captures all necessary metadata for the Data model.


Line range hint 1549-1553: Good use of help_text for clarity

The custom help_text for the 'size' field provides clear explanation of what the field represents, which is particularly helpful for API users.


Line range hint 1558-1562: LGTM: DataMetaWriteSerializer is appropriately minimal

The DataMetaWriteSerializer is correctly designed to only allow modification of the 'deleted_frames' field. This approach limits the risk of unintended changes to other metadata fields during write operations.


Line range hint 1564-1566: LGTM: AttributeValSerializer structure is appropriate

The AttributeValSerializer correctly defines the necessary fields 'spec_id' and 'value' with appropriate types and constraints.


Line range hint 1-2077: Overall, the serializers are well-implemented with minor improvement opportunities

After reviewing several key serializers in this file, the overall implementation appears to be solid and well-structured. The serializers appropriately handle various aspects of the CVAT system, from projects and tasks to data metadata and attributes.

Some minor suggestions for improvement include:

  1. Adding docstrings to complex serializers for better documentation.
  2. Considering deprecation of compatibility methods.
  3. Enhancing type checking in certain methods.

These small changes could further improve the code's maintainability and robustness. Great job on the implementation overall!

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.35%. Comparing base (c9754a9) to head (84fdcbb).
Report is 5 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8492      +/-   ##
===========================================
+ Coverage    74.34%   74.35%   +0.01%     
===========================================
  Files          394      394              
  Lines        42216    42211       -5     
  Branches      3896     3896              
===========================================
+ Hits         31387    31388       +1     
+ Misses       10829    10823       -6     
Components Coverage Δ
cvat-ui 78.75% <ø> (+0.01%) ⬆️
cvat-server 70.48% <63.63%> (+0.01%) ⬆️

@SpecLad SpecLad merged commit 99669f5 into cvat-ai:develop Oct 1, 2024
42 of 43 checks passed
@SpecLad SpecLad deleted the rm-task-subsets branch October 1, 2024 11:14
@cvat-bot cvat-bot bot mentioned this pull request Oct 1, 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
Development

Successfully merging this pull request may close these issues.

2 participants