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

return in draw mask if mask canvas not defined #4227

Merged
merged 4 commits into from Apr 4, 2024

Conversation

sashankaryal
Copy link
Contributor

@sashankaryal sashankaryal commented Apr 3, 2024

What changes are proposed in this pull request?

DetectionOverlay::canvas is only defined if DetectionOverlay::label::mask is defined. This PR adds a return statement in DetectionOverlay::drawMask() if canvas is undefined.

To repro:

import fiftyone as fo
import fiftyone.zoo as foz
import numpy as np

dataset = foz.load_zoo_dataset("quickstart").limit(1).clone()
dataset.name="empty-detection-mask-2368"
dataset.clear_sample_fields(["ground_truth", "predictions"])
sample = dataset.first()
sample["ground_truth"] = fo.Detections(
    detections=[
        fo.Detection(
            label="bad_mask_detection",
            bounding_box=[0.0, 0.0, 0.0, 0.0],
            mask=np.empty((0, 0)),
        ),
    ]
)
sample.save()

Error before change:

Screenshot 2024-04-03 at 2 07 15 PM

After change:
Screenshot 2024-04-03 at 2 11 41 PM

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of mask drawing in the overlay feature by ensuring the drawing canvas is available before proceeding.
  • Documentation
    • Added a note about updating browser binaries when upgrading Playwright version in the e2e testing setup.
  • Refactor
    • Refactored logic in the SelectorAsserter class to enhance readability and potentially improve test reliability.
  • Tests
    • Introduced a test for loading and displaying a detection mask in a grid interface using FiftyOne, a computer vision tool.
    • Refactored the assertion for entry count text validation in the quickstart test of the quickstart suite.

Copy link
Contributor

coderabbitai bot commented Apr 3, 2024

Walkthrough

The update across various files enhances the Playwright test suite and overlay functionality. It includes adjustments to Playwright rules, improvements in element visibility checks, and new tests for detection masks and entry count text validation. These changes aim to enhance testing reliability and maintainability in the e2e testing setup.

Changes

File(s) Summary
.../looker/src/overlays/detection.ts Added a check for this.canvas existence before drawing the mask.
e2e-pw/.eslintrc.js Adjusted Playwright rules, disabled "playwright/no-networkidle", and added a note on "playwright/no-standalone-expect".
e2e-pw/README.md Added a note on updating browser binaries when upgrading Playwright.
e2e-pw/src/oss/poms/selector.ts Refactored element visibility checks using toBeVisible() for improved readability.
e2e-pw/src/oss/specs/overlays/detection-mask.spec.ts Added a test for loading and displaying detection masks in a grid interface using FiftyOne.
e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts Refactored entry count text validation in the quickstart test.

🐰✨
In the realm of code, where the overlays play,
A rabbit hopped in, to brighten the day.
"Before you draw," it said with a smile,
"Ensure the canvas is there, all the while."
With a hop and a skip, the bug was no more,
Leaving the code better than before. 🌟
🐰✨

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/coderabbit-overrides.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.

@sashankaryal sashankaryal self-assigned this Apr 3, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e7d2a9a and a211fa1.
Files selected for processing (1)
  • app/packages/looker/src/overlays/detection.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/packages/looker/src/overlays/detection.ts

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 28.23%. Comparing base (0502123) to head (fde69bc).
Report is 16 commits behind head on develop.

Files Patch % Lines
app/packages/looker/src/overlays/detection.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4227      +/-   ##
===========================================
+ Coverage    27.99%   28.23%   +0.24%     
===========================================
  Files          814      813       -1     
  Lines       101640   101849     +209     
  Branches      1178     1214      +36     
===========================================
+ Hits         28456    28761     +305     
+ Misses       73184    73088      -96     
Flag Coverage Δ
app 15.74% <0.00%> (+0.18%) ⬆️
python 99.24% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@benjaminpkane benjaminpkane left a comment

Choose a reason for hiding this comment

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

My mistake, LGTM 🚀

If you have a moment, I wouldn't object to adding the below to a new/existing e2e test

sample = dataset.first()
sample["ground_truth"] = fo.Detections(
    detections=[
        fo.Detection(
            label="bad_mask_detection",
            bounding_box=[0.0, 0.0, 0.0, 0.0],
            mask=np.empty((0, 0)),
        ),
    ]
)
sample.save()

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

Review Status

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between a211fa1 and fde69bc.
Files ignored due to path filters (2)
  • e2e-pw/package.json is excluded by !**/*.json
  • e2e-pw/yarn.lock is excluded by !**/*.lock, !**/*.lock
Files selected for processing (5)
  • e2e-pw/.eslintrc.js (1 hunks)
  • e2e-pw/README.md (1 hunks)
  • e2e-pw/src/oss/poms/selector.ts (1 hunks)
  • e2e-pw/src/oss/specs/overlays/detection-mask.spec.ts (1 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1 hunks)
Additional Context Used
Path-based Instructions (3)
e2e-pw/src/oss/poms/selector.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

e2e-pw/src/oss/specs/overlays/detection-mask.spec.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1)

Pattern **/*.{ts,tsx}: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.

Additional comments not posted (5)
e2e-pw/.eslintrc.js (1)

13-14: Monitor the issue with the "playwright/no-standalone-expect" rule and re-enable it once the false positives are resolved to maintain code quality.

e2e-pw/src/oss/poms/selector.ts (1)

57-61: The refactoring to use toBeVisible() for visibility checks aligns with Playwright best practices and enhances test readability and reliability.

e2e-pw/src/oss/specs/overlays/detection-mask.spec.ts (1)

1-57: The test suite is well-structured and aligns with the PR objectives, effectively testing the detection mask functionality with appropriate setup and assertions.

e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1)

31-32: Refactoring the assertion to use grid.assert.isEntryCountTextEqualTo improves the readability and maintainability of the test.

e2e-pw/README.md (1)

10-11: The note about updating browser binaries after upgrading Playwright is important for maintaining a functional e2e testing setup and should be followed to prevent compatibility issues.

@sashankaryal sashankaryal merged commit d4615a6 into develop Apr 4, 2024
16 checks passed
@sashankaryal sashankaryal deleted the bugfix/empty-detection-mask branch April 4, 2024 17:07
@coderabbitai coderabbitai bot mentioned this pull request Apr 18, 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.

None yet

2 participants