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

Lightning filter fixes #4757

Merged
merged 3 commits into from
Sep 11, 2024
Merged

Lightning filter fixes #4757

merged 3 commits into from
Sep 11, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Aug 30, 2024

What changes are proposed in this pull request?

Indexed id fields are incorrectly included as (unindexed) subfilters in lightning mode

Also fixes loading state with boolean lightning filters.

Note that indexed ObjectId fields offer indexed matches/querying but do not offer ixscan substring prefix search, so search results are not enabled. Only exact 24 hex character searches are allowed

Before

Screen.Recording.2024-08-30.at.9.14.46.AM.mov

After

Screen.Recording.2024-08-30.at.9.15.12.AM.mov

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

Selector test

Release Notes

  • Added indexed id fields to lightning filters

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

    • Enhanced loading indicator logic in the Filters component for improved user feedback during data loading.
    • Updated filtering logic in the lightning module for more dynamic path validation.
  • Bug Fixes

    • Adjusted the FILTERS object key definition to ensure proper referencing.
  • Tests

    • Introduced unit tests for the lightning module to validate selector functionality and improve test coverage.

@benjaminpkane benjaminpkane added bug Bug fixes app Issues related to App features labels Aug 30, 2024
@benjaminpkane benjaminpkane requested a review from a team August 30, 2024 13:17
@benjaminpkane benjaminpkane self-assigned this Aug 30, 2024
Copy link
Contributor

coderabbitai bot commented Aug 30, 2024

Walkthrough

The changes involve modifications to several components within the codebase, including adjustments to conditional logic for loading indicators, minor formatting updates, alterations to object key definitions, the introduction of unit tests for a state management module, and updates to filtering logic in a selector function. These changes collectively enhance the functionality and maintainability of the code.

Changes

Files Change Summary
app/.../Filters/StringFilter/Checkboxes.tsx Expanded conditional logic for displaying the loading indicator to include checks for show and results.
app/.../Filters/StringFilter/useSelected.ts Added a blank line after the declaration of the shown constant, with no change to function logic.
app/.../Sidebar/Entries/FilterablePathEntry/FilterItem.tsx Removed quotes around the key "_LABEL_TAGS" in the FILTERS object, changing it to _LABEL_TAGS.
app/.../state/recoil/lightning.test.ts Introduced unit tests for the lightning module, validating the behavior of the lightningPaths function with controlled responses.
app/.../state/recoil/lightning.ts Modified filtering logic in the lightningPaths selector to check if indexes contains the result of get(schemaAtoms.dbPath(p)) instead of checking p directly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Checkboxes
    participant LoadingIndicator

    User->>Checkboxes: Trigger loading
    Checkboxes->>LoadingIndicator: Check loading state
    alt Loading with results
        LoadingIndicator-->>User: Show loading indicator
    else No results
        LoadingIndicator-->>User: Show loading indicator
    end
Loading

🐰 In fields of green, I hop with glee,
New changes sprout like leaves on a tree.
Load indicators shine bright and clear,
With tests in place, there's nothing to fear!
Hooray for the code, so tidy and neat,
A rabbit's delight, oh what a treat! 🥕✨


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eba6938 and 91e8ef4.

Files selected for processing (1)
  • app/packages/core/src/components/Filters/StringFilter/Checkboxes.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/packages/core/src/components/Filters/StringFilter/Checkboxes.tsx

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 using PR comments)

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

Other keywords and placeholders

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

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: 1

Outside diff range, codebase verification and nitpick comments (1)
app/packages/state/src/recoil/lightning.ts (1)

172-172: Approve the modification in filtering logic.

The change to use schemaAtoms.dbPath for path transformation before checking membership in the indexes set is a significant improvement. This ensures that paths are correctly resolved based on the schema's structure before being used in filtering operations.

The code changes are approved.

Consider adding comments explaining the use of schemaAtoms.dbPath in this context to aid future maintainability.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 380ab4c and 79d519a.

Files selected for processing (5)
  • app/packages/core/src/components/Filters/StringFilter/Checkboxes.tsx (1 hunks)
  • app/packages/core/src/components/Filters/StringFilter/useSelected.ts (1 hunks)
  • app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/FilterItem.tsx (1 hunks)
  • app/packages/state/src/recoil/lightning.test.ts (1 hunks)
  • app/packages/state/src/recoil/lightning.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/packages/core/src/components/Filters/StringFilter/useSelected.ts
Additional context used
Path-based instructions (4)
app/packages/state/src/recoil/lightning.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.

app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/FilterItem.tsx (1)

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

app/packages/core/src/components/Filters/StringFilter/Checkboxes.tsx (1)

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

app/packages/state/src/recoil/lightning.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 (3)
app/packages/state/src/recoil/lightning.test.ts (1)

1-5: Proper setup of test environment.

The use of vitest and mocking of recoil and recoil-relay ensures that the tests are isolated and reproducible.

app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/FilterItem.tsx (1)

26-26: Key change in FILTERS object approved, verify consistency.

The change from "_LABEL_TAGS" to _LABEL_TAGS simplifies the object key. Ensure that all references to this key across the codebase are updated to reflect this change.

app/packages/core/src/components/Filters/StringFilter/Checkboxes.tsx (1)

183-183: Enhanced conditional logic for loading indicator.

The updated condition for displaying the loading indicator is more comprehensive, improving user feedback during data loading scenarios.

Comment on lines +9 to +24
describe("tests lightning selectors", () => {
it("resolves wildcard indexed fields with database path", () => {
const test = <TestSelectorFamily<typeof lightning.lightningPaths>>(
(<unknown>lightning.lightningPaths("ground_truth"))
);
setMockAtoms({
dbPath: (p) =>
p === "ground_truth.id" ? "ground_truth._id" : "ground_truth.label",
expandPath: () => "ground_truth",
fieldPaths: () => ["id", "label"],
indexesByPath: new Set(["ground_truth._id", "ground_truth.label"]),
isLabelPath: () => true,
});

expect(test()).toEqual(new Set(["ground_truth.id", "ground_truth.label"]));
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Well-implemented test case for lightningPaths selector.

The test case effectively checks the selector's ability to resolve database paths. Consider adding more test cases to cover edge cases and error handling scenarios.

Would you like me to help in writing additional test cases?

@benjaminpkane benjaminpkane force-pushed the bugfix/lightning-filters branch from 79d519a to eba6938 Compare August 30, 2024 15:37
@benjaminpkane benjaminpkane changed the base branch from release/v0.25.1 to develop August 30, 2024 15:38
@@ -180,7 +180,7 @@ const Checkboxes = ({
const show = useRecoilValue(showSearchSelector({ modal, path }));
const getCount = useGetCount(modal, path);

if (loading) {
if (loading || (!show && results === null)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably we should add a comment here to explain this

Copy link
Contributor

@minhtuev minhtuev left a comment

Choose a reason for hiding this comment

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

Added a comment otherwise LGTM

@findtopher
Copy link
Member

If this is fixes, should this target release/v0.25.1?

@benjaminpkane benjaminpkane marked this pull request as draft September 3, 2024 13:53
@benjaminpkane
Copy link
Contributor Author

benjaminpkane commented Sep 3, 2024

Could use more testing. Converting to draft

@benjaminpkane benjaminpkane marked this pull request as ready for review September 11, 2024 20:35
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.

3 participants