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

Merge release/v1.1.0 to develop #5126

Merged
merged 5 commits into from
Nov 16, 2024
Merged

Merge release/v1.1.0 to develop #5126

merged 5 commits into from
Nov 16, 2024

Conversation

voxel51-bot
Copy link
Collaborator

@voxel51-bot voxel51-bot commented Nov 15, 2024

Merge release/v1.1.0 to develop

Summary by CodeRabbit

  • New Features

    • Enhanced rendering logic for sidebar components based on modal state.
    • Introduced a new max_inline_actions property in the TableView component for customizable inline actions.
  • Bug Fixes

    • Improved conditions for enabling/disabling filter paths and frame filtering in the IconWrapper component.
  • Tests

    • Expanded test data for float-related queries to include a broader range of values, enhancing test coverage.

benjaminpkane and others added 3 commits November 15, 2024 12:59
* modal checks

* still allow modal frame filters when frame filtering is disabled

* fix logic
* improve float tests

* lightning _first fix

* None handling
Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The changes in this pull request involve modifications to several components within the application, particularly focusing on the handling of the modal state across various files. The EntryCounts.tsx, Icon.tsx, and useTitleTemplate.tsx files have updated their logic to incorporate conditions based on the modal prop, affecting when certain UI elements are rendered. Additionally, the lightning.py file underwent structural changes in the aggregation pipeline and result parsing, enhancing data processing. The test suite has been updated to include new test data for float-related queries.

Changes

File Change Summary
app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx Modified PathEntryCounts to evaluate queryPerformance based on modal state; updated rendering conditions.
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Icon.tsx Adjusted disabled and frameFilteringDisabled states to depend on modal prop, refining rendering logic.
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/useTitleTemplate.tsx Changed disabled to enabled for rendering logic based on checkbox state; updated function signature.
fiftyone/server/lightning.py Altered _first, _parse_result, and _unwind functions for improved data aggregation and result handling.
tests/unittests/lightning_tests.py Updated test data for float-related queries to include new values, enhancing test coverage without altering assertions.
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx Modified rendering condition for inline actions to allow one additional action when the count equals maxInline.
app/packages/core/src/plugins/SchemaIO/components/TableView.tsx Added max_inline_actions prop to TableView, allowing customization of inline actions displayed in ActionsMenu.

Possibly related PRs

  • Fix modal sidebar regressions #5116: This PR modifies the PathEntryCounts component in EntryCounts.tsx, which is directly related to the changes made in the main PR that also involves the PathEntryCounts component.
  • Lightning filter fixes #4757: This PR includes changes to the useTitleTemplate function, which affects the rendering logic of components including PathEntryCounts and Icon, similar to the changes in the main PR.
  • Update TableView with multi inline actions #5118: The updates to the TableView component in this PR include changes to how actions are displayed, which may relate to the rendering logic in the EntryCounts.tsx file of the main PR.
  • Fix lightning numeric bounds #5125: This PR addresses issues related to numeric bounds in the lightning.py file, which may indirectly relate to the rendering logic and conditions in the EntryCounts.tsx component, especially if numeric data is involved in the rendering conditions.

Suggested reviewers

  • findtopher

🐇 In the code, we hop and play,
With modal checks to save the day.
From counts to icons, all aligned,
In tests, new values we did find.
So let’s rejoice, with code so bright,
Our rabbit hearts are filled with delight! 🐇


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 (6)
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Icon.tsx (1)

Line range hint 43-63: Consider enhancing type safety with discriminated unions

The component's behavior significantly differs based on the combination of multiple boolean flags (queryPerformance, indexed, modal, frameField). Consider using a discriminated union type to make these relationships more explicit and type-safe.

type IconState = 
  | { type: 'lightning'; path: string; frameFilteringDisabled: boolean }
  | { type: 'arrow'; path: string; disabled: boolean; frameFilteringDisabled: boolean };

function determineIconState(props: {
  queryPerformance: boolean;
  indexed: boolean;
  modal: boolean;
  frameField: boolean;
  path: string;
  disabled: boolean;
  frameFilteringDisabled: boolean;
}): IconState {
  const { queryPerformance, indexed, modal, frameField, path, disabled, frameFilteringDisabled } = props;
  
  if (queryPerformance && indexed && !modal && !frameField) {
    return { type: 'lightning', path, frameFilteringDisabled };
  }
  
  return { type: 'arrow', path, disabled, frameFilteringDisabled };
}
app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx (2)

44-44: Consider extracting the modal-dependent query performance logic

The condition !modal is now coupled with query performance check. Consider extracting this logic into a separate selector for better reusability and maintainability.

-const queryPerformance = useRecoilValue(fos.queryPerformance) && !modal;
+const modalAwareQueryPerformance = selectorFamily<boolean, { modal: boolean }>({
+  key: "modalAwareQueryPerformance",
+  get: (params) => ({get}) => {
+    return get(fos.queryPerformance) && !params.modal;
+  }
+});
+const queryPerformance = useRecoilValue(modalAwareQueryPerformance({modal}));

Line range hint 9-13: Enhance type safety with literal type for modal

The modal prop could benefit from a more specific type definition since it's used in boolean operations.

interface PathEntryCountsProps {
  path: string;
-  modal: boolean;
+  modal: true | false;
}
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/useTitleTemplate.tsx (2)

100-103: Consider memoizing Recoil values to prevent unnecessary re-renders.

The component reads multiple Recoil values which could trigger re-renders. Consider combining these values using a selector or memoizing them.

+ const titleState = useRecoilValue(
+   selector({
+     key: 'titleState',
+     get: ({get}) => ({
+       enabled: !get(fos.isDisabledCheckboxPath(path)),
+       isFilterMode: get(fos.isSidebarFilterMode),
+       expandedPath: get(fos.expandPath(path))
+     })
+   })
+ );
- const enabled = !useRecoilValue(fos.isDisabledCheckboxPath(path));
- const isFilterMode = useRecoilValue(fos.isSidebarFilterMode);
- const expandedPath = useRecoilValue(fos.expandPath(path));

Line range hint 1-107: Add TypeScript type definitions for better type safety.

The hook parameters and return types should be explicitly typed for better maintainability and type safety.

+ interface HoverHandlers {
+   onMouseEnter: () => void;
+   onMouseLeave: () => void;
+ }
+ 
+ interface TitleTemplateProps {
+   hoverHandlers: HoverHandlers;
+   hoverTarget: React.RefObject<HTMLSpanElement>;
+   container: React.RefObject<HTMLDivElement>;
+ }
+ 
- const useTitleTemplate = ({
+ const useTitleTemplate = ({ 
   modal,
   path,
}: {
   modal: boolean;
   path: string;
- }) => {
+ }): ((props: TitleTemplateProps) => JSX.Element) => {
-  return function useTitleTemplate({ hoverHandlers, hoverTarget, container }) {
+  return function useTitleTemplate({ hoverHandlers, hoverTarget, container }: TitleTemplateProps) {
fiftyone/server/lightning.py (1)

482-488: Consider adding error handling for invalid field paths

The prefix handling for frame fields is correct, but consider adding validation for the field path to prevent potential errors when accessing invalid paths.

Add error handling like this:

     prefix = ""
     if is_frame_field:
         prefix = "frames."
 
     for key in keys:
         path = ".".join([path, key]) if path else key
+        full_path = f"{prefix}{path}"
+        if not dataset.has_field(full_path):
+            raise ValueError(f"Invalid field path: {full_path}")
-        field = dataset.get_field(f"{prefix}{path}")
+        field = dataset.get_field(full_path)
         while isinstance(field, fof.ListField):
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 476e534 and f23d634.

📒 Files selected for processing (5)
  • app/packages/core/src/components/Sidebar/Entries/EntryCounts.tsx (1 hunks)
  • app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Icon.tsx (1 hunks)
  • app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/useTitleTemplate.tsx (2 hunks)
  • fiftyone/server/lightning.py (3 hunks)
  • tests/unittests/lightning_tests.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
app/packages/core/src/components/Sidebar/Entries/EntryCounts.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/Icon.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/useTitleTemplate.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.

🔇 Additional comments (6)
app/packages/core/src/components/Sidebar/Entries/FilterablePathEntry/Icon.tsx (1)

43-46: LGTM! The modal state handling looks correct.

The changes properly integrate the modal prop into the disabled state calculations, ensuring that filtering remains enabled during modal interactions. This aligns with the PR's objective of improving modal state handling across components.

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

Line range hint 31-42: LGTM: Proper memoization of atom getter

Good use of useCallback for memoizing the atom getter function with correct dependencies.

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

81-81: LGTM! Improved readability with positive condition.

The change from disabled to enabled using negation makes the code more intuitive and easier to understand.

fiftyone/server/lightning.py (2)

468-472: LGTM: Enhanced result parsing logic

The updated parsing logic correctly handles both the new group stage structure (using "value" field) and maintains backward compatibility (fallback to "_id").


397-405: LGTM: Improved aggregation pipeline structure

The changes improve the robustness of the aggregation pipeline by:

  1. Ensuring correct ordering after unwinding arrays
  2. Using a more standard MongoDB aggregation pattern for grouping results

Let's verify the aggregation pipeline behavior with different field types:

✅ Verification successful

Let me search for the actual usage of _first function to understand how it's used with different field types.


Let me check how the _first function is used in the context of aggregation pipelines.


Based on the code analysis, I can now provide a final assessment of the changes to the _first function.

The aggregation pipeline changes are correct and improve robustness

The modifications to the _first function's aggregation pipeline are well-structured and handle edge cases appropriately:

  1. The sorting step is correctly placed at the start of the pipeline with {"$sort": {path: sort}}
  2. The $group stage with "_id": None and dynamic $min/$max operator is a standard MongoDB pattern for finding extreme values
  3. The pipeline properly handles array fields through _match_arrays helper
  4. Special handling for float values is preserved through _handle_nonfinites

The changes maintain the function's core purpose while using more idiomatic MongoDB aggregation patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of the _first function to ensure compatibility
# with different field types and array scenarios

# Search for field definitions that might use this aggregation
rg -B 2 -A 2 "ListField|ArrayField" 

# Search for direct calls to _first to understand usage patterns
ast-grep --pattern '_first($path, $dataset, $sort, $is_frame_field)'

Length of output: 147373


Script:

#!/bin/bash
# Search for direct calls to _first function to understand its usage patterns
rg -B 5 -A 5 "_first\("

Length of output: 3034


Script:

#!/bin/bash
# Get the full implementation and usage context of _first function
rg -B 20 -A 20 "def _first\(" fiftyone/server/lightning.py

Length of output: 1031

tests/unittests/lightning_tests.py (1)

491-491: LGTM! Enhanced test coverage with boundary value.

The addition of 0.0 to the float lists improves test coverage by including an important boundary value. This change helps ensure that the lightning queries handle zero values correctly in combination with positive and negative numbers.

Let's verify that the test assertions properly handle these new test cases:

Also applies to: 493-493, 495-495, 497-497, 511-511, 515-515, 517-517

✅ Verification successful

Test coverage is properly verified

The test data structure and assertions are well-designed to verify the handling of zero values:

  • The test includes comprehensive combinations of 0.0 with positive and negative numbers in lists
  • The test data covers edge cases by mixing 0.0 with special values (inf, -inf, nan)
  • The test uses FloatLightningResult type to verify numeric properties
  • The assertions validate the results through the GraphQL query response
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the test assertions cover the new test cases with zero values
# Expected: The assertions should check min/max values which would be affected by zero

rg -A 5 '"lightning",' tests/unittests/lightning_tests.py | rg -A 5 'FloatLightningResult'

Length of output: 90


Script:

#!/bin/bash
# Let's try a different approach to find the test assertions in the FloatLightningQueries class

rg -B 2 -A 10 "class TestFloatLightningQueries" tests/unittests/lightning_tests.py

Length of output: 457


Script:

#!/bin/bash
# Let's also check the specific test methods that might be using these float lists

rg -B 2 -A 15 "float_list=\[0\.0, -1\.0\]" tests/unittests/lightning_tests.py

Length of output: 639


Script:

#!/bin/bash
# Search for any assertions or result validations in the test file

rg "assert|\.result" tests/unittests/lightning_tests.py

Length of output: 237


Script:

#!/bin/bash
# Let's get more context around the assertions to see what they're actually checking

rg -B 5 -A 5 "assertListEqual" tests/unittests/lightning_tests.py

Length of output: 2014


Script:

#!/bin/bash
# Let's also check the complete test method to understand the full test flow

rg -B 10 -A 30 "async def test_floats" tests/unittests/lightning_tests.py

Length of output: 1351


Script:

#!/bin/bash
# Let's get the complete test method including the query and assertions for float fields

rg -B 5 -A 40 'async def test_floats' tests/unittests/lightning_tests.py

Length of output: 1413

minhtuev and others added 2 commits November 15, 2024 14:51
* Allowing TableView to pass max_inline_actions as an arg

Co-authored-by: minhtuevo <[email protected]>
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 and nitpick comments (1)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1)

Line range hint 114-114: Consider making onClick optional in ActionPropsType.

The type definition shows onClick as required, but the code uses the optional chaining operator ?.. Consider updating the type to match the implementation:

type ActionPropsType = {
  name: string;
  label: string;
-  onClick: (action: ActionPropsType, e: React.MouseEvent) => void;
+  onClick?: (action: ActionPropsType, e: React.MouseEvent) => void;
  icon: string;
  variant: string;
  mode: "inline" | "menu";
  color?: string;
  size?: SizeType;
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f23d634 and 84ba847.

📒 Files selected for processing (2)
  • app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.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/plugins/SchemaIO/components/TableView.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.

🔇 Additional comments (3)
app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx (1)

21-21: LGTM! The condition change improves action visibility.

The updated condition actions.length <= maxInline is more intuitive than the previous exact match, allowing better utilization of inline actions when space permits.

Please verify the UI layout renders correctly with multiple inline actions:

✅ Verification successful

The condition change is safe and properly implemented

The code analysis reveals:

  • The component handles both inline and overflow menu cases correctly
  • maxInline prop is properly typed and has a default value of DEFAULT_MAX_INLINE = 1
  • TableView uses the component with a configurable max_inline_actions prop
  • The UI implementation uses Material-UI's Stack with proper spacing for inline actions
  • The component gracefully handles size variations with appropriate styling
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for test files and snapshots that might need updating
rg -g "*.{test,spec}.{ts,tsx}" -l "ActionsMenu"
rg -g "__snapshots__/*.snap" -l "ActionsMenu"

Length of output: 242


Script:

#!/bin/bash
# Let's try a broader search for test files and related components
fd -e test.tsx -e test.ts -e spec.tsx -e spec.ts . app/packages/core/src/plugins/SchemaIO/
fd -e tsx -e ts . app/packages/core/src/plugins/SchemaIO/ --exec rg -l "ActionsMenu"

Length of output: 307


Script:

#!/bin/bash
# Let's examine how ActionsMenu is used in TableView and check the maxInline prop usage
rg -A 5 -B 5 "ActionsMenu" app/packages/core/src/plugins/SchemaIO/components/TableView.tsx
# Also check the ActionsMenu component implementation for default value and prop types
cat app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx

Length of output: 4018

app/packages/core/src/plugins/SchemaIO/components/TableView.tsx (2)

36-36: Implementation follows React best practices

The changes maintain consistent patterns with the existing codebase:

  • Proper use of default values
  • Consistent prop passing
  • Maintains existing component structure

Also applies to: 202-202


202-202: Verify ActionsMenu implementation for maxInline prop

The prop name changes from snake_case (max_inline_actions) to camelCase (maxInline). Let's verify the ActionsMenu component implementation.

✅ Verification successful

Props naming convention is consistent in ActionsMenu implementation

The verification shows that the maxInline prop is properly defined and used within the ActionsMenu component:

  • It's correctly typed as an optional number prop in the interface
  • It's properly destructured from props with a default value
  • The camelCase naming convention is consistently used within the component
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for ActionsMenu component definition and usage of maxInline prop
ast-grep --pattern 'interface $interface {
  $$$
  maxInline$_: $_
  $$$
}'

# Find all usages of maxInline in ActionsMenu
rg -A 5 'maxInline' app/packages/core/src/plugins/SchemaIO/components/ActionsMenu.tsx

Length of output: 564

@@ -33,6 +33,7 @@ export default function TableView(props: ViewPropsType) {
selected_color,
size = "small",
variant = "filled",
max_inline_actions = 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add TypeScript type definition for max_inline_actions

The new prop should be properly typed in the view schema type definition to maintain type safety.

Add the type definition to the view schema interface:

interface ViewSchema {
  // ... existing props
  max_inline_actions?: number;
}

@benjaminpkane benjaminpkane merged commit f427d46 into develop Nov 16, 2024
14 checks passed
@benjaminpkane benjaminpkane deleted the merge/release/v1.1.0 branch November 16, 2024 00:01
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