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

Release/v0.25.1 #4774

Merged
merged 23 commits into from
Sep 6, 2024
Merged

Release/v0.25.1 #4774

merged 23 commits into from
Sep 6, 2024

Conversation

findtopher
Copy link
Member

@findtopher findtopher commented Sep 6, 2024

Release v0.25.1

Summary by CodeRabbit

  • New Features

    • Enhanced PillButton component with improved property organization.
    • Introduced useRecords hook for better state management of records.
    • Added keyboard event handling to SampleWrapper for improved user interaction.
    • New optional dataCy property in PillEntry for better accessibility and testing.
    • Integrated useKey hook in TabsView for improved user interaction tracking.
    • Added asynchronous methods to ModalSidebarPom for enhanced testing capabilities.
  • Bug Fixes

    • Resolved issues with dataset permissions and sample modal interactions.
    • Fixed sidebar state persistence and sample selection bugs.
  • Documentation

    • Updated plugin documentation to clarify capabilities of the configuration file.
  • Tests

    • Added unit tests for useRecords and useSelectSample functionalities.
    • Enhanced test coverage for PanelRef class and new test cases for various functionalities.

swheaton and others added 23 commits August 23, 2024 15:15
* modal filter + tagging fix, e2e sketch

* e2e with screenshot assertions

* lint unused

* add back sample_ids

* event tweak
* handle keypoint and keypoints

* other tests

* lint
* lint graphQLSyncFragmentAtomFamily

* rm unused exposed function, add on set for grid sidebar

* fix sidebar persitence

* add expansion inheritance
Fix bug with group_by(..., match_expr=)
* clear records on page refresh

* refactor as independent hook, add hook test

* rm useRef

* fixing selections with partial index records

* add range tests

* relay cleanup tweak

* typos
Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Walkthrough

The changes encompass various enhancements across multiple files, including modifications to component properties, the introduction of new hooks and tests, and adjustments to state management. Key updates involve the restructuring of type definitions, the implementation of new testing strategies for hooks and components, and refinements in the handling of user interactions and data processing within the application.

Changes

Files Change Summary
app/packages/components/src/components/PillButton/PillButton.tsx Reordered properties in PillButtonProps type definition for better organization.
app/packages/core/src/components/Grid/Grid.tsx Updated import statements, initialized selectSample after spacing, integrated useRecords hook.
app/packages/core/src/components/Grid/useRecords.test.ts Introduced unit tests for useRecords hook, verifying state updates based on clear string changes.
app/packages/core/src/components/Grid/useRecords.ts Defined useRecords hook with memoization for a Map object, optimizing record management.
app/packages/core/src/components/Grid/useSelect.ts Changed ID import to a type-only import for optimization.
app/packages/core/src/components/Grid/useSelectSample.test.ts Added tests for addRange and removeRange functions in useSelectSample.
app/packages/core/src/components/Grid/useSelectSample.ts Updated logic in addRange and removeRange functions to use Records type for better clarity.
app/packages/core/src/components/Grid/useSpotlightPager.ts Modified useSpotlightPager to accept records as a parameter, updating internal logic accordingly.
app/packages/core/src/components/Modal/Sample.tsx Integrated keyboard event handling to toggle hovering state using the "c" key.
app/packages/core/src/components/Sidebar/Entries/GroupEntries.tsx Added optional dataCy property to PillEntry type for improved accessibility and testing.
app/packages/core/src/plugins/SchemaIO/components/TabsView.tsx Introduced useKey hook for managing user interaction state in tab changes.
app/packages/relay/src/fragments/sidebarGroupsFragment.ts Changed queried field from name to datasetId in sidebarGroupsFragment.
app/packages/state/src/hooks/useSetModalState.ts Updated modal state management to include sidebar expanded state checks.
tests/unittests/group_tests.py Added test_match_expr method to validate grouping datasets based on expressions.
tests/unittests/panels/panel_tests.py Enhanced test coverage for PanelRef class, adding tests for set_state and set_data methods.
fiftyone/core/stages.py Modified _make_flat_pipeline to wrap match_expr in $expr for aggregation expression handling.
fiftyone/server/routes/tag.py Simplified filter handling in post method of TagRoute, removing previous filter parameters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ModalSidebarPom
    participant Grid
    participant Records

    User->>ModalSidebarPom: Interact with sidebar
    ModalSidebarPom->>Grid: Apply filters
    Grid->>Records: Update records based on filters
    Records-->>Grid: Return updated records
    Grid-->>User: Display updated grid
Loading

🐰 "In the meadow, changes bloom,
With buttons and grids, we make room.
New tests hop in, all bright and spry,
As we dance through code, oh my, oh my!
With each little tweak, our joy will grow,
In this coding world, let the magic flow!" 🌼


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.

@findtopher findtopher requested a review from a team September 6, 2024 14:09
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: 5

Outside diff range, codebase verification and nitpick comments (2)
e2e-pw/src/oss/poms/modal/modal-sidebar.ts (1)

16-21: Approve the implementation of applyFilter.

The applyFilter method correctly uses the locator to interact with the UI elements based on the provided label. The use of force: true in the click method is noted, which might be necessary for elements that are not easily interactable due to styling or visibility issues.

Consider adding a comment in the code to explain the use of force: true to aid future maintainers or testers in understanding the choice.

docs/source/release-notes.rst (1)

Line range hint 1-1: Reminder: Add tests.

The TODO comment indicates that tests are missing.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 868e339 and 5d0226e.

Files ignored due to path filters (5)
  • app/packages/app/src/pages/datasets/__generated__/DatasetPageQuery.graphql.ts is excluded by !**/__generated__/**
  • app/packages/relay/src/fragments/__generated__/sidebarGroupsFragment.graphql.ts is excluded by !**/__generated__/**
  • app/packages/relay/src/queries/__generated__/datasetQuery.graphql.ts is excluded by !**/__generated__/**
  • e2e-pw/src/oss/specs/smoke-tests/tagger.spec.ts-snapshots/labels-chromium-darwin.png is excluded by !**/*.png, !**/*.png
  • e2e-pw/src/oss/specs/smoke-tests/tagger.spec.ts-snapshots/labels-chromium-linux.png is excluded by !**/*.png, !**/*.png
Files selected for processing (31)
  • app/packages/components/src/components/PillButton/PillButton.tsx (1 hunks)
  • app/packages/core/src/components/Grid/Grid.tsx (5 hunks)
  • app/packages/core/src/components/Grid/useRecords.test.ts (1 hunks)
  • app/packages/core/src/components/Grid/useRecords.ts (1 hunks)
  • app/packages/core/src/components/Grid/useSelect.ts (1 hunks)
  • app/packages/core/src/components/Grid/useSelectSample.test.ts (1 hunks)
  • app/packages/core/src/components/Grid/useSelectSample.ts (4 hunks)
  • app/packages/core/src/components/Grid/useSpotlightPager.ts (5 hunks)
  • app/packages/core/src/components/Modal/Sample.tsx (2 hunks)
  • app/packages/core/src/components/Sidebar/Entries/GroupEntries.tsx (3 hunks)
  • app/packages/core/src/plugins/SchemaIO/components/TabsView.tsx (2 hunks)
  • app/packages/relay/src/fragments/sidebarGroupsFragment.ts (1 hunks)
  • app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts (2 hunks)
  • app/packages/state/src/hooks/useSetModalState.ts (2 hunks)
  • app/packages/state/src/recoil/pathFilters/index.test.ts (1 hunks)
  • app/packages/state/src/recoil/pathFilters/index.ts (5 hunks)
  • app/packages/state/src/recoil/sidebar.ts (2 hunks)
  • app/packages/state/src/recoil/sidebarExpanded.ts (2 hunks)
  • docs/source/plugins/developing_plugins.rst (1 hunks)
  • docs/source/release-notes.rst (1 hunks)
  • e2e-pw/src/oss/poms/modal/modal-sidebar.ts (2 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1 hunks)
  • e2e-pw/src/oss/specs/smoke-tests/tagger.spec.ts (7 hunks)
  • fiftyone/core/stages.py (1 hunks)
  • fiftyone/operators/delegated.py (1 hunks)
  • fiftyone/operators/panel.py (2 hunks)
  • fiftyone/server/routes/tag.py (1 hunks)
  • fiftyone/utils/ultralytics.py (1 hunks)
  • fiftyone/utils/yolo.py (1 hunks)
  • tests/unittests/group_tests.py (1 hunks)
  • tests/unittests/panels/panel_tests.py (3 hunks)
Files skipped from review due to trivial changes (3)
  • app/packages/components/src/components/PillButton/PillButton.tsx
  • app/packages/core/src/components/Grid/useSelect.ts
  • docs/source/plugins/developing_plugins.rst
Additional context used
Path-based instructions (19)
app/packages/core/src/components/Grid/useRecords.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/relay/src/fragments/sidebarGroupsFragment.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/Grid/useRecords.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/Grid/useSelectSample.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/state/src/recoil/pathFilters/index.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/state/src/recoil/sidebarExpanded.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/plugins/SchemaIO/components/TabsView.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/Modal/Sample.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.

e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.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/hooks/useSetModalState.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.

e2e-pw/src/oss/poms/modal/modal-sidebar.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/Grid/useSelectSample.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/Grid/useSpotlightPager.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.

e2e-pw/src/oss/specs/smoke-tests/tagger.spec.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/Grid/Grid.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/relay/src/graphQLSyncFragmentAtomFamily.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/pathFilters/index.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/GroupEntries.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/sidebar.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 (60)
app/packages/relay/src/fragments/sidebarGroupsFragment.ts (1)

5-5: Verify the handling of datasetId across the application.

The change from name to datasetId in the GraphQL fragment could significantly impact how data is processed and displayed in the application. Ensure that all components and functionalities that rely on this fragment are updated to accommodate the new field.

Run the following script to verify the handling of datasetId across the application:

app/packages/core/src/components/Grid/useRecords.test.ts (1)

5-23: Well-structured tests for useRecords hook.

The tests are comprehensive and effectively check the hook's behavior when the clear string changes. The use of renderHook and rerender is appropriate and follows best practices for testing React hooks.

app/packages/core/src/components/Grid/useSelectSample.test.ts (1)

4-29: Comprehensive and well-structured tests for range operations.

The tests for addRange and removeRange functions are well-structured and seem to cover the basic scenarios effectively. Using Set and Map is appropriate for the operations being tested. It's good practice to include tests for edge cases, such as adding or removing empty ranges or handling non-existent elements in the collections.

app/packages/state/src/recoil/pathFilters/index.test.ts (1)

10-26: Effective testing of keypoint filters with clear differentiation of behavior.

The tests effectively differentiate the behavior of the keypointFilter based on the field type, which is crucial for ensuring that the filter logic is robust and behaves as expected across different scenarios. Using constants for field types helps avoid errors and improves maintainability. Consider adding tests for more complex scenarios or invalid inputs to further ensure the filter's robustness.

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

8-8: Key renaming in Recoil state management entities enhances clarity.

The changes to the keys of sidebarExpandedStore and sidebarExpanded improve semantic clarity and help prevent potential naming conflicts. It's important to verify that these changes are consistently applied across the entire application to avoid issues with state management. Consider using a global search or refactoring tool to ensure all references to these keys are updated.

Run the following script to verify the consistent application of the new keys:

Also applies to: 22-22

Verification successful

Key renaming in Recoil state management entities is consistently applied.

The keys sidebarExpandedStore and sidebarExpanded have been consistently updated across the application, as evidenced by their presence in various files related to state management and components. This confirms that the renaming has been correctly implemented without leaving any outdated references.

  • Files where the keys are used include filters.ts, sidebarExpanded.ts, useSetModalState.ts, index.ts, lightning.ts, and several component files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new keys are consistently used across the application.

# Test: Search for the old and new keys. Expect: Only occurrences of the new keys.
rg --type typescript -A 5 $'sidebarExpandedStore|sidebarExpanded'

Length of output: 101


Script:

#!/bin/bash
# Description: Verify that the new keys are consistently used across the application.

# Test: Search for the old and new keys. Expect: Only occurrences of the new keys.
rg --type ts -A 5 $'sidebarExpandedStore|sidebarExpanded'

Length of output: 7923

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

7-7: Correct use of useKey hook.

The import and usage of the useKey hook are correctly implemented to manage user interaction states effectively.

Also applies to: 14-14


35-38: Enhanced user interaction handling in TabsView.

The modifications to the onChange handler to include setUserChanged enhance the responsiveness of the component to user actions. This is a good practice for state management in interactive components.

app/packages/core/src/components/Modal/Sample.tsx (1)

8-8: Proper integration of useKeyDown for enhanced keyboard interaction.

The import and usage of the useKeyDown hook within the SampleWrapper component are correctly implemented to handle keyboard events, enhancing the component's interactivity and accessibility.

Also applies to: 29-32

e2e-pw/src/oss/specs/smoke-tests/quickstart.spec.ts (1)

89-94: Well-implemented test case for sidebar persistence.

The new test case "sidebar persistence" is well-structured and effectively verifies the sidebar's state after interactions, ensuring robustness in the testing framework.

fiftyone/server/routes/tag.py (1)

72-80: Review the changes in filter handling and modal response logic.

The method now uses an empty dictionary for filters, which could potentially ignore user-specified filters and affect the functionality. Ensure that this change aligns with the intended behavior and does not inadvertently filter out necessary data.

Additionally, the handling of the modal flag to determine the response format needs careful review to ensure it meets the user interface expectations.

Consider adding comments or documentation to clarify the reasons behind these changes and their expected impact on the application.

app/packages/state/src/hooks/useSetModalState.ts (2)

13-13: Approve the new import for sidebar state management.

The import of sidebarExpandedAtoms is correctly placed and used within the function to enhance the sidebar's dynamic state management. This addition aligns with the described enhancements in the PR summary.


66-68: Approve the updated logic for managing the sidebar's expanded state.

The addition of conditions for managing the sidebar's expanded state at lines 66-68 enhances the dynamic interactions within the user interface. This update appears to integrate well with the existing state management logic.

Consider adding unit tests to ensure that these new conditions integrate seamlessly with the existing functionality and do not introduce regressions.

e2e-pw/src/oss/poms/modal/modal-sidebar.ts (4)

23-27: Approve the implementation of applySearch.

The applySearch method is well-implemented, correctly simulating a search operation by filling the input and pressing the "Enter" key. This method aligns with user expectations for search interactions within the sidebar.


29-31: Approve the implementation of clearGroupFilters.

The clearGroupFilters method is efficiently implemented, using the locator to interact with the clear filters button for a specific group. This functionality is essential for allowing users to reset filters easily within the sidebar.


33-37: Approve the implementation of clickFieldDropdown.

The clickFieldDropdown method is well-implemented, using the locator to interact with the dropdown arrow for specified fields. This method enhances the interactivity of the sidebar by allowing users to access additional options or settings related to different fields.


74-76: Approve the implementation of toggleLabelCheckbox.

The toggleLabelCheckbox method is efficiently implemented, allowing for quick toggling of checkboxes for specified fields. This functionality is crucial for testing different configurations rapidly within the sidebar.

app/packages/core/src/components/Grid/useSelectSample.ts (4)

1-9: Review of Imports and Initial Setup

The imports and initial setup look appropriate for the functionality described. The use of Recoil for state management and the structured import of types and utilities suggest a well-organized approach to state handling and component interaction.


44-53: Utility Function get for Record Retrieval

The get function provides a robust way to retrieve record indices with added error handling. This is a significant improvement in terms of code reliability and maintainability. Throwing an error when a record is not found (line 52) ensures that the function's consumers handle missing data proactively.


Line range hint 55-99: Refined Logic in removeRange Function

The removeRange function mirrors the enhancements seen in addRange, with improved clarity and error handling. The logic to determine the range of indices to remove is well thought out, especially the handling of edge cases where the index might be at the start or end of the range.

The loop for adding back items not present in the index records (lines 93-97) is a good safeguard against data inconsistency.


Line range hint 102-143: Modular Default Export Function

The default export function now accepts records as a parameter, enhancing its modularity and reusability. The use of Recoil callbacks and the structured handling of selection logic based on user interactions (shift key usage, sample selection/deselection) are well-implemented.

The integration of addRange and removeRange within user interaction handling (lines 121-124) demonstrates a good understanding of functional programming and state management in React applications.

app/packages/core/src/components/Grid/useSpotlightPager.ts (2)

Line range hint 17-60: Updated Function Signature and Logic in useSpotlightPager

The introduction of the records parameter in the useSpotlightPager function (line 59) is a significant change that enhances the function's ability to interact with external state. This change allows for more flexible and maintainable code by decoupling the pager logic from the internal state management previously handled with useRef.

The use of records directly in the function body (line 97) to process pagination data ensures that the function can adapt to changes in the external state more dynamically.


Line range hint 70-128: Refactoring and Error Handling Enhancements

The refactoring to use a keys useRef for managing record invalidation keys (line 70) is a thoughtful addition that separates concerns more clearly than before. The handling of asynchronous operations within the useRecoilCallback (lines 70-99) is robust, with proper error handling and subscription management.

The cleanup logic in the useEffect hook (lines 124-128) ensures that the component cleans up after itself, preventing potential memory leaks and ensuring that the UI remains consistent with the underlying data state.

e2e-pw/src/oss/specs/smoke-tests/tagger.spec.ts (2)

4-26: Integration of ModalPom and Refactoring of Test Setup

The introduction of ModalPom (line 12) and the restructuring of the test setup to accommodate this change are significant improvements. The removal of gridActionsRow and its integration into the grid object streamline the test context and reduce redundancy.

The asynchronous setup functions for grid, modal, sidebar, and tagger (lines 16-26) are well-structured, ensuring that each component is properly initialized before tests run.


Line range hint 42-129: Updated Test Cases Reflecting New Modal Functionalities

The test cases have been updated to reflect the integration of the ModalPom. The new test case "In modal, I can add a label tag to a filtered sample" (lines 102-129) is a valuable addition that expands the test coverage to include modal interactions.

The use of promises to handle asynchronous events (lines 113-118) and the clear structuring of actions and expectations within each test case ensure that the tests are both readable and maintainable.

app/packages/core/src/components/Grid/Grid.tsx (2)

4-6: Approved: Import Reorganization

The reorganization of imports enhances clarity and maintainability without affecting functionality.


78-78: Verify: Updated selectSample.current Function Call

The update to the selectSample.current function call now passing only the detail parameter simplifies the logic. Verify that this change aligns with the intended behavior and that all dependent functionalities are updated accordingly.

app/packages/relay/src/graphQLSyncFragmentAtomFamily.ts (1)

59-60: Approved: Comment Reformatting and Enhanced Property Access

The reformatting of comments improves readability and maintainability. The introduction of optional chaining (fragmentOptions?.keys[i]) enhances the robustness of the code by safely accessing properties, which is a best practice in handling potential null or undefined values.

Also applies to: 97-97

app/packages/state/src/recoil/pathFilters/index.ts (1)

9-10: Approved: Introduction of Keypoint Handling Enhancements

The introduction of new constants (KEYPOINT_FIELD, KEYPOINTS_FIELD) and the keypointFilter function significantly enhances the filtering capabilities of the module. These changes are well-implemented and improve the clarity and functionality of the filtering process.

Also applies to: 35-35, 172-188

tests/unittests/panels/panel_tests.py (7)

186-192: Test for setting state with a dictionary is correctly implemented.

The test verifies both the state update and the method call, ensuring the functionality behaves as expected.


195-201: Test for setting state with a nested key path is correctly implemented.

The test ensures that nested paths are correctly updated and the corresponding method call is verified, which is crucial for ensuring the robustness of state management.


204-210: Test for setting state with a nested key path using a dictionary is correctly implemented.

This test verifies the correct handling of nested paths using a dictionary format, ensuring that the state management is robust and handles complex scenarios effectively.


213-217: Test for enforcing the write-only property on data attribute is correctly implemented.

This test correctly checks that accessing the data attribute raises a WriteOnlyError, which is essential for maintaining the integrity of the write-only property.


234-240: Test for setting data with a dictionary is correctly implemented.

This test verifies that data can be correctly updated using a dictionary, and it checks that the appropriate method call is made, ensuring the functionality behaves as expected.


243-249: Test for setting data with a nested key path is correctly implemented.

This test ensures that nested paths in data are correctly updated and the corresponding method call is verified, which is crucial for ensuring the robustness of data management.


252-258: Test for setting data with a nested key path using a dictionary is correctly implemented.

This test verifies the correct handling of nested paths using a dictionary format, ensuring that the data management is robust and handles complex scenarios effectively.

fiftyone/operators/delegated.py (1)

408-409: Improved Error Handling: Conditional Check on outputs

The addition of a conditional check before invoking to_json() on outputs enhances the robustness of the _execute_operator method by preventing potential AttributeError exceptions. This is a good practice for handling None values in Python.

fiftyone/utils/ultralytics.py (1)

61-61: Code Simplification and Correction in _extract_track_ids

The modification to use result.boxes.conf.size(0) directly for generating a list of None values simplifies the code and corrects the logic. This change enhances clarity and ensures the correct size is used for the list.

app/packages/state/src/recoil/sidebar.ts (2)

217-217: Refined Expansion Logic in resolveGroups

The update to check explicitly for a boolean value in the expanded object enhances the robustness of the group expansion logic. This prevents unintended behavior from non-boolean truthy or falsy values, aligning with best practices for type safety in JavaScript.


319-366: Streamlined Export Structure in sidebarGroupsDefinition

The simplification of the sidebarGroupsDefinition export by directly returning the graphQLSyncFragmentAtomFamily function and refining the data comparison logic in the read function enhances clarity and correctness. The focus on dataset ID for state updates is a more reliable approach than using names, which improves the robustness of data handling.

docs/source/release-notes.rst (1)

3-4: LGTM!

The code changes are approved.

fiftyone/core/stages.py (15)

Line range hint 1-1: Class Concat Review:

The Concat class is implemented correctly and uses appropriate MongoDB operations to merge collections. The validation logic in validate is robust, ensuring that only compatible collections are concatenated.


Line range hint 1-1: Class Exclude Review:

The Exclude class is implemented correctly and uses appropriate MongoDB operations to exclude samples based on IDs. The validation logic in validate ensures that only valid IDs are used for exclusion.


Line range hint 1-1: Class ExcludeBy Review:

The ExcludeBy class is implemented correctly and uses appropriate MongoDB operations to exclude samples based on field values. The validation logic in validate ensures that the field exists in the dataset before exclusion.


Line range hint 1-1: Class ExcludeFields Review:

The ExcludeFields class is implemented correctly and uses appropriate MongoDB operations to exclude specified fields from samples. The validation logic in validate ensures that the fields exist in the dataset before exclusion.


Line range hint 1-1: Class ExcludeFrames Review:

The ExcludeFrames class is implemented correctly and uses appropriate MongoDB operations to exclude specified frames from video samples. The validation logic in validate ensures that the collection contains videos before exclusion.


Line range hint 1-1: Class ExcludeGroups Review:

The ExcludeGroups class is implemented correctly and uses appropriate MongoDB operations to exclude specified groups from samples. The validation logic in validate ensures that the collection contains groups before exclusion.


Line range hint 1-1: Class ExcludeLabels Review:

The ExcludeLabels class is implemented correctly and uses appropriate MongoDB operations to exclude specified labels from samples based on multiple criteria. The validation logic in validate ensures that the labels exist in the dataset before exclusion.


Line range hint 1-1: Class Exists Review:

The Exists class is implemented correctly and uses appropriate MongoDB operations to filter samples based on the existence of a specified field. The validation logic in validate ensures that the field exists in the dataset before filtering.


Line range hint 1-1: Class FilterField Review:

The FilterField class is implemented correctly and uses appropriate MongoDB operations to filter the values of a specified field in samples based on multiple criteria. The validation logic in validate ensures that the field exists in the dataset before filtering.


Line range hint 1-1: Class FilterLabels Review:

The FilterLabels class is implemented correctly and uses appropriate MongoDB operations to filter labels in a specified field of samples based on multiple criteria. The validation logic in validate ensures that the field exists in the dataset before filtering.


Line range hint 1-1: Class FilterKeypoints Review:

The FilterKeypoints class is implemented correctly and uses appropriate MongoDB operations to filter keypoints in a specified field of samples based on multiple criteria. The validation logic in validate ensures that the field exists in the dataset before filtering.


Line range hint 1-1: Class Flatten Review:

The Flatten class is implemented correctly and uses appropriate MongoDB operations to flatten a dynamically grouped collection into a non-grouped collection. The validation logic in validate ensures that the collection is dynamically grouped before flattening.


Line range hint 1-1: Class GeoNear Review:

The GeoNear class is implemented correctly and uses appropriate MongoDB operations to sort samples based on their proximity to a specified geolocation. The validation logic in validate ensures that the location field is specified and creates a 2dsphere index if necessary.


Line range hint 1-1: Class GeoWithin Review:

The GeoWithin class is implemented correctly and uses appropriate MongoDB operations to filter samples based on whether their geolocation falls within a specified boundary. The validation logic in validate ensures that the location field is specified and creates a 2dsphere index if necessary.


Line range hint 1-1: Class GroupBy Review:

The GroupBy class is implemented correctly and uses appropriate MongoDB operations to group samples based on a specified field or expression. The validation logic in validate ensures that the collection is not already dynamically grouped before grouping.

fiftyone/operators/panel.py (2)

249-250: Simplified data setting in PanelRefData.

The changes to directly use super().set(d) and self._ctx.ops.patch_panel_data(d) are approved as they simplify the code and potentially enhance performance. Ensure that these changes integrate seamlessly with the superclass's set method and the patch_panel_data method.

Run the following script to verify the integration:

Verification successful

Integration of super().set(d) in PanelRefData is correct.

The super().set(d) call in PanelRefData correctly invokes the set method from its superclass PanelRefBase, ensuring proper integration. The usage of patch_panel_data is confirmed, but its implementation details are not fully visible. Consider manually verifying the patch_panel_data method if further assurance is needed.

  • PanelRefData correctly inherits and overrides the set method from PanelRefBase.
  • patch_panel_data is used in PanelRefData, but further details are not visible.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of the `set` method with the superclass and `patch_panel_data`.

# Test: Search for the superclass `set` method and `patch_panel_data` method usage. Expect: Proper handling of the dictionary `d`.
rg --type python -A 5 $'super().set' fiftyone/operators/panel.py
rg --type python -A 5 $'patch_panel_data' fiftyone/operators/panel.py

Length of output: 196


Script:

#!/bin/bash
# Description: Verify the integration of the `set` method with the superclass and `patch_panel_data`.

# Test: Search for the superclass `set` method and `patch_panel_data` method usage. Expect: Proper handling of the dictionary `d`.
rg --type py -A 5 $'super().set' fiftyone/operators/panel.py
rg --type py -A 5 $'patch_panel_data' fiftyone/operators/panel.py

Length of output: 286


Script:

#!/bin/bash
# Description: Verify the class hierarchy and the usage of the `set` method in the superclass.

# Search for the class definition containing the `set` method.
rg --type py 'class ' fiftyone/operators/panel.py -A 10

# Search for the `set` method definition in the superclass.
rg --type py 'def set' fiftyone/operators/panel.py -A 5

Length of output: 3271


215-216: Simplified state setting in PanelRefState.

The changes to directly use super().set(d) and self._ctx.ops.patch_panel_state(d) are approved as they simplify the code and potentially enhance performance. However, ensure that these changes integrate seamlessly with the superclass's set method and the patch_panel_state method.

Run the following script to verify the integration:

app/packages/core/src/components/Sidebar/Entries/GroupEntries.tsx (3)

35-36: Enhanced testability with dataCy property in PillEntry.

The addition of the optional dataCy property to the PillEntry type is approved as it enhances testability and accessibility by providing a unique identifier for each pill entry.


47-52: Improved flexibility and testability in Pills component.

The update to destructure and use the dataCy property in the Pills component is approved. This change enhances the component's flexibility and usability in testing scenarios by allowing dataCy to be passed as a prop to the PillButton component.


311-332: Enhanced clarity and specificity with dataCy usage in PathGroupEntry.

The specific assignment of dataCy values based on the context in the PathGroupEntry component is approved. This modification improves the clarity and specificity of the identifiers used for testing and interaction tracking, enhancing the overall maintainability of the code.

Comment on lines +5 to +9
export default (clear: string) => {
return useMemo(() => {
clear;
return new Map<string, number>();
}, [clear]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify the usage of the clear parameter in useMemo.

The clear parameter is included in the dependency array but does not seem to affect the memoized value directly. This could potentially lead to bugs or confusion about the hook's behavior. Consider either using the clear parameter to affect the state or clarify its purpose if it's intended to trigger re-computation without directly influencing the result.

Comment on lines +18 to +38
export const addRange = (
index: number,
selected: Set<string>,
records: Records
) => {
// filter selections without an index record
const items = [...selected].filter((i) => records.has(i));
const reverse = Object.fromEntries(
Array.from(records.current.entries()).map(([k, v]) => [v, k])
);

const min = argMin(
items.map((id) => Math.abs(records.current.get(id) - index))
Array.from(records.entries()).map(([k, v]) => [v, k])
);
const min = argMin(items.map((id) => Math.abs(get(records, id) - index)));

const close = records.current.get(items[min]);
const close = get(records, items[min]);

const [start, end] = index < close ? [index, close] : [close, index];

const added = new Array(end - start + 1)
.fill(0)
.map((_, i) => reverse[i + start]);

return new Set([...items, ...added]);
return new Set([...selected, ...added]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Enhanced Logic in addRange Function

The addRange function has been refactored to use the new Records type, which simplifies the handling of record indices. The use of a filtering mechanism to ensure only valid records are processed is a robust approach to error handling. The logic for determining the closest record index and the range of indices to add is clear and well-implemented.

However, the creation of the reverse map (line 26) could potentially be optimized or clarified to ensure its purpose and usage are immediately apparent to future maintainers of this code.

Consider adding a comment explaining the purpose of the reverse map or explore alternative ways to achieve the same functionality with potentially more readable code.

pageSelector: pageParameters,
zoomSelector: gridCrop,
});
const records = useRecords(pageReset);
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor: Introduction of useRecords Hook

The introduction of the useRecords hook to manage the records state is a positive change, enhancing the modularity and reusability of the component. Ensure that the pageReset parameter is correctly handled within the hook to avoid potential issues with state management.

Also applies to: 104-104

Comment on lines +509 to +524
split_info = d[self.split]
if isinstance(split_info, str):
split_info = [split_info]
data_paths = [
fos.normpath(os.path.join(dataset_path, si)) for si in split_info
]
classes = _parse_yolo_classes(d.get("names", None))

if etau.is_str(data) and data.endswith(".txt"):
txt_path = _parse_yolo_v5_path(data, self.yaml_path)
image_paths = [
_parse_yolo_v5_path(fos.normpath(p), txt_path)
for p in _read_file_lines(txt_path)
]
else:
if etau.is_str(data):
data_dirs = [data]
image_paths = []
for data_path in data_paths:
if etau.is_str(data_path) and data_path.endswith(".txt"):
txt_path = _parse_yolo_v5_path(data_path, self.yaml_path)
image_paths.extend(
_parse_yolo_v5_path(fos.normpath(p), txt_path)
for p in _read_file_lines(txt_path)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Review: Handling of multiple dataset paths in YOLOv5DatasetImporter.setup method.

The modifications in the setup method of the YOLOv5DatasetImporter class enhance its flexibility by allowing it to handle multiple dataset paths. This is achieved by checking if split_info is a string and converting it to a list if necessary, which is then used to construct normalized paths for each dataset split. This approach is beneficial as it supports configurations where the dataset might be split across multiple directories or files, improving the method's usability in diverse scenarios.

However, there are a few considerations and potential improvements:

  1. Error Handling: The method assumes that the paths provided in split_info are valid and that files exist at those paths. It would be prudent to add checks to ensure that the files/directories indeed exist before proceeding with their processing to avoid runtime errors.
  2. Logging: Adding logging at key steps, especially before and after significant operations like file reading, could help in debugging and understanding the flow of data, especially in error scenarios.
  3. Performance Considerations: If the list of paths is large, the current implementation might become inefficient. Consider parallelizing the reading and processing of paths if performance becomes a bottleneck.

Overall, the changes are a solid improvement, making the method more adaptable to different dataset configurations.

Comment on lines +1981 to +1989
@drop_datasets
def test_match_expr(self):
dataset = _make_group_by_dataset()

view = dataset.group_by(
"frame_number", flat=True, match_expr=(F().length() > 1)
)
self.assertDictEqual(view.count_values("frame_number"), {1: 2, 2: 2})

Copy link
Contributor

Choose a reason for hiding this comment

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

Review: New test method test_match_expr in group_tests.py.

The new test method test_match_expr is designed to validate the functionality of grouping datasets based on a specified expression. The method correctly sets up a dataset, applies a grouping with a match expression that filters elements based on their length, and asserts the expected results.

Key observations:

  1. Clarity and Scope of Test: The test is clear in its intent and correctly scoped to verify the functionality it targets. It uses the group_by method with a match_expr that checks if the length of elements is greater than 1, which is a practical and useful scenario to test.
  2. Correctness of Assertions: The assertion checks the count of values for the frame_number key against the expected results, which effectively validates the behavior of the group_by method under the conditions set by the match_expr.
  3. Documentation and Comments: Adding a few comments explaining the choice of match_expr and why the expected results are {1: 2, 2: 2} would enhance the readability and maintainability of the test, making it easier for new contributors or future maintainers to understand the test's purpose at a glance.

Overall, the addition of this test method is a positive enhancement to the test suite, ensuring that the functionality of grouping by expressions is correctly handled.

Copy link
Contributor

@j053y j053y left a comment

Choose a reason for hiding this comment

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

🔩

@findtopher findtopher merged commit bd121cb into main Sep 6, 2024
16 checks passed
@findtopher findtopher deleted the release/v0.25.1 branch September 6, 2024 17:18
findtopher added a commit that referenced this pull request Sep 6, 2024
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.

8 participants