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 mode refactor and disable/enable qp mode toggle #4928

Merged
merged 6 commits into from
Oct 15, 2024

Conversation

minhtuev
Copy link
Contributor

@minhtuev minhtuev commented Oct 15, 2024

What changes are proposed in this pull request?

Refactored lightning mode to rename as query performance mode and allowed enabling/disabling qp mode toggle through deployment vars

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

Release Notes

Is this a user-facing change that should be mentioned in the release notes?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release
    notes for FiftyOne users.

(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)

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 selectors for query performance configuration.
  • Improvements

    • Renamed and restructured components related to performance modes for clarity and consistency.
    • Updated tooltip texts and links to reflect the new query performance mode.
    • Enhanced rendering logic to ensure correct display of performance-related information.
  • Documentation

    • Updated component exports and type definitions for better clarity.

@minhtuev minhtuev marked this pull request as ready for review October 15, 2024 08:19
Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

Walkthrough

The pull request introduces significant changes across multiple components, primarily renaming and restructuring elements associated with performance modes. The LIGHTNING_MODE constant is replaced with QP_MODE throughout various components, including Options.tsx, FieldLabelAndInfo, Arrow, and Tune. Additionally, new selectors for query performance configuration are added in the lightning.ts file. These changes aim to unify the handling of performance modes and improve clarity in the codebase.

Changes

File Path Change Summary
app/packages/core/src/components/Actions/Options.tsx Renamed Lightning to QueryPerformance, updated constants and rendering conditions.
app/packages/core/src/components/FieldLabelAndInfo/index.tsx Replaced LIGHTNING_MODE with QP_MODE, updated useFieldInfo hook and FieldInfoTable logic.
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Arrow.tsx Updated to use QP_MODE instead of LIGHTNING_MODE in tooltip logic.
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Tune.tsx Changed import from LIGHTNING_MODE to QP_MODE, affecting Tooltip and DisabledReason.
app/packages/core/src/utils/links.ts Renamed LIGHTNING_MODE to QP_MODE, retaining original URL value.
app/packages/state/src/recoil/lightning.ts Introduced new selectors for query performance configuration, added enableQueryPerformanceConfig and defaultQueryPerformanceConfig.
e2e-pw/src/oss/poms/action-row/display-options.ts Updated setLightningMode method to use qp-mode-${mode} selector string.

Possibly related PRs

  • Added two env vars for enabling query performance #4917: The changes in this PR involve renaming and restructuring related to query performance, which aligns with the modifications made in the main PR regarding the Lightning component being renamed to QueryPerformance and the introduction of QP_MODE.

Suggested reviewers

  • benjaminpkane

Poem

In the code where rabbits play,
LIGHTNING_MODE has hopped away.
With QP_MODE now in sight,
Performance shines, oh what a delight!
Components dance, all in line,
A clearer path, our code will shine! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3231978 and 8beadb0.

📒 Files selected for processing (1)
  • app/packages/core/src/components/Actions/Options.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/core/src/components/Actions/Options.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>, 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.

@minhtuev minhtuev changed the title Lightning mode refactor Lightning mode refactor and disable/enable qp mode toggle Oct 15, 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

🧹 Outside diff range and nitpick comments (7)
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Tune.tsx (2)

57-57: LGTM: Constant usage updated correctly

The QP_MODE constant is correctly used in the href prop of the DisabledReason component, maintaining consistency with the import change. This update aligns with the PR objective and doesn't introduce any issues.

Consider updating the text prop from "add an index" to "enable query performance mode" for better clarity and consistency with the new terminology. This would make the tooltip message more explicit about the action being suggested.

- text={<DisabledReason href={QP_MODE} text={"add an index"} />}
+ text={<DisabledReason href={QP_MODE} text={"enable query performance mode"} />}

Line range hint 1-67: Overall impact: Minimal and consistent with PR objective

The changes in this file successfully implement the renaming from "lightning mode" to "query performance mode" without affecting the component's structure or functionality. The updates are minimal, localized, and don't introduce any breaking changes.

To improve code organization and make it easier to update in the future, consider extracting the hardcoded string "add an index" into a constant at the top of the file. This would centralize all text content and make it easier to maintain:

const ADD_INDEX_TEXT = "add an index";
// or with the suggested update:
// const ENABLE_QP_MODE_TEXT = "enable query performance mode";

// Then use it in the component:
text={<DisabledReason href={QP_MODE} text={ADD_INDEX_TEXT} />}

This change would make the component more maintainable and easier to update in the future.

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

63-63: LGTM: Component logic updated correctly

The component logic has been updated to use QP_MODE instead of LIGHTNING_MODE in the Tooltip's text prop. This change is consistent with the refactoring from "lightning mode" to "query performance mode" and doesn't affect the overall functionality of the component.

For consistency, consider updating the text in the DisabledReason component from "add an index" to something more specific to "query performance mode", such as "enable query performance mode" or "add an index for query performance". This would make the tooltip message more aligned with the new terminology.

app/packages/state/src/recoil/lightning.ts (1)

203-211: Good integration of new selectors, minor suggestion for organization

The new enableQueryPerformanceConfig and defaultQueryPerformanceConfig selectors are well-integrated into the existing codebase. They follow the same pattern as the lightningThresholdConfig selector and are placed logically within the file structure.

The naming convention aligns with the "query performance" terminology mentioned in the PR objectives, which is good for consistency.

Consider grouping all configuration-related selectors together for better code organization. You could move the lightningThresholdConfig selector (defined at line 199) next to the new selectors for improved readability and maintainability.

app/packages/core/src/components/Actions/Options.tsx (1)

Line range hint 219-285: LGTM: QueryPerformance component updated correctly.

The renaming from "Lightning" to "QueryPerformance" has been consistently applied throughout the component. The new enableQpMode condition, updated attributes, and refactored active state logic improve the component's functionality and readability.

Consider extracting the enableQpMode condition to a custom hook or memoized value for better reusability and performance:

const enableQpMode = useMemo(() => 
  useRecoilValue(fos.enableQueryPerformanceConfig) && useRecoilValue(fos.defaultQueryPerformanceConfig),
  [fos.enableQueryPerformanceConfig, fos.defaultQueryPerformanceConfig]
);

This change would prevent unnecessary re-renders and improve code organization.

app/packages/core/src/components/FieldLabelAndInfo/index.tsx (2)

23-23: Approved: Import statement updated correctly

The import statement has been successfully updated from LIGHTNING_MODE to QP_MODE, which aligns with the PR objective of renaming "lightning mode" to "query performance mode".

Consider updating the variable name lightnigPath to queryPerformancePath or qpPath in the Lightning component for consistency with the new naming convention.


348-348: Approved: External link updated, but consider further renaming

The href attribute has been correctly updated to use QP_MODE, which is consistent with the import statement change and the PR objective.

For better consistency with the new "query performance mode" terminology, consider the following refactoring suggestions:

  1. Rename the Lightning component to QueryPerformance or QPMode.
  2. Update the following variable names:
    • lightning to queryPerformance or qpMode
    • lightnigPath to queryPerformancePath or qpPath
  3. Update the link text from "Lightning indexed" to "Query Performance indexed" or "QP indexed".

These changes would ensure that the component and its internal variables align with the new naming convention throughout the codebase.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 16f55b0 and 3634828.

📒 Files selected for processing (6)
  • app/packages/core/src/components/Actions/Options.tsx (4 hunks)
  • app/packages/core/src/components/FieldLabelAndInfo/index.tsx (2 hunks)
  • app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Arrow.tsx (2 hunks)
  • app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Tune.tsx (2 hunks)
  • app/packages/core/src/utils/links.ts (1 hunks)
  • app/packages/state/src/recoil/lightning.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
app/packages/core/src/components/Actions/Options.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/FieldLabelAndInfo/index.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/Sidebar/Entries/FilterablePathEntry/Arrow.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/Sidebar/Entries/FilterablePathEntry/Tune.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/utils/links.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/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 (10)
app/packages/core/src/utils/links.ts (1)

16-17: Approve renaming, but suggest URL update and usage verification.

The renaming from LIGHTNING_MODE to QP_MODE aligns with the PR objectives. However, consider the following points:

  1. The URL still contains "lightning-mode" in its path. It might be beneficial to update the documentation URL to reflect the new "query performance mode" terminology.
  2. Ensure that all references to this constant throughout the codebase have been updated to use QP_MODE.

To verify the usage of QP_MODE across the codebase, run the following script:

This script will help identify any missed replacements and confirm the correct usage of the new constant name.

✅ Verification successful

Approve renaming and recommend URL update.

The renaming from LIGHTNING_MODE to QP_MODE has been successfully applied across the codebase. However, the URL associated with QP_MODE still references "lightning-mode". Please update the documentation URL to reflect the new "query performance mode" terminology.

  • Update the URL in app/packages/core/src/utils/links.ts to use "query-performance-mode" instead of "lightning-mode".
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to LIGHTNING_MODE and verify QP_MODE usage

# Search for any remaining LIGHTNING_MODE references
echo "Searching for LIGHTNING_MODE references:"
rg --type-not md "LIGHTNING_MODE"

# Search for QP_MODE usage
echo "Searching for QP_MODE usage:"
rg --type-not md "QP_MODE"

Length of output: 1182

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

6-6: LGTM: Import statement updated correctly

The import statement has been updated to use QP_MODE instead of LIGHTNING_MODE, which aligns with the PR objective of renaming "lightning mode" to "query performance mode". This change is consistent and doesn't introduce any issues.

app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Arrow.tsx (2)

10-10: LGTM: Import statement updated correctly

The import statement has been updated to use QP_MODE instead of LIGHTNING_MODE, which is consistent with the reported refactoring from "lightning mode" to "query performance mode". This change maintains the overall structure of the imports while reflecting the new terminology.


Line range hint 1-93: Summary: Successful refactoring of lightning mode to query performance mode

The changes in this file successfully implement the renaming of "lightning mode" to "query performance mode". The modifications are minimal and focused, affecting only the import statement and one instance in the component logic. These changes maintain the overall structure and functionality of the Arrow component while updating the terminology.

The component continues to adhere to React and TypeScript best practices, and the changes are consistent with the PR objectives. No new issues have been introduced, and the refactoring has been implemented cleanly.

app/packages/state/src/recoil/lightning.ts (3)

203-206: LGTM: enableQueryPerformanceConfig selector implementation

The implementation of the enableQueryPerformanceConfig selector follows Recoil best practices. It uses a unique key and correctly retrieves the enableQueryPerformance property from the config object. The naming is clear and consistent with the existing code style.


208-211: LGTM: defaultQueryPerformanceConfig selector implementation

The implementation of the defaultQueryPerformanceConfig selector adheres to Recoil best practices. It uses a unique key and correctly retrieves the defaultQueryPerformance property from the config object. The naming is clear and consistent with the existing code style.


203-211: Summary: Changes align well with PR objectives

The additions to this file align well with the PR objectives of refactoring the "lightning mode" to "query performance mode". The new selectors (enableQueryPerformanceConfig and defaultQueryPerformanceConfig) provide a clear interface for accessing query performance-related configuration.

These changes contribute to the overall goal of improving clarity in the codebase and unifying the handling of performance modes. The implementation is consistent with existing patterns and follows best practices for Recoil and TypeScript.

app/packages/core/src/components/Actions/Options.tsx (3)

20-20: LGTM: Import statement updated correctly.

The addition of QP_MODE import is consistent with the renaming from "Lightning mode" to "Query Performance mode".


376-376: LGTM: Conditional rendering of QueryPerformance component updated correctly.

The change ensures that the QueryPerformance component is only rendered when there's no active view, which is consistent with the component's purpose and improves the UI logic.


Line range hint 1-385: LGTM: Successful renaming of "Lightning mode" to "Query Performance mode".

The changes in this file consistently rename "Lightning mode" to "Query Performance mode" throughout the components and their usage. The modifications align well with the PR objectives and maintain the overall structure and functionality of the file. The renaming has been applied correctly to imports, component names, attributes, and rendering logic.

Great job on maintaining consistency and improving the clarity of the codebase!

@sashankaryal
Copy link
Contributor

Lightning mode e2e tests are failing. It might be an actual regression or the specs might have to be updated.

const [threshold, setThreshold] = useRecoilState(fos.lightningThreshold);
const config = useRecoilValue(fos.lightningThresholdConfig);
const reset = useResetRecoilState(fos.lightningThreshold);
const count = useRecoilValue(fos.datasetSampleCount);
const theme = useTheme();
const enableQpMode = useRecoilValue(fos.enableQueryPerformanceConfig) && useRecoilValue(fos.defaultQueryPerformanceConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

In React, hooks cannot be run conditionally. This should be changed to two separate lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

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.

LGTM 🚀

@minhtuev minhtuev merged commit 92f7e1f into develop Oct 15, 2024
11 checks passed
@minhtuev minhtuev deleted the feat/lightning-mode-refactor branch October 15, 2024 21:57
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.

3 participants