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

Fix Looker Classifications handing #5322

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Dec 27, 2024

What changes are proposed in this pull request?

The ClassificationsOverlay does not have a label attribute. Resolves #5317

How is this patch tested? If it is not, please explain why.

Todo

Release Notes

  • Fixed visualizer rendering for classification labels

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Summary by CodeRabbit

  • New Features

    • Introduced new overlay types: Detection, Heatmap, and Segmentation.
  • Bug Fixes

    • Improved logic for handling overlay data to enhance performance and reliability.
    • Updated cleanup method to prevent potential errors.
  • Chores

    • Adjusted imports for better modularity and organization.
    • Enhanced type safety in utility functions for improved reliability.
    • Added new test suite for the viewsAreEqual function to ensure correct behavior.

@benjaminpkane benjaminpkane added bug Bug fixes app Issues related to App features labels Dec 27, 2024
@benjaminpkane benjaminpkane self-assigned this Dec 27, 2024
Copy link
Contributor

coderabbitai bot commented Dec 27, 2024

Walkthrough

The pull request modifies the abstract.ts file in the Looker package, focusing on improving overlay handling and data processing. The changes introduce new imports for different overlay types and update the updateSample method to more robustly handle overlay data. The modifications include type-checking for overlay instances, adjusting buffer management, and implementing safer method invocation through optional chaining. Additionally, type annotations are added to utility functions in utils.ts, enhancing type safety and error handling.

Changes

File Change Summary
app/packages/looker/src/lookers/abstract.ts - Added imports for DetectionOverlay, HeatmapOverlay, and SegmentationOverlay
- Updated updateSample method to use type-based overlay data assignment
- Improved buffer handling with detachment check
- Enhanced overlay cleanup using optional chaining
app/packages/state/src/utils.ts - Added type annotations to filterView and viewsAreEqual functions
- Corrected sorting logic in stringifyObj function
app/packages/state/src/utils.test.ts - Added new test suite for viewsAreEqual function with five test cases

Assessment against linked issues

Objective Addressed Explanation
Prevent web app crash when clicking label tags [#5317]
Resolve TypeError related to 'mask' undefined

Possibly related PRs

  • Better heatmap range handling #4865: This PR modifies the HeatmapOverlay class, which is directly related to the changes made in the main PR that also involves the HeatmapOverlay. Both PRs focus on enhancing the functionality and handling of overlays in the application.
  • sample update / overlay recoloring performance optimization #5247: This PR updates the updateSample method in the AbstractLooker class, which is also modified in the main PR. Both PRs involve changes to how overlays are managed and memory is handled during sample updates, indicating a strong connection between them.

Suggested reviewers

  • ritch
  • sashankaryal

Poem

🐰 In the realm of code, where overlays dance,
A rabbit hops through types with a glance,
Buffers checked, methods chained with care,
No more crashes to give us a scare!
Debugging magic, smooth and light,
Our digital world now shines so bright! 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
app/packages/looker/src/lookers/abstract.ts (3)

27-29: Add a short docstring for new overlay imports
While these imports look good, consider adding a short docstring or code comment clarifying the purpose of each overlay to improve clarity in the codebase.


556-557: Leverage the existing buffer checks
There is a blank line before pushing buffer to arrayBuffers. This is more of a style preference than a functional concern, but be mindful of extra lines that could reduce visual clarity.


752-752: Ensure robust cleanup error handling
The optional chaining on overlay.cleanup?.() is a good safeguard. However, if a cleanup error arises, ensure it is handled or logged to prevent silent failures and aid debugging.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18dde78 and dad866d.

📒 Files selected for processing (1)
  • app/packages/looker/src/lookers/abstract.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/looker/src/lookers/abstract.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 (1)
app/packages/looker/src/lookers/abstract.ts (1)

534-540: Check for missing or undefined overlay.label
Before accessing overlay.label.mask or overlay.label.map, ensure overlay.label is defined. Otherwise, if overlay.label is unexpectedly null, a runtime error may occur.

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

🧹 Nitpick comments (1)
app/packages/state/src/utils.ts (1)

68-79: Check behavior for string inputs in viewsAreEqual.

When viewOne and viewTwo are both strings with identical content, the initial strict equality check (===) correctly treats them as equal. However, other string nuances (e.g., leading/trailing spaces) might lead to unexpected comparisons. If partial matches or case-insensitive comparisons are desired, consider customizing the comparison logic.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dad866d and cc499d5.

⛔ Files ignored due to path filters (1)
  • app/packages/looker/tsconfig.json is excluded by !**/*.json
📒 Files selected for processing (1)
  • app/packages/state/src/utils.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/state/src/utils.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 (1)
app/packages/state/src/utils.ts (1)

60-60: Type annotation improvement is good to see.

By explicitly typing the parameter as State.Stage[], this prevents inadvertent misuse of the filterView function. It also ensures better clarity for future readers and contributors.

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

🧹 Nitpick comments (1)
app/packages/state/src/utils.test.ts (1)

12-20: Expand test coverage for array-based views

Currently, there is only a test for empty arrays. Consider adding more scenarios, such as different array lengths, partially similar arrays, or objects within arrays, to ensure viewsAreEqual is thoroughly validated.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc499d5 and 2744d55.

📒 Files selected for processing (1)
  • app/packages/state/src/utils.test.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/state/src/utils.test.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 (1)
app/packages/state/src/utils.test.ts (1)

2-2: Ensure comprehensive testing of all newly imported functions

While adding viewsAreEqual to the import statement is correct, confirm that all required functionality is covered by unit tests. This prevents future regressions if the function is referenced in other test suites.

}

arrayBuffers.push(buffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a guard for undefined buffer?

Suggested change
arrayBuffers.push(buffer);
if (buffer) {
arrayBuffers.push(buffer);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Issues related to App features bug Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On the Demo Site, clicking label tags in the BDD example crashes the web app
2 participants