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

Improve search results for multikey indexes in group datasets #5208

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

benjaminpkane
Copy link
Contributor

@benjaminpkane benjaminpkane commented Dec 3, 2024

What changes are proposed in this pull request?

Including a filter for a distinct call prevents a distinct scan, so omit the group slice

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

    • Simplified distinct query processing, which may return broader result sets without specific filters.
  • Bug Fixes

    • Adjusted expected output in unit tests to reflect changes in query results, ensuring accuracy in test cases.

@benjaminpkane benjaminpkane self-assigned this Dec 3, 2024
Copy link
Contributor

coderabbitai bot commented Dec 3, 2024

Walkthrough

The pull request modifies the lightning.py file by removing the filter parameter from the _do_async_query and _do_distinct_query functions. This change alters how distinct queries are executed, as filtering criteria will no longer be applied during these operations. The modifications streamline the query process but may result in broader result sets from distinct queries. Additionally, updates were made to the test cases in lightning_tests.py to reflect the new expected outputs.

Changes

File Change Summary
fiftyone/server/lightning.py Updated function signatures for _do_async_query and _do_distinct_query to remove filter parameter.
tests/unittests/lightning_tests.py Adjusted expected output for classifications.classifications.label in two test cases to include both "one" and "two".

Possibly related PRs

Suggested labels

enhancement, app, bug

Suggested reviewers

  • minhtuev
  • brimoor

Poem

In the server's glow, we make a change,
Queries now broader, a little strange.
Filters removed, let the results flow,
In the world of data, new paths we sow.
With each little hop, we refine our quest,
A rabbit's delight, we strive for the best! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 04bc724 and 458efd5.

📒 Files selected for processing (1)
  • tests/unittests/lightning_tests.py (2 hunks)
🔇 Additional comments (1)
tests/unittests/lightning_tests.py (1)

1135-1135: Test expectations updated to reflect new distinct query behavior

The test expectations have been updated to reflect that distinct queries now return all unique values across the dataset, regardless of the slice being queried. This change aligns with the PR objective of improving search results for multikey indexes by preventing distinct scans.

Let's verify this behavior change is consistent with other test cases:

Also applies to: 1167-1167

✅ Verification successful

Let me analyze the search results to verify the behavior change. I need to get more context about the test class and its setup.


Based on the test context, I can now provide a final response about the review comment:

Test expectations correctly reflect distinct query behavior

The test expectations are correct and consistent with the implementation. The test creates two samples with classifications labeled "one" and "two", and even when querying only the "one" slice, the distinct values query returns both labels ["one", "two"]. This is the expected behavior as distinct queries should return all unique values across the dataset regardless of the slice being queried.

Key evidence:

  • The test creates two samples with different classification labels ("one" and "two")
  • The test explicitly queries only the "one" slice samples
  • The expected result includes both values in classifications.classifications.label
  • This behavior is consistent across multiple test cases in the file
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other test cases that might need similar updates for distinct queries

# Search for similar test patterns with distinct queries
rg -A 5 'values": \[.*\]' tests/unittests/

Length of output: 20663


Script:

#!/bin/bash
# Get the context of the TestGroupDatasetLightningQueries class and its test methods
rg -B 10 -A 10 "class TestGroupDatasetLightningQueries" tests/unittests/lightning_tests.py

Length of output: 984


Script:

#!/bin/bash
# Get more context about the test method and the sample data
rg -B 20 -A 30 "test_group_dataset" tests/unittests/lightning_tests.py

Length of output: 1949


Script:

#!/bin/bash
# Get the query and expected results context
rg -A 50 'query = """' tests/unittests/lightning_tests.py

Length of output: 11631


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

🧹 Outside diff range and nitpick comments (1)
fiftyone/server/lightning.py (1)

352-353: LGTM! Consider monitoring query performance

The removal of filtering from the distinct operation should improve performance by preventing distinct scans. Consider adding performance monitoring to validate the improvement.

Consider adding metrics collection for query execution time to quantify the performance improvement. This could help validate the effectiveness of this change and identify any potential bottlenecks.

🧰 Tools
🪛 Ruff (0.8.0)

353-353: Do not use bare except

(E722)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between cea9b9a and 04bc724.

📒 Files selected for processing (1)
  • fiftyone/server/lightning.py (2 hunks)
🔇 Additional comments (1)
fiftyone/server/lightning.py (1)

331-331: Verify the impact on group datasets

The removal of the filter parameter from _do_distinct_query aligns with the PR objective of preventing distinct scans. However, we should verify that this change doesn't affect the correctness of results for group datasets.

✅ Verification successful

Removal of filter parameter is safe and intentional

The code analysis reveals that the removal of the filter parameter from _do_distinct_query is correct and safe because:

  1. _do_distinct_query is only called for fields that have list types (when query.has_list is true)
  2. For non-list fields, the code uses _do_distinct_pipeline which properly handles filtering
  3. The change aligns with the PR's goal of preventing distinct scans on multikey indexes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usages of _do_distinct_query to understand the impact
# Test: Look for calls to _do_distinct_query and verify they don't rely on filtering
rg -A 5 "_do_distinct_query" --type python

Length of output: 73


Script:

#!/bin/bash
# Search for usages of _do_distinct_query without file type flag
rg -A 5 "_do_distinct_query"

Length of output: 711


Script:

#!/bin/bash
# Let's look at the implementation of _do_distinct_query and surrounding context
ast-grep --pattern $'async def _do_distinct_query($$$) {
  $$$
}'

Length of output: 66


Script:

#!/bin/bash
# Let's examine the full context of the file to understand the changes
cat fiftyone/server/lightning.py

Length of output: 14092

@benjaminpkane benjaminpkane merged commit 0e3fa78 into release/v1.1.0 Dec 3, 2024
13 checks passed
@benjaminpkane benjaminpkane deleted the distinct-scans branch December 3, 2024 17:54
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