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

Fixed skeleton selection algorithm #7921

Merged
merged 3 commits into from
May 21, 2024
Merged

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented May 21, 2024

Motivation and context

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

  • Bug Fixes

    • Fixed an issue where selecting a skeleton by cursor was not functioning correctly when hidden points were present.
  • Refactor

    • Improved readability and performance in SkeletonShape class by using an array for distance calculations.
    • Updated shape type comparisons in the canvas to use enum values instead of string literals.
  • Chores

    • Adjusted access levels of various methods within the Collection class for better encapsulation and usage.

@bsekachev bsekachev requested a review from nmanovic as a code owner May 21, 2024 06:38
Copy link
Contributor

coderabbitai bot commented May 21, 2024

Warning

Rate Limit Exceeded

@bsekachev has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 10 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 7dd38c6 and fc10f5a.

Walkthrough

This update addresses various improvements and fixes across multiple files in the codebase. Key changes include fixing skeleton selection issues, modifying method access levels in the Collection class, refactoring distance calculations in SkeletonShape, and updating shape type comparisons in the CanvasWrapperComponent class. These enhancements aim to improve functionality, readability, and performance.

Changes

Files Change Summary
changelog.d/20240521_093739_boris_fixed_skeletons_selection.md Documented the fix for selecting skeletons by cursor when hidden points are present.
cvat-core/src/annotations-collection.ts Modified access levels of various methods within the Collection class to be public or private as needed.
cvat-core/src/annotations-objects.ts Refactored the SkeletonShape class to use an array distances for calculating the shortest distance from a point to an edge, enhancing readability and performance.
cvat-ui/src/components/annotation-page/canvas/views/.../canvas-wrapper.tsx Updated shape type comparison in the CanvasWrapperComponent class to use enum values instead of string literals.

In code's vast fields, where changes bloom,
A fix for skeletons dispels the gloom.
Methods now clear, access defined,
Distance refactored, performance refined.
Shapes in enums, a cleaner sight,
The code evolves, shining bright. 🌟


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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 146e188 and 7dd38c6.
Files selected for processing (4)
  • changelog.d/20240521_093739_boris_fixed_skeletons_selection.md (1 hunks)
  • cvat-core/src/annotations-collection.ts (16 hunks)
  • cvat-core/src/annotations-objects.ts (1 hunks)
  • cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx (1 hunks)
Additional Context Used
LanguageTool (1)
changelog.d/20240521_093739_boris_fixed_skeletons_selection.md (1)

Near line 3: Possible missing preposition found.
Context: ### Fixed - Selection a skeleton by cursor does not work correc...

Additional comments not posted (16)
cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx (1)

811-811: Use enum values for shape type comparisons.

Ensure this change is covered by unit tests to verify that the behavior remains consistent.

cvat-core/src/annotations-collection.ts (15)

777-777: Ensure the clear method correctly handles the clearing of annotations within specified frames or entirely.


218-218: Review the error handling in _mergeInternal for consistency and completeness.

Verification successful

The error handling in the _mergeInternal method appears to be consistent and complete. The method throws ArgumentError exceptions when encountering unknown shapeType values or missing elements in the skeleton structure. Additionally, it catches and rethrows errors with additional context when merging skeleton parts.

  • The method checks for valid shapeType values and throws an ArgumentError if an unknown type is encountered.
  • It ensures that all required sublabels are present when merging skeletons and throws an ArgumentError if any are missing.
  • It catches errors during the recursive merging of skeleton parts and rethrows them with additional context.

Based on the extracted code, the error handling is thorough and addresses potential issues that could arise during the merging process.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Review the error handling in `_mergeInternal` for consistency and completeness.

# Test: Search for the method usage. Expect: Consistent and complete error handling.
rg --type python $'_mergeInternal'

Length of output: 64



Script:

#!/bin/bash
# Description: Review the error handling in `_mergeInternal` for consistency and completeness.

# Test: Search for the method definition and usage. Expect: Consistent and complete error handling.
rg --type ts '_mergeInternal'

Length of output: 427



Script:

#!/bin/bash
# Extract the definition of the `_mergeInternal` method and its usage for review.

# Extract the method definition
rg --type ts --context 10 '_mergeInternal' cvat-core/src/annotations-collection.ts

Length of output: 2522


458-458: Validate the splitting logic in _splitInternal to ensure it correctly handles track and shape division.

Verification successful

The _splitInternal method in cvat-core/src/annotations-collection.ts appears to handle the splitting of tracks and shapes correctly. It creates two copies of the track, one for frames before the split and one for frames after. It also recursively handles elements if the object is a SkeletonTrack.

  • The method clears server IDs, creates copies of the track, and adjusts the shapes accordingly.
  • It ensures that the shapes are correctly marked as outside for the split frame.
  • For SkeletonTrack objects, it recursively splits the elements.

The logic seems sound and correctly handles the division of tracks and shapes.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Validate the splitting logic in `_splitInternal` to ensure it correctly handles track and shape division.

# Test: Search for the method usage. Expect: Correct handling of track and shape division.
rg --type python $'_splitInternal'

Length of output: 64



Script:

#!/bin/bash
# Description: Validate the splitting logic in `_splitInternal` to ensure it correctly handles track and shape division.

# Test: Search for the method usage in TypeScript files. Expect: Correct handling of track and shape division.
rg --type ts '_splitInternal'

Length of output: 429



Script:

#!/bin/bash
# Description: Extract the implementation and usage context of `_splitInternal` to verify its splitting logic.

# Extract the implementation of `_splitInternal`
rg --type ts --context 10 '_splitInternal' cvat-core/src/annotations-collection.ts

Length of output: 2514


1152-1152: Ensure the select method accurately determines the closest object state based on the provided coordinates.

Verification successful

The select method in annotations-collection.ts is indeed implemented and used in the codebase. The method is defined to select the closest object state based on the provided coordinates. Here are the relevant locations:

  • Definition: cvat-core/src/annotations-collection.ts (line 1152)
  • Usage:
    • cvat-core/src/session-implementation.ts
    • cvat-core/src/session.ts
    • cvat-canvas/src/typescript/canvas-wrapper.tsx

These locations indicate that the select method is integrated into the session and canvas handling logic, ensuring it is used to determine the closest object state based on coordinates.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure the `select` method accurately determines the closest object state based on the provided coordinates.

# Test: Search for the method usage. Expect: Accurate determination of closest object state.
rg --type python $'select'

Length of output: 56



Script:

#!/bin/bash
# Description: Ensure the `select` method accurately determines the closest object state based on the provided coordinates.

# Test: Search for the method usage. Expect: Accurate determination of closest object state.
rg 'select' --type js

Length of output: 46469



Script:

#!/bin/bash
# Description: Ensure the `select` method accurately determines the closest object state based on the provided coordinates.

# Test: Search for the method definition and usage in TypeScript files.
rg 'select' --type ts

Length of output: 82376


119-119: Ensure the import method handles all edge cases for tag, shape, and track creation.


526-526: Ensure the split method correctly handles the splitting of tracks and updates the history accordingly.

Verification successful

The split method in annotations-collection.ts appears to interact with the history object, as indicated by multiple calls to this.history.do. This suggests that the method is indeed updating the history.

  • cvat-core/src/annotations-collection.ts: Multiple instances of this.history.do indicate that history updates are being handled.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure the `split` method correctly handles the splitting of tracks and updates the history accordingly.

# Test: Search for the method usage. Expect: Correct handling and history updates.
rg --type python $'split'

Length of output: 55



Script:

#!/bin/bash
# Description: Ensure the `split` method correctly handles the splitting of tracks and updates the history accordingly.

# Test: Search for the method usage in TypeScript files. Expect: Correct handling and history updates.
rg --type typescript 'split'

# Test: Retrieve the implementation of the `split` method in annotations-collection.ts.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  split(objectState: ObjectState, frame: number): void {
    $$$
  }
  $$$  
}'

Length of output: 200



Script:

#!/bin/bash
# Description: Ensure the `split` method correctly handles the splitting of tracks and updates the history accordingly.

# Test: Search for the method usage in TypeScript files. Expect: Correct handling and history updates.
rg --type ts 'split'

# Test: Retrieve the implementation of the `split` method in annotations-collection.ts.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  split(objectState: ObjectState, frame: number): void {
    $$$
  }
  $$$  
}'

Length of output: 22872



Script:

#!/bin/bash
# Description: Ensure the `split` method correctly handles the splitting of tracks and updates the history accordingly.

# Test: Retrieve the implementation of the `split` method in annotations-collection.ts.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  split(objectState: ObjectState, frame: number): void {
    $$$
  }
  $$$  
}' cvat-core/src/annotations-collection.ts

# Test: Check if the `split` method updates the history.
rg 'history' cvat-core/src/annotations-collection.ts

Length of output: 628


1217-1217: Confirm that _searchEmpty correctly identifies empty frames based on the given parameters.


401-401: Check the logic in merge for handling different object states and ensure it aligns with expected behavior.

Verification successful

The merge method in cvat-core/src/annotations-collection.ts includes checks for object types, ensures objects are in the collection, and handles shape types appropriately. The _mergeInternal method further validates shape types and labels, ensuring consistency.

  • merge method: Validates object states, ensures objects are in the collection, and handles shape types.
  • _mergeInternal method: Validates shape types and labels, ensuring consistency.

These methods appear to handle different object states correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check the logic in `merge` for handling different object states and ensure it aligns with expected behavior.

# Test: Search for the method usage. Expect: Proper handling of different object states.
rg --type python $'merge'

Length of output: 55



Script:

#!/bin/bash
# Description: Check the logic in `merge` for handling different object states and ensure it aligns with expected behavior.

# Test: Search for the method usage in TypeScript files. Expect: Proper handling of different object states.
rg --type ts 'merge'

Length of output: 10921



Script:

#!/bin/bash
# Description: Extract the implementation of the `merge` method and its related internal methods in `cvat-core/src/annotations-collection.ts`.

# Extract the `merge` method implementation
ast-grep --lang typescript --pattern $'class AnnotationsCollection {
  $$$
  public merge(objectStates: ObjectState[]): void {
    $$$
  }
  $$$
}' cvat-core/src/annotations-collection.ts

# Extract the `_mergeInternal` method implementation
ast-grep --lang typescript --pattern $'class AnnotationsCollection {
  $$$
  private _mergeInternal(objectsForMerge: (Track | Shape)[], shapeType: ShapeType, label: Label): SerializedTrack {
    $$$
  }
  $$$
}' cvat-core/src/annotations-collection.ts

Length of output: 441



Script:

#!/bin/bash
# Description: Extract the implementation of the `merge` method and its related internal methods in `cvat-core/src/annotations-collection.ts`.

# Extract the `merge` method implementation
ast-grep --lang typescript --pattern 'public merge(objectStates: ObjectState[]): void { $$$ }' cvat-core/src/annotations-collection.ts

# Extract the `_mergeInternal` method implementation
ast-grep --lang typescript --pattern 'private _mergeInternal(objectsForMerge: (Track | Shape)[], shapeType: ShapeType, label: Label): SerializedTrack { $$$ }' cvat-core/src/annotations-collection.ts

Length of output: 1357



Script:

#!/bin/bash
# Description: Extract the implementation of the `merge` method and its related internal methods in `cvat-core/src/annotations-collection.ts`.

# Extract the `merge` method implementation
ast-grep --lang typescript --pattern 'function merge($_) { $$$ }' cvat-core/src/annotations-collection.ts

# Extract the `_mergeInternal` method implementation
ast-grep --lang typescript --pattern 'function _mergeInternal($_) { $$$ }' cvat-core/src/annotations-collection.ts

Length of output: 224



Script:

#!/bin/bash
# Description: Extract the implementation of the `merge` method and its related internal methods in `cvat-core/src/annotations-collection.ts`.

# Extract the `merge` method implementation
rg 'public merge\(objectStates: ObjectState\[\]\): void' -A 20 cvat-core/src/annotations-collection.ts

# Extract the `_mergeInternal` method implementation
rg 'private _mergeInternal\(objectsForMerge: \(Track \| Shape\)\[\], shapeType: ShapeType, label: Label\): SerializedTrack' -A 20 cvat-core/src/annotations-collection.ts

Length of output: 2263


162-162: Confirm that the export method correctly filters and serializes tracks, shapes, and tags.


608-608: Review the join method to ensure it only allows joining of compatible object types and handles attributes correctly.


961-961: Check the put method for correct handling of object states and integration into the collection.

Verification successful

The put method is defined in cvat-core/src/annotations-collection.ts and is used in several places within the codebase. However, to ensure it handles object states correctly and integrates them into the collection properly, we need to inspect its implementation and usage in detail.


The previous attempts to gather information about the put method's implementation and usage context did not yield results. To ensure we correctly verify the handling of object states and their integration into the collection, we need to refine our approach.


The previous script failed due to a regex parse error. To correct this, we need to escape special characters in the regex pattern.


The put method in cvat-core/src/annotations-collection.ts is responsible for handling object states and integrating them into the collection. The method is used in cvat-core/src/session-implementation.ts for both Job and Task prototypes.

Here is the relevant snippet of the put method implementation:

public put(objectStates: ObjectState[]): number[] {
    checkObjectType('shapes for put', objectStates, null, Array);
    const constructed = {
        shapes: [],
        tracks: [],
        tags: [],
    };

    for (const state of objectStates) {
        checkObjectType('object state', state, null, ObjectState);
        checkObjectType('state client ID', state.clientID, null, null);
        // Additional logic for handling object states...
    }
    // Further processing and return statement...
}

And its usage in cvat-core/src/session-implementation.ts:

Job.prototype.annotations.put.implementation = function (objectStates) {
    return getCollection(this).put(objectStates);
};

Task.prototype.annotations.put.implementation = function (objectStates) {
    return getCollection(this).put(objectStates);
};

The put method appears to validate the input object states and then processes them accordingly. The method is integrated into the Job and Task prototypes, ensuring that object states can be added to these entities.

Based on the gathered information, the put method seems to handle object states correctly and integrates them into the collection as expected.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check the `put` method for correct handling of object states and integration into the collection.

# Test: Search for the method usage. Expect: Proper handling and integration.
rg --type python $'put'

Length of output: 53



Script:

#!/bin/bash
# Description: Check the `put` method for correct handling of object states and integration into the collection.

# Search for the definition of the `put` method in TypeScript files.
rg --type typescript 'put'

# Search for the usage of the `put` method in TypeScript files.
rg --type typescript '\.put\('

Length of output: 129



Script:

#!/bin/bash
# Description: Check the `put` method for correct handling of object states and integration into the collection.

# Search for the definition of the `put` method in TypeScript files.
rg --glob '*.ts' 'put'

# Search for the usage of the `put` method in TypeScript files.
rg --glob '*.ts' '\.put\('

Length of output: 16544



Script:

#!/bin/bash
# Description: Retrieve the implementation of the `put` method and its usage context.

# Extract the implementation of the `put` method from `cvat-core/src/annotations-collection.ts`.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  put(objectStates: ObjectState[]): number[] {
    $$$
  }
  $$$  
}' cvat-core/src/annotations-collection.ts

# Extract the context of the `put` method usage in `cvat-core/src/session-implementation.ts`.
rg --context 5 --glob 'cvat-core/src/session-implementation.ts' 'getCollection(this).put'

Length of output: 256



Script:

#!/bin/bash
# Description: Retrieve the implementation of the `put` method and its usage context.

# Extract the implementation of the `put` method from `cvat-core/src/annotations-collection.ts`.
rg --context 10 --glob 'cvat-core/src/annotations-collection.ts' 'put(objectStates: ObjectState[]): number[]'

# Extract the context of the `put` method usage in `cvat-core/src/session-implementation.ts`.
rg --context 10 --glob 'cvat-core/src/session-implementation.ts' 'getCollection(this).put'

Length of output: 345



Script:

#!/bin/bash
# Description: Retrieve the implementation of the `put` method and its usage context.

# Extract the implementation of the `put` method from `cvat-core/src/annotations-collection.ts`.
rg --context 10 --glob 'cvat-core/src/annotations-collection.ts' 'put\(objectStates: ObjectState\[\]\): number\[\]'

# Extract the context of the `put` method usage in `cvat-core/src/session-implementation.ts`.
rg --context 10 --glob 'cvat-core/src/session-implementation.ts' 'getCollection\(this\)\.put'

Length of output: 4940


693-693: Verify that slice correctly handles the slicing of shapes and updates the collection and history as expected.

Verification successful

The slice method in cvat-core/src/annotations-collection.ts has been successfully extracted. Here is the relevant implementation:

public slice(state: ObjectState, results: number[][]): void {
    if (results.length !== 2) {
        throw new Error('Not supported slicing count');
    }

    const [points1, points2] = results;
    checkObjectType('sliced object id', state, null, ObjectState);
    checkObjectType('first slicing contour', points1, null, Array);
    checkObjectType('second slicing contour', points2, null, Array);

    points1.forEach(
        (el: number) => checkObjectType('first slicing contour element', el, 'number'),
    );
    points2.forEach(
        (el: number) => checkObjectType('second slicing contour element', el, 'number'),
    );

    const slicedObject = this.objects[state.clientID];
    if (!(slicedObject instanceof PolygonShape || slicedObject instanceof MaskShape)) {
        throw new ArgumentError(
            `Only polygon shape or mask shape can be sliced. Got "${slicedObject.constructor.name}"`,
        );
    }

    const { width, height } = this.frameMeta[slicedObject.frame];
    if (slicedObject instanceof MaskShape) {
        points1.push(slicedObject.left, slicedObject.top, slicedObject.right, slicedObject.bottom);
        points2.push(slicedObject.left, slicedObject.top, slicedObject.right, slicedObject.bottom);
    }

    const imported = this.import({
        shapes: [{
            attributes: validateAttributesList(objectAttributesAsList(state)),
            frame: slicedObject.frame,
            group: slicedObject.group,
            label_id: slicedObject.label.id,
            outside: false,
            occluded: slicedObject.occluded,
            points: slicedObject.shapeType === ShapeType.POLYGON ?
                points1 : cropMask(points1, width, height),
            rotation: 0,
            type: slicedObject.shapeType,
            z_order: slicedObject.zOrder,
            source: Source.MANUAL,
            elements: [],
        }, {
            attributes: validateAttributesList(objectAttributesAsList(state)),
            frame: slicedObject.frame,
            group: slicedObject.group,
            label_id: slicedObject.label.id,
            outside: false,
            occluded: slicedObject.occluded,
            points: slicedObject.shapeType === ShapeType.POLYGON ?
                points2 : cropMask(points2, width, height),
            rotation: 0,
            type: slicedObject.shapeType,
            z_order: slicedObject.zOrder,
            source: Source.MANUAL,
            elements: [],
        }],
        tracks: [],
        tags: [],
    });
    slicedObject.removed = true;

    this.history.do(
        HistoryActions.SLICED_OBJECT,
        () => {
            slicedObject.removed = false;
            imported.shapes.forEach((shape) => {
                shape.removed = true;
            });
        },
        () => {
            slicedObject.removed = true;
            imported.shapes.forEach((shape) => {
                shape.removed = false;
            });
        },
        [...imported.shapes.map((object) => object.clientID), slicedObject.clientID],
        slicedObject.frame,
    );
}

This method performs the following steps:

  1. Validates the input parameters.
  2. Checks the type of the object to be sliced.
  3. Handles the slicing logic for both PolygonShape and MaskShape.
  4. Imports the new shapes created by the slicing operation.
  5. Updates the history to allow undo/redo operations.

Based on the extracted implementation, the slice method appears to correctly handle the slicing of shapes and updates the collection and history as expected.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `slice` correctly handles the slicing of shapes and updates the collection and history as expected.

# Test: Search for the method usage. Expect: Correct slicing and updates.
rg --type python $'slice'

Length of output: 55



Script:

#!/bin/bash
# Description: Verify that `slice` correctly handles the slicing of shapes and updates the collection and history as expected.

# Search for the `slice` method in TypeScript files to find its usage.
rg --type ts 'slice'

# Extract the implementation of the `slice` method from the TypeScript file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  slice($_, $_) {
    $$$
  }
  $$$  
}'

Length of output: 29759



Script:

#!/bin/bash
# Description: Verify that `slice` correctly handles the slicing of shapes and updates the collection and history as expected.

# Extract the implementation of the `slice` method from the TypeScript file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  slice(state: ObjectState, results: number[][]): void {
    $$$
  }
  $$$  
}'

Length of output: 136



Script:

#!/bin/bash
# Description: Verify that `slice` correctly handles the slicing of shapes and updates the collection and history as expected.

# Extract the implementation of the `slice` method from the TypeScript file.
ast-grep --lang typescript --pattern $'class AnnotationsCollection {
  $$$
  public slice(state: ObjectState, results: number[][]): void {
    $$$
  }
  $$$  
}'

Length of output: 162



Script:

#!/bin/bash
# Description: Verify that `slice` correctly handles the slicing of shapes and updates the collection and history as expected.

# Extract the implementation of the `slice` method from the TypeScript file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  public slice(state: ObjectState, results: number[][]): void {
    $$$
  }
  $$$  
}'

Length of output: 112331


1263-1263: Review the search method to ensure it correctly identifies frames based on the specified filters and parameters.


567-567: Confirm that group correctly updates object groups and handles history actions properly.


821-821: Review the statistics method to confirm it accurately calculates statistics for all object types and handles sublabels correctly.

Verification successful

The statistics method in cvat-core/src/annotations-collection.ts has been successfully extracted. Here is the implementation:

public statistics(): Statistics {
    const labels = {};
    const shapes = ['rectangle', 'polygon', 'polyline', 'points', 'ellipse', 'cuboid', 'skeleton'];
    const body = {
        ...(shapes.reduce((acc, val) => ({
            ...acc,
            [val]: { shape: 0, track: 0 },
        }), {})),
        mask: { shape: 0 },
        tag: 0,
        manually: 0,
        interpolated: 0,
        total: 0,
    };

    const sep = '{{cvat.skeleton.lbl.sep}}';
    const fillBody = (spec, prefix = ''): void => {
        const pref = prefix ? `${prefix}${sep}` : '';
        for (const label of spec) {
            const { name } = label;
            labels[`${pref}${name}`] = JSON.parse(JSON.stringify(body));

            if (label?.structure?.sublabels) {
                fillBody(label.structure.sublabels, `${pref}${name}`);
            }
        }
    };

    const total = JSON.parse(JSON.stringify(body));
    fillBody(Object.values(this.labels).filter((label) => !label.hasParent));

    const scanTrack = (track, prefix = ''): void => {
        const countInterpolatedFrames = (start: number, stop: number, lastIsKeyframe: boolean): number => {
            let count = stop - start;
            if (lastIsKeyframe) {
                count -= 1;
            }
            for (let i = start + 1; lastIsKeyframe ? i < stop : i <= stop; i++) {
                if (this.frameMeta.deleted_frames[i]) {
                    count--;
                }
            }
            return count;
        };

        const pref = prefix ? `${prefix}${sep}` : '';
        const label = `${pref}${track.label.name}`;
        labels[label][track.shapeType].track++;
        const keyframes = Object.keys(track.shapes)
            .sort((a, b) => +a - +b)
            .map((el) => +el)
            .filter((frame) => !this.frameMeta.deleted_frames[frame]);

        let prevKeyframe = keyframes[0];
        let visible = false;
        for (const keyframe of keyframes) {
            if (visible) {
                const interpolated = countInterpolatedFrames(prevKeyframe, keyframe, true);
                labels[label].interpolated += interpolated;
                labels[label].total += interpolated;
            }
            visible = !track.shapes[keyframe].outside;
            prevKeyframe = keyframe;

            if (visible) {
                labels[label].manually++;
                labels[label].total++;
            }
        }

        let lastKey = keyframes[keyframes.length - 1];
        if (track.shapeType === ShapeType.SKELETON) {
            track.elements.forEach((element) => {
                scanTrack(element, label);
                lastKey = Math.max(lastKey, ...Object.keys(element.shapes).map((key) => +key));
            });
        }

        if (lastKey !== this.stopFrame && !track.get(lastKey).outside) {
            const interpolated = countInterpolatedFrames(lastKey, this.stopFrame, false);
            labels[label].interpolated += interpolated;
            labels[label].total += interpolated;
        }
    };

    for (const object of Object.values(this.objects)) {
        if (object.removed) {
            continue;
        }

        let objectType = null;
        if (object instanceof Shape) {
            objectType = 'shape';
        } else if (object instanceof Track) {
            objectType = 'track';
        } else if (object instanceof Tag) {
            objectType = 'tag';
        } else {
            throw new ScriptingError(`Unexpected object type: "${objectType}"`);
        }

        const { name: label } = object.label;
        if (objectType === 'tag' && !this.frameMeta.deleted_frames[object.frame]) {
            labels[label].tag++;
            labels[label].manually++;
            labels[label].total++;
        } else if (objectType === 'track') {
            scanTrack(object);
        } else if (!this.frameMeta.deleted_frames[object.frame]) {
            const { shapeType } = object as Shape;
            labels[label][shapeType].shape++;
            labels[label].manually++;
            labels[label].total++;
            if (shapeType === ShapeType.SKELETON) {
                (object as SkeletonShape).elements.forEach((element) => {
                    const combinedName = [label, element.label.name].join(sep);
                    labels[combinedName][element.shapeType].shape++;
                    labels[combinedName].manually++;
                    labels[combinedName].total++;
                });
            }
        }
    }

    for (const label of Object.keys(labels)) {
        for (const shapeType of Object.keys(labels[label])) {
            if (typeof labels[label][shapeType] === 'object') {
                for (const objectType of Object.keys(labels[label][shapeType])) {
                    total[shapeType][objectType] += labels[label][shapeType][objectType];
                }
            } else {
                total[shapeType] += labels[label][shapeType];
            }
        }
    }

    return new Statistics(labels, total);
}

The statistics method appears to handle various object types (shapes, tracks, tags) and sublabels correctly. It initializes a structure to hold statistics, iterates over the objects, and updates the statistics accordingly. It also recursively processes sublabels for skeleton shapes.

  • The method initializes a labels object to store statistics for each label.
  • It defines a body structure to hold counts for different shapes and actions.
  • It uses a recursive fillBody function to initialize the statistics structure for each label and its sublabels.
  • It processes tracks with the scanTrack function, which counts interpolated and manually annotated frames.
  • It iterates over all objects, updating the statistics based on their type and label.
  • Finally, it aggregates the statistics into a total object and returns a new Statistics instance.

Based on this analysis, the statistics method seems to accurately calculate statistics for all object types and handle sublabels correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Review the `statistics` method to confirm it accurately calculates statistics for all object types and handles sublabels correctly.

# Test: Search for the method usage. Expect: Accurate calculations and sublabel handling.
rg --type python $'statistics'

Length of output: 60



Script:

#!/bin/bash
# Description: Review the `statistics` method to confirm it accurately calculates statistics for all object types and handles sublabels correctly.

# Search for the `statistics` method definition in TypeScript files.
rg --type ts 'statistics'

# Extract the implementation of the `statistics` method from the relevant file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  statistics() {
    $$$
  }
  $$$  
}'

Length of output: 3853



Script:

#!/bin/bash
# Description: Extract the implementation of the `statistics` method from `cvat-core/src/annotations-collection.ts`.

# Extract the implementation of the `statistics` method from the relevant file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  statistics() {
    $$$
  }
  $$$  
}' cvat-core/src/annotations-collection.ts

Length of output: 136



Script:

#!/bin/bash
# Description: Search for the `statistics` method in `cvat-core/src/annotations-collection.ts` using a more flexible pattern.

# Search for the `statistics` method definition and its implementation in the relevant file.
rg 'statistics' cvat-core/src/annotations-collection.ts

# Extract the implementation of the `statistics` method from the relevant file.
ast-grep --lang typescript --pattern $'statistics() {
  $$$
}' cvat-core/src/annotations-collection.ts

Length of output: 681



Script:

#!/bin/bash
# Description: Search for the `statistics` method in `cvat-core/src/annotations-collection.ts` using a more flexible pattern.

# Search for the `statistics` method definition and its implementation in the relevant file.
rg 'statistics' cvat-core/src/annotations-collection.ts

# Extract the implementation of the `statistics` method from the relevant file.
ast-grep --lang typescript --pattern $'function statistics() {
  $$$
}' cvat-core/src/annotations-collection.ts

Length of output: 245



Script:

#!/bin/bash
# Description: Search for the `statistics` method in `cvat-core/src/annotations-collection.ts` using a pattern that matches methods within classes.

# Extract the implementation of the `statistics` method from the relevant file.
ast-grep --lang typescript --pattern $'class $_ {
  $$$
  public statistics(): $_ {
    $$$
  }
  $$$  
}' cvat-core/src/annotations-collection.ts

Length of output: 109771

@@ -1936,8 +1936,7 @@ export class SkeletonShape extends Shape {
return null;
}

// The shortest distance from point to an edge
return Math.min.apply(null, [x - xtl, y - ytl, xbr - x, ybr - y]);
return Math.min.apply(null, distances);
Copy link
Contributor

@coderabbitai coderabbitai bot May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor distance method to use array for calculations.

-        return Math.min.apply(null, distances);
+        return Math.min(...distances);

This change uses the spread operator for clarity and modern JavaScript practices, aligning with the summary's mention of using an array for distance calculations.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
return Math.min.apply(null, distances);
return Math.min(...distances);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you heard that in case with large array it will throw Stack overflow exception?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsekachev, you're absolutely right about the potential for a stack overflow exception when using the spread operator with very large arrays in JavaScript. This is due to limitations on the maximum call stack size, which can indeed be exceeded with large arrays.

To avoid this issue, we can revert to using Math.min.apply(null, array), which is generally safer for large arrays as it doesn't add to the call stack in the same way. Here's how you can implement it:

return Math.min.apply(null, distances);

This method should work efficiently without the risk of a stack overflow, even with large data sets. Thank you for pointing out this important consideration!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is exactly what I did, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsekachev, yes, you're absolutely right. Your implementation using Math.min.apply(null, distances) is exactly what was suggested and is the best approach for handling potentially large arrays safely in JavaScript. Great job on ensuring robustness in your code! If there's anything else you'd like to discuss or need further assistance with, feel free to let me know.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.38%. Comparing base (146e188) to head (fc10f5a).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7921      +/-   ##
===========================================
+ Coverage    83.34%   83.38%   +0.03%     
===========================================
  Files          380      380              
  Lines        40027    40032       +5     
  Branches      3766     3769       +3     
===========================================
+ Hits         33359    33379      +20     
+ Misses        6668     6653      -15     
Components Coverage Δ
cvat-ui 79.30% <100.00%> (+0.07%) ⬆️
cvat-server 87.13% <ø> (+<0.01%) ⬆️

@bsekachev bsekachev merged commit 7c1073e into develop May 21, 2024
32 checks passed
@bsekachev bsekachev deleted the bs/fixed_skeletons_selection branch May 21, 2024 11:50
@cvat-bot cvat-bot bot mentioned this pull request May 21, 2024
fahadb-kt added a commit to fahadb-kt/cvat that referenced this pull request Aug 21, 2024
* Move rego files into their respective apps (#7806)

This is the promised sequel to #7734. After this change, the `iam` app
will no longer contain any code specific to other apps.

To make this work, the `/api/auth/rules` endpoint will now construct the
OPA bundle from a set of paths, which will be populated by
`load_app_permissions`.

Move OPA test files accordingly. Fortunately, `opa test` accepts
multiple directories, so it is trivial to adapt the testing
instructions.

Make the necessary adaptations to `generate_tests.py` to search for test
generators in every app. The original parameters of `generate_tests.py`
don't really make sense when there are multiple `rules` directory, so
remove them.

Instead, add a new `--apps-dir` parameter. This parameter isn't really
needed to test the open source version of CVAT, but I expect it to be
useful for testing the Enterprise version.

In addition, add some safety checks to `generate_tests.py`:

* Make sure that we find at least one test generator.

* Propagate exceptions from `call_generator` into the main thread.


### How has this been tested?
I tested the updated commands from the documentation manually, and
examined the rules bundle returned by `/api/auth/rules` to ensure that
it still contains all the `.rego` files.

* Fixed incorrect Cloud Storage request by ID (#7823)

* Opening update CS page sends infinite requests when CS id does not exist (#7828)

=

* Fixed duration of 'change:frame' event (#7817)

* Save video if test failed (#7807)

* Modernize Rego syntax (#7824)

Open Policy Agent v0.59 introduced a new directive (`import rego.v1`)
that ensures that the file is compatible with OPA v1 (to be released in
the future).

Add this directive to all Rego files and update the syntax accordingly.
Which involves the following:

* Rewrite all rules to use the `if` keyword, which is now mandatory.

* Where appropriate, use the `in` keyword, which is now available
without a future import. It's not mandatory, but it looks much nicer.

In addition, update Regal to the latest version, which now enforces the
use of `import rego.v1` by default.

* Optimized analytics requests to ClickHouse (#7804)

* Update the Nuclio version (#7787)

Old verison of Nuclio has some vulnerabilities and it needs to be
updated. Function dependencies have also been updated.

The `mask_rcnn` function has been removed because `mask_rcnn` using
python 3.6. In new version of Nuclio python3.6 is no longer supported.
Nuclio officially recommends using python3.9. Running `mask_rcnn` on
python3.9 causes errors within the function and package conflicts.

* Fixed: Cannot read properties of undefined (reading 'addClass') (#7834)

* fix[security]: Disable nginx server signature by default (#7814)

* Enhanced uploading files with tus protocol, enabled retries (#7830)

* Fixed exception when copy/paste a skeleton point (#7843)

* Added ability to call analytics report manually (#7805)

* Use CPU PyTorch for testing the SDK (#7825)

<!-- 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. -->
Not only is the GPU version of PyTorch much bigger than the CPU version,
but it also pulls in CUDA, which is enormous. We don't (and can't) use
any GPU features in our tests, so we don't need the GPU version.

Using the CPU version saves ~4GB of disk space, which is a lot, because
the standard GitHub runners only offer 14 GB.

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

- **Chores**
- Enhanced the installation process by adding an extra index URL for
PyTorch CPU wheels to improve SDK setup reliability.

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

* Update server dependencies (#7845)

* Bump tqdm from 4.60.0 to 4.66.3 in /utils/dicom_converter (#7848)

* Do not allow to remove latest keyframe from UI (#7844)

* Optimized requests to analytics DB, using timestamps, to avoid going trough the whole table (#7833)

* Fix task creation with video file when there are no valid keyframes (#7838)

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

### 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
- [x] 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**
- Fixed an issue where task creation from videos without valid keyframes
could cause errors.
- **New Features**
	- Enhanced video stream handling to support videos without keyframes.
- Improved manifest management with new checks for empty states and
better index handling.

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

* [GSoC2024] Added feature to show tags corresponding to GT job and manual job in a separate row (#7774)

Fixes #7773 and #7749

Added feature to show tags corresponding to GT job and manual job in a
separate row. Along with the tags of the GT job have a mark of '(GT)' in
them.

### How has this been tested?
When we want to see both manual annotations and GT annotations:
<img width="1217" alt="image loading..."
src="https://github.com/cvat-ai/cvat/assets/72168180/362a1728-24f3-43cb-ac4d-1571ebc5faaf">

When we only want to see the annotations for the manual annotations job:
<img width="1217" alt="image loading..."
src="https://github.com/cvat-ai/cvat/assets/72168180/443fbf56-cd86-404b-bd6d-28351738dddf">



### 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
- [x] 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~
- [x] 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 display tags for Ground Truth (GT) and manual jobs in a
separate row, with GT tags marked for easy identification.
- Enhanced tag highlighting in the annotation interface to better
indicate conflicts.

- **Style**
- Implemented new styles for frame tags to improve visual distinction
when highlighted.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Kirill Lakhov <kirill.9992@gmail.com>
Co-authored-by: Maxim Zhiltsov <zhiltsov.max35@gmail.com>

* Fixed vertical polylines difficult to select (#7860)

* Make `generate_tests.py` work with relative `--apps-dir` values (#7851)

In #7806 I goofed and made the `--apps-dir` option work only with
absolute paths. This patch fixes that.

* Fixed cannot read property 'annotations' of null (#7857)

* [GSoC2024] Added quality reporting for Tag annotations (#7582)

Fixes #7424 

This PR adds quality computations for Tag annotations.

* Avoid fetching a list of shapes/tags from db, optimized fetching tracks (#7852)

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

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


- **Refactor**
- Updated the method for counting objects in analytics reports to
improve accuracy.
- Made internal methods for initializing tags, shapes, and tracks
publicly accessible, enhancing external usability.

- **Bug Fixes**
	- Fixed import paths for better module integration and reliability.

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

* Prevent losing tracked attributes when moving to a project (#7863)

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

### 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
- [x] 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**
- Improved object tracking by adding a new model
`TrackedShapeAttributeVal` for enhanced performance and accuracy.
- Resolved issue of lost tracked attribute values when moving tasks to
projects.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* Prepare release v2.13.0

* Update develop after v2.13.0

* Remove tasks by projectId from state after deleting project (#7854)

* helm-chart: prevent Traefik from ignoring the backend ingress rule (#7859)

<!-- 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. -->
There is a condition that may occur during Kubernetes deployment, where
the frontend service already has an endpoint (i.e. the frontend pod),
but the backend service does not. For example, the backend pod may not
have started yet or the service controller may not have had time to
react to the backend pod.

In this case, when Traefik serves a request with an `/api/...` path, it
will see that it matches the `/api` rule, but since the corresponding
service has no endpoints, it will _skip_ that rule and try other rules.
And since the `/` rule matches everything, it will then route the
request to the frontend.

This is confusing and unhelpful, and more importantly, it makes health
checks return the wrong result. Since the frontend will serve
`index.html` to every request, a request to `/api/server/health/` or
`/api/server/about` will return a 200 code, even though the server isn't
actually up.

Because of this bug, I have observed weird failures in the Helm
workflow, where the "Wait for CVAT to be ready" step completes, but CVAT
is not actually ready. (FYI: The failures I've seen are actually in a
private repo, but the failure condition could occur in this repo too.
It's just more likely in a private repo, because GitHub uses smaller
runners in private repos.)

The fix is simple: use the `allowEmptyServices` Traefik setting, which
disables the rule skipping behavior. With this setting on, Traefik will
return a 503 response for backend URLs until the backend service gains
an endpoint.

### 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. -->
I deployed the Helm chart, then ran a `kubectl delete deployments.apps
cvat-backend-server` to simulate the server being unavailable. Then I
curled the `/api/server/health/` endpoint.

### 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**
- Fixed an issue to prevent incorrect 200 OK responses from API
endpoints before backend readiness.

- **New Features**
- Updated Helm chart to support configurations that allow empty services
in the Kubernetes Ingress provider.

- **Documentation**
- Updated version in Helm chart documentation from `0.12.0` to `0.12.1`.

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

* Fixed calculation of metrics for analytics reports (#7144)

* Check UI does not crash if to activate an object while frame fetching (#7873)

* Fix creating chunks with original quality from png images (#7899)

* Update helm (#7894)

Added ability to specify ServiceAccount for backend pods
Removed passing of DJANGO_MODWSGI_EXTRA_ARGS env variable to server pod
Do not set database host and port env variables if they are empty

* fixed server for duplicate attribute names (#7890)

* Fixed object count in analytics for skeletons and tracks (#7883)

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

### 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
- [x] 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**
- Corrected an issue where analytics reported an incorrect count of
objects for skeleton tracks/shapes.
- Fixed a bug where the analytic report consistently showed one less
object for tracks than the actual count.

- **Improvements**
- Enhanced filtering logic for shapes and tracks in analytics, improving
the accuracy of annotation speed metrics.

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

* Fix CI-nightly tests and refactoring cypress config (#7908)

* Fixed analytics report: working time rounding to minimal 1 hour is not applied to annotation speed anymore (#7898)

<!-- 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
Depends on #https://github.com/cvat-ai/cvat/pull/7883

### 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
- [x] 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**
- Corrected an issue where analytic reports showed an incorrect count of
objects for skeleton tracks and shapes.

- **Improvements**
- Renamed metrics related to annotation speed from total to average for
jobs, tasks, and projects.
- Updated descriptions for annotation speed metrics to specify the
number of objects per hour.
  - Removed unnecessary clamping function for working time statistics.

These changes enhance the accuracy and clarity of analytic reports,
providing more meaningful insights into annotation speeds and object
counts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fixed exception: Cannot read properties of undefined (reading 'onBloc… (#7913)

* Fixed one way to create an empty mask (#7915)

* check creating task with video without valid keyframes

* fix before commands

* remove extra check

* Fixed updating job/task status after changing job state (#7901)

* Array.toReversed replaced by Array.reduceRight because of better comp… (#7916)

* [GSoC2024] Added additional security headers (#7752)

Added security headers for Referrer-Policy, X-Content-Type-Options.

Referring to Issue https://github.com/cvat-ai/cvat/issues/7398, Added
additional security headers. Added to address the deduction in security
score rating third party scanners.

- Referrer-Policy "strict-origin-when-cross-origin";: Limit the referrer
information sent when a user navigates away from the website

- X-Content-Type-Options "nosniff";: Prevent browsers from attempting to
MIME-sniff the content type of a response to reduce risk of XSS and
Content Injection

Co-authored-by: Roman Donchenko <rdonchen@outlook.com>

* Fixed skeleton selection algorithm (#7921)

* add rest api test

* remove extra video file

* remove unused task

* fix video file path

* Ignore ground truth jobs when compute analytics report for a task/project (#7919)

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

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

* Prepare release v2.14.0

* Update develop after v2.14.0

* replace test video

* formatted code

* add copy videos folder

* Update cypress version (#7929)

* Upgrade React and Antd till the latest version (#7466)

* Fixed conflicts highlight crash in case of hidden by `zOrder` objects (#7917)

* Fixed couple of not stable Cypress tests (#7937)

* Fix missing serviceName field in kvrocks (issue #7741) (#7924)

Add the serviceName field to the kvrocks StatefulSet as per the
Kubernetes specification. This change ensures that the service name is
correctly associated with the StatefulSet pods, allowing for proper DNS
resolution and service discovery within the cluster.

Fixes #7741 

### Motivation and context
The Helm installation is currently failing as reported in issue #7741 

### How has this been tested?


### 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
- [x] 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**
- Resolved the issue of a missing `serviceName` field in `kvrocks`,
ensuring proper configuration and improved stability.

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

* Fix login when email domain contains capital symbols and user was created after invitation to some org (#7906)

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

### 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 email creation process to ensure the use of the normalized
email from the user object, enhancing data consistency and reducing
errors.

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

* Fixed .ant-modal-wrapper kept after closing saving modal (#7948)

* use other method to get path

* Fix dataset downloading (#7864)

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

This PR addresses several problems:
- when requesting a dataset download, it's possible to get the 500 error
with the message "The result file does not exist in export cache", which
isn't expected for this request
- when downloading the dataset the same error can be obtained if the
file is requested right before the cache expiration
- there are several
[TOCTOU](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use)
bugs related to dataset cache file existence checks
- under some conditions, it's possible that the export job is never
started
- the finished RQ jobs were removed automatically on result reporting
(after the client requested the result). This made it hard to debug
problems for admins, as the jobs were often removed already

This PR fixes the problems by the following:
- introduced dataset cache file locking (via redis) during reading,
writing, and removal
- the 500 error is changed to automatic reexporting attempt on export
status request
- the 500 error is changed to 404 when the file is not available for
downloading
- the exported files are now have different names for each instance
update time
- the lifetime of the exported files is now automatically prolonged on
each export request for the file (given the export is still valid)
- the deferred export jobs are now checked to have ghost dependencies.
If so, the requested job is restarted
- added several environment variables for configuration
- <s>finished RQ export jobs are not removed automatically on result
retrieval. Now, they just use the export cache lifetime instead (should
be continued in another PR)</s>

### 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**
- Improved reliability of file handling during export and cleanup
processes.
- Introduced new functionality for managing export cache locks and
directories.

- **Bug Fixes**
- Addressed race conditions in concurrent export and cleanup operations.

- **Dependencies**
- Updated multiple packages to their latest versions for enhanced
security and performance:
    - `cryptography` to `42.0.7`
    - `django` to `4.2.13`
    - `django-health-check` to `3.18.2`
    - `freezegun` to `1.5.1`
    - `jinja2` to `3.1.4`
    - `limits` to `3.12.0`
    - `lxml` to `5.2.2`
    - `orjson` to `3.10.3`
    - Added `pottery` version `3.0.0`
    - Updated `tqdm` to `4.66.4`
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* Fixed working time lost in click:element events (#7942)

* Aborted enabling black linter onsave in vscode (#7956)

* Delete extra comma (#7957)

* Fix a non-deterministic webhook test (#7952)

`test_two_project_webhooks_intersection` is supposed to trigger each
webhook once. However, the first one of these webhooks actually gets
triggered twice, because creating a task causes the project's
`updated_date` to be bumped, which triggers an `update:project` event.

The test still passes a lot of the time (I guess because the second
delivery doesn't appear immediately?), but sometimes it fails. It's very
easy to make it fail consistently, though - just add a `sleep(5)` before
the `get_deliveries` calls.

Fix this by changing the first webhook's second event to something that
will not be triggered.

* Improved `DatasetNotFound` error message (#7923)

The recent changes enhance the dataset import functionality across various dataset formats in the CVAT application by integrating specific importers from the Datumaro library. The updates streamline the detection of datasets, improve error handling, and introduce new tests to ensure robustness against incorrect file structures during import operations.

* Fix automatic `tag` annotation support (#7839)

* Update packages with vulnerability (#7951)

* Cannot set properties of undefined (setting 'serverID') (#7949)

* Fixed some deprecation warnings (#7970)

* Added license information regarding '/serverless' directory (#7967)

* Stabilized the cypress test for fix CI-nightly runs (#7966)

* Squashed `zoom:image` and `send:exception` client events (#7953)

* Fix memory consumption when exporting to azure blob storage (#7960)

Fix memory consumption when exporting to azure blob storage

* Fixed several issues related to creating tasks with cloud data (#7969)

<!-- 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. -->
@coderabbitai summary
### 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
- [x] I have created a changelog fragment <!-- see top comment in
CHANGELOG.md -->
- [ ] I have updated the documentation accordingly
- [x] I have added tests to cover my changes (*partially*)
- [ ] 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**
  - Improved media download performance with parallel downloading.
  - Enhanced file handling with the new `NamedBytesIO` class.
- Added support for specifying stop frames in task manifest generation.
  - Enhanced `DatasetImagesReader` to handle generator sources.

- **Performance Improvements**
- Optimized image download methods to use threading for faster
processing.

- **Configuration**
- Introduced new settings for maximum threads and files per thread in
cloud data downloading.

These updates enhance the flexibility, performance, and configurability
of media handling and downloading in the application.

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

* Using dedicated event to store working time (#7958)

- Parsing JSON payloads to get `working_time` in general leads to low
performance in Clickhouse requests. This patch will not fix it right
now, but with this patch, after a period of time we may switch to new
quick approach to calculate working time.
- There will not be a lot of `send:working_time` events, we may store
this scope of events for a longer time (e.g. 5 years instead of one by
default).
- Finally storing working time in such events like `click:element` or
`send:exception`, or `debug:info` seems not logical.
- Also, the history showed, that as result in different bugs, these
events may sometime lose information about `job_id`, `task_id`, etc.

Resolved #7884

* Update README.md (#7980)

* Check non-existent cloud storage update page (#7972)

* Annotation interface documentation updated (#7947)

* Bump requests from 2.31.0 to 2.32.2 in /tests/python (#7954)

* Updated icon (#7981)

* Fixed layout on create cloud storage page (#7985)

* Prepare release v2.14.1

* Update develop after v2.14.1

* Fixed: Queued jobs are not considered in deferring logic (#7907)

* Stabilized the cypress test for fix CI-nightly runs 2 (#7971)

* Update datumaro format description (#7992)

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

Skeletons are not supported in this format

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

- **Documentation**
- Updated the `Datumaro 1.0` format to support `Tags` instead of
`Tracks`.
- Expanded documentation to include support for additional annotation
types like Polylines, Masks, Points, Cuboids, and Tags in both export
and import operations.

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

* Fixed ImageBitmap memory leak (#7995)

<!-- 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
Resolved #7909
Resolved #7850

### 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
- [x] 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))
- [x] 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**
- Addressed a significant memory leak issue by ensuring `ImageBitmap`
objects are properly closed after use.
- Updated various components to handle cleanup and termination of
workers and instances correctly, preventing potential resource leaks.

- **Version Updates**
  - Updated `cvat-canvas` to version 2.20.3.
  - Updated `cvat-core` to version 15.0.6.
  - Updated `cvat-data` to version 2.1.0.

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

* Updated documentation (one item was missing in the list of events saving triggers) (#8001)

* Prepare release v2.14.2

* Update develop after v2.14.2

* Rename kvrocks port (#8010)

Fix connection error issue in case of istio usage:
https://istio.io/v1.0/docs/setup/kubernetes/spec-requirements/#:~:text=Named%20ports%3A%20Service%20ports%20must,but%20name%3A%20http2foo%20is%20not.

* Fixed login with token without next parameter (#7999)

* Increased server health check timeout (#7993)

* Fixed: Cannot read properties of null (reading 'draw') (#7997)

* Remove unnecessary fields from the `/api/lambda/functions` response (#8004)

Remove several fields that haven't been used for one reason or another:

* `labels` and `attributes` have been replaced by `labels_v2`. Keeping
them around nearly triples the response length.

* `framework` hasn't been used by the UI since #5635, and IMO was never
useful to begin with. There are no decisions that the UI can take based
on this field, so it's essentially just a freeform text field, and we
already have a freeform text field - `description`. (Which... the UI
doesn't display either. But it could!)

Remove the `framework` field from the function descriptions as well,
since it has no other purpose.

* `state` has, as far I could determine, never been used by the UI. I
could see a field like this potentially being useful (e.g. the UI could
still display a function, but prevent it from being used if it's
unavailable), but since none of that is implemented right now, I see no
reason to have this field in the API.

* Fixed exception: State cannot be updated during editing, need to finish current editing first (#8019)

* Check creating cloud storage without manifest file (#7984)

* Number of Org Members (#8015)

Updated number of members

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

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

- **Documentation**
  - Updated details for the Solo and Team plans on CVAT.ai:
- Solo Plan: Adjusted the number of members allowed from "up to 3
members" to "up to 2 members".
- Team Plan: Adjusted the number of members required to pay for from "4
seats (3 annotators + 1 organization owner)" to "3 seats (2 annotators +
1 organization owner)".

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

* Merge pull request from GHSA-q684-4jjh-83g6

S3 storages support user-specified endpoint URLs, and Azure storages support
user-specified connection strings (which can contain endpoint URLs), so they
are susceptible to SSRF. Make S3 and Azure requests go through smokescreen
to fix this.

AFAIK, there is no way to configure a custom URL for Google Cloud storages,
so those aren't vulnerable.

Co-authored-by: Nikita Manovich <nikita@cvat.ai>

* Merge pull request from GHSA-jpf9-646h-4px7

* Mitigate a CSRF vulnerability in export and backup-related endpoints

While Django has built-in CSRF protection (which we use), it does not cover
GET requests, and AFAICS, there is no way to force it to do that.
Unfortunately, the many endpoints that initiate dataset exports and backups
do accept GET requests _and_ initiate side effects, making them susceptible.

The proper fix for this issue would be to redesign those endpoints to use
POST requests, but a) that's more complicated, and b) we should still keep
the old endpoints for backwards compatibility.

So apply a less proper fix, which is to disable session authentication for
the affected endpoints. It's a bit complex, because in some cases
(particularly when `action=download`) we _need_ session authentication to
work, because the UI redirects the user to such endpoints.

In addition, modify the handling logic for these endpoints in order to
ensure that when `action=download`, no side effects are triggered.
Previously, `action=download` would still queue an RQ job if none existed.

Even after this, `action=download` will still have two small side effects:

* An existing RQ job will be deleted if its results are out of date.
  I don't think this is a problem, because such a job cannot be used anyway.

* A completed RQ job will be deleted too. This is a problematic design,
  but I don't think an attacker can achieve anything by exploiting this. If
  an attacker maliciously redirects the user to an `action=download` URL,
  then they'll just download the export/backup as usual.

Some tests were making export requests incorrectly, so fix them.

* Add test for the CSRF workaround

* Prepare release v2.14.3

* Update develop after v2.14.3

* Remove `ModelKind.CLASSIFIER` (#8011)

I'd like the "kind" field in the API to identify the function's
"signature", or the types of values it receives as input and produces as
output. Classifiers have the same signature as detectors, so
`classifier` is a redundant value.

Besides improving semantic purity, removing this redundant value
simplifies the UI code.

The only meaningful difference between how the UI handles classifiers,
as compared to detectors, is that it shows the word "classifier" in the
model modal, which can be helpful. But we can achieve the same thing by
examining the function's `return_type` field. This lets us give a
special label to segmentation functions, as well.

"classifier" can't actually be returned by `/api/lambda/functions`, but
it _can_ be returned by the RoboFlow/Hugging Face function API in CVAT
Enterprise. So we'll need a small compatibility shim to transform this
value to "detector" until I fix that API to stop returning it too.

* Change minio host server definition (#8032)

* Stop editing when n key pressed (#7922)

* Allowed editing in single shape annotation mode (#8017)

* Fix server cache cleanup for backups and events (#8040)

In #7864 the cache cleanup function was updated. The function was not
supposed to be called for anything except datasets, but it was called
for backups and events. This PR changes these clients to use their own
functions.

- Fixed `ValueError: Couldn't parse filename components in
'c71eba87-0914-4ccb-b883-a1bf1612fbf8.csv'` errors

* CVAT Architecture documentation update (#8031)

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

### 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.githu…
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.

3 participants