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

Do not adjust opacity level each frame if there are masks #8149

Merged
merged 8 commits into from
Jul 12, 2024

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Jul 11, 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

  • New Features

    • Improved opacity handling to prevent reset when switching frames with masks.
  • Bug Fixes

    • Fixed the method call in regression tests to ensure correct object creation.
  • Refactor

    • Simplified opacity management logic based on presence of masks.
    • Renamed internal functions for clarity.
  • Tests

    • Enhanced test scenarios for better validation of opacity settings and frame changes.

@bsekachev bsekachev requested a review from azhavoro as a code owner July 11, 2024 06:48
Copy link
Contributor

coderabbitai bot commented Jul 11, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent updates ensure that the opacity level for annotations, specifically those with masks, is maintained consistently across frame switches. This enhancement modifies opacity handling logic in both the front-end code and test scripts, ensuring a more robust and user-friendly experience.

Changes

File/Path Change Summary
changelog.d/20240711_094827_boris_... Added changelog entry for preventing opacity reset when frames switch with masks present.
cvat-ui/src/actions/annotation-actions.ts Modified getJobAsync to update annotationsIncludeMasks flag and handle opacity settings based on mask shapes.
cvat-ui/src/reducers/settings-reducer.ts Adjusted opacity handling using annotationsIncludeMasks instead of states and job.
cvat-ui/src/utils/clamp-opacity.ts Refactored clampOpacity to accept a boolean annotationsIncludeMasks parameter.
tests/cypress/e2e/actions_objects/... Corrected method call in tests, impacting object creation control flow.
tests/cypress/e2e/issues_prs/issue_7176_... Updated test scripts to reflect changes in opacity settings and frame transitions, adjusting object creation and test descriptions.
tests/cypress/support/commands.js Renamed headlessCreateObject function to headlessCreateObjects.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Backend
    participant Annotations
    
    User->>UI: Requests frame switch
    UI->>Annotations: Check annotationsIncludeMasks
    alt Mask Present
        Annotations->>UI: Maintain current opacity
    else No Mask
        Annotations->>UI: Reset opacity to default
    end
    UI->>Backend: Fetch new frame data
    Backend->>UI: Return frame data
    UI->>User: Display frame with appropriate opacity
Loading

Poem

A rabbit hops through lines of code,
Ensuring masks don't fade, but glow.
When frames do switch, the opacity stays,
In the user’s gaze, no more dismays.
With every test and refactor done,
Our journey to clarity has just begun.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

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

@bsekachev bsekachev requested a review from nmanovic as a code owner July 11, 2024 06:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
cvat-ui/src/utils/clamp-opacity.ts (1)

Line range hint 8-25:
Consider replacing magic numbers with named constants.

The use of magic numbers (30 and 60) in the function can reduce readability. Consider defining these values as named constants for better clarity.

const ENHANCED_DEFAULT_OPACITY = 30;
const ENHANCED_DEFAULT_SELECTED_OPACITY = 60;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ad1bcd5 and 386c65a.

Files selected for processing (7)
  • changelog.d/20240711_094827_boris_do_not_reset_opacity.md (1 hunks)
  • cvat-ui/src/actions/annotation-actions.ts (3 hunks)
  • cvat-ui/src/reducers/settings-reducer.ts (2 hunks)
  • cvat-ui/src/utils/clamp-opacity.ts (2 hunks)
  • tests/cypress/e2e/actions_objects/regression_tests.js (1 hunks)
  • tests/cypress/e2e/issues_prs/issue_7176_opacity_reset.js (5 hunks)
  • tests/cypress/support/commands.js (1 hunks)
Files skipped from review due to trivial changes (2)
  • changelog.d/20240711_094827_boris_do_not_reset_opacity.md
  • tests/cypress/support/commands.js
Additional comments not posted (7)
tests/cypress/e2e/actions_objects/regression_tests.js (1)

47-47: Verify the correctness of headlessCreateObjects usage.

Ensure that the headlessCreateObjects function is correctly implemented and used to create objects as intended.

Verification successful

The headlessCreateObjects function is correctly implemented and used in the test setup. The function properly creates objects and ensures they are saved as intended.

  • tests/cypress/support/commands.js: Implementation of headlessCreateObjects.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `headlessCreateObjects`.

# Test: Search for the function implementation. Expect: Correct logic for creating objects.
rg --type javascript 'headlessCreateObjects'

Length of output: 79


Script:

#!/bin/bash
# Description: Verify the implementation of `headlessCreateObjects`.

# Test: Search for the function implementation. Expect: Correct logic for creating objects.
rg 'headlessCreateObjects'

Length of output: 344


Script:

#!/bin/bash
# Description: Extract the implementation of `headlessCreateObjects` from `tests/cypress/support/commands.js`.

# Test: Extract function implementation. Expect: Correct logic for creating objects.
rg -A 20 'Cypress.Commands.add\(\'headlessCreateObjects\'' tests/cypress/support/commands.js

Length of output: 93


Script:

#!/bin/bash
# Description: Extract the implementation of `headlessCreateObjects` from `tests/cypress/support/commands.js`.

# Test: Extract function implementation. Expect: Correct logic for creating objects.
rg -A 20 "Cypress.Commands.add('headlessCreateObjects'" tests/cypress/support/commands.js

Length of output: 213


Script:

#!/bin/bash
# Description: Extract the implementation of `headlessCreateObjects` from `tests/cypress/support/commands.js`.

# Test: Extract function implementation. Expect: Correct logic for creating objects.
rg -A 20 "Cypress.Commands.add\('headlessCreateObjects'" tests/cypress/support/commands.js

Length of output: 978

tests/cypress/e2e/issues_prs/issue_7176_opacity_reset.js (3)

94-96: LGTM!

The test case correctly checks if the annotation view opens with increased opacity levels when masks are present.


Line range hint 98-113:
LGTM!

The test cases correctly set lower opacity values and verify that they do not reset when switching frames.


65-72: Verify the correctness of headlessCreateObjects usage.

Ensure that the headlessCreateObjects function is correctly implemented and used to create objects with a mask shape as intended.

cvat-ui/src/reducers/settings-reducer.ts (1)

444-451: LGTM!

The changes correctly use the clampOpacity function with the annotationsIncludeMasks parameter to clamp the opacity values.

cvat-ui/src/actions/annotation-actions.ts (2)

982-982: Verify the correct usage of the annotationsIncludeMasks flag.

The annotationsIncludeMasks flag has been added to the payload of the GET_JOB_SUCCESS action. Ensure that this flag is correctly set and utilized in the application.

Verification successful

The annotationsIncludeMasks flag is correctly set and utilized in the application.

  • The flag is set based on the presence of mask shapes in cvat-ui/src/actions/annotation-actions.ts.
  • It is passed to the clampOpacity function in cvat-ui/src/reducers/settings-reducer.ts.
  • Within clampOpacity in cvat-ui/src/utils/clamp-opacity.ts, it is used to determine opacity values.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of the `annotationsIncludeMasks` flag in the codebase.

# Test: Search for the usage of `annotationsIncludeMasks`. Expect: Correct usage in relevant files.
rg --type typescript 'annotationsIncludeMasks'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify the correct usage of the `annotationsIncludeMasks` flag in the codebase.

# Test: Search for the usage of `annotationsIncludeMasks`. Expect: Correct usage in relevant files.
rg --type ts 'annotationsIncludeMasks'

Length of output: 556


Script:

#!/bin/bash
# Description: Retrieve the context around the usage of `annotationsIncludeMasks` in the identified files.

# Test: Get 5 lines of context around each match to understand the usage.
rg --type ts 'annotationsIncludeMasks' -A 5 -B 5

Length of output: 3847


941-941: Verify the impact of removing showAllInterpolationTracks.

The showAllInterpolationTracks setting has been removed from the getJobAsync function. Ensure that this removal does not affect other parts of the application that rely on this setting.

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.39%. Comparing base (0317871) to head (2a9b63c).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8149      +/-   ##
===========================================
- Coverage    83.39%   83.39%   -0.01%     
===========================================
  Files          389      388       -1     
  Lines        41296    41272      -24     
  Branches      3858     3852       -6     
===========================================
- Hits         34440    34418      -22     
+ Misses        6856     6854       -2     
Components Coverage Δ
cvat-ui 79.64% <100.00%> (-0.02%) ⬇️
cvat-server 86.75% <ø> (+<0.01%) ⬆️

Copy link

sonarcloud bot commented Jul 11, 2024

@bsekachev bsekachev merged commit 5aae413 into develop Jul 12, 2024
33 checks passed
@bsekachev bsekachev deleted the bs/do_not_reset_opacity branch July 15, 2024 09:32
@cvat-bot cvat-bot bot mentioned this pull request Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants