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

better group slice support for operators #4850

Merged
merged 5 commits into from
Sep 27, 2024
Merged

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented Sep 26, 2024

What changes are proposed in this pull request?

  • Add group slice in operator and python panel context and add associated events
  • Fix group slice operator to only change slice when needed

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

Using an example operator and panel

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 on_change_group_slice parameter to enhance group slice handling in the Custom Panel.
    • Added groupSlice to various contexts, improving the management of group slice data.
    • New event handler for on_change_group_slice to respond to group slice changes during startup.
  • Documentation

    • Updated documentation to reflect the new on_change_group_slice parameter in relevant functions.
  • Bug Fixes

    • Improved logic for setting group slice to ensure updates occur only when necessary.

@imanjra imanjra requested review from ritch, brimoor and a team September 26, 2024 14:22
Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The changes in this pull request introduce enhancements related to group slicing functionality across multiple components. Key modifications include the addition of new parameters and properties to various functions and classes, enabling better handling of group slice changes. These updates affect how context is managed and improve the responsiveness of the application to group slice events.

Changes

Files Change Summary
app/packages/operators/src/CustomPanel.tsx Added on_change_group_slice parameter to defineCustomPanel, allowing the component to handle group slice changes.
app/packages/operators/src/hooks.ts Introduced groupSlice variable using useRecoilValue to enhance context management. Added to dependency arrays of hooks.
app/packages/operators/src/operators.ts Added groupSlice property to RawContext type and getter method in ExecutionContext. Integrated groupSlice into several asynchronous functions.
app/packages/operators/src/state.ts Included groupSlice in globalContextSelector and useExecutionContext, ensuring it is part of the application context.
app/packages/operators/src/useCustomPanelHooks.ts Added optional onChangeGroupSlice property to CustomPanelProps interface and updated useCustomPanelHooks to utilize useCtxChangePanelEvent.
docs/source/plugins/developing_plugins.rst Added on_change_group_slice method to handle group slice changes in the panel context.
fiftyone/operators/builtin.py Modified logic in execute methods to conditionally set group slice based on context.
fiftyone/operators/executor.py Added group_slice property method to retrieve the value from request_params.
fiftyone/operators/operations.py Introduced on_change_group_slice parameter to register_panel function for handling group slice changes.
fiftyone/operators/panel.py Added on_change_group_slice event handler method to the on_startup method.

Possibly related PRs

  • add set_group_slice operator #4844: The addition of the set_group_slice operator directly relates to the changes made in the main PR, as both involve enhancements to group slice functionality within the application.
  • add reload_on_navigation for modal panels #4846: The introduction of the reload_on_navigation feature for modal panels may interact with the on_change_group_slice functionality, as both are concerned with how the application responds to changes in group slices during user navigation.
  • Fix selection for group modal #4789: The changes in the handle_group_filter function to refine group selection logic may relate to the handling of group slices, as both involve managing how groups and slices are represented and interacted with in the application.

Suggested labels

bug, app

Suggested reviewers

  • benjaminpkane
  • ritch
  • sashankaryal

Poem

In the meadow where rabbits play,
A new slice of joy has come our way.
With each hop and every twist,
Group changes now can't be missed!
So let's dance and cheer with glee,
For a brighter path, as sweet as can be! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 808260c and e38dfd0.

📒 Files selected for processing (1)
  • fiftyone/operators/builtin.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • fiftyone/operators/builtin.py

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

🧹 Outside diff range and nitpick comments (17)
app/packages/operators/src/CustomPanel.tsx (1)

117-117: LGTM! Consider adding type annotations for improved type safety.

The addition of the on_change_group_slice parameter and its corresponding prop onChangeGroupSlice is well-implemented and aligns with the PR objectives. The changes follow the existing naming conventions and code structure.

For improved type safety, consider adding type annotations to the defineCustomPanel function parameters. This would help catch potential type-related issues early and improve code maintainability. For example:

export function defineCustomPanel({
  // ... other parameters
  on_change_group_slice,
  panel_name,
  panel_label,
}: {
  // ... other parameter types
  on_change_group_slice?: (groupSlice: GroupSlice) => void,
  panel_name: string,
  panel_label: string,
}) {
  // ... function body
}

Replace GroupSlice with the actual type of the group slice data structure you're using.

Also applies to: 134-134

app/packages/operators/src/hooks.ts (2)

28-28: Consider adding a type annotation for groupSlice.

To improve code clarity and prevent potential type inference issues, consider adding an explicit type annotation for the groupSlice variable. This will make the expected type clear to other developers and help catch any type-related errors early.

- const groupSlice = useRecoilValue(fos.groupSlice);
+ const groupSlice: YourGroupSliceType = useRecoilValue(fos.groupSlice);

Replace YourGroupSliceType with the actual type of the groupSlice state.


28-28: Document the purpose and impact of groupSlice in the context.

The addition of groupSlice to the operator context is a significant change. To ensure clarity for other developers and maintain code readability, please add a comment explaining:

  1. The purpose of groupSlice in the context.
  2. How it affects the behavior of operators or other components consuming this context.
  3. Any considerations for when groupSlice changes.

Add a comment above the groupSlice declaration, for example:

// groupSlice represents the current group slice state.
// It's used by operators to adjust their behavior based on the active group slice.
// Changes to groupSlice may trigger re-evaluation of operator placements.
const groupSlice: YourGroupSliceType = useRecoilValue(fos.groupSlice);

Also applies to: 51-51, 63-63

app/packages/operators/src/useCustomPanelHooks.ts (2)

28-28: LGTM! Consider adding JSDoc comment for clarity.

The addition of the onChangeGroupSlice property to the CustomPanelProps interface is consistent with the existing pattern and naming convention. It enhances the flexibility of the custom panel by allowing it to respond to group slice changes.

Consider adding a JSDoc comment to describe the purpose and usage of this new property, for example:

/** Callback fired when the group slice changes */
onChangeGroupSlice?: string;

133-138: LGTM! Consider refactoring for improved readability.

The addition of the useCtxChangePanelEvent hook for ctx.groupSlice and props.onChangeGroupSlice is consistent with the existing pattern and enhances the functionality of the custom panel to react to group slice changes.

Consider refactoring the repeated useCtxChangePanelEvent calls into a more concise format to improve readability. For example:

const ctxChangeEvents = [
  { value: ctx._currentContext, handler: props.onChangeCtx },
  { value: ctx.view, handler: props.onChangeView },
  // ... other existing events ...
  { value: ctx.groupSlice, handler: props.onChangeGroupSlice }
];

ctxChangeEvents.forEach(({ value, handler }) => 
  useCtxChangePanelEvent(isLoaded, panelId, value, handler)
);

This refactoring would make it easier to add or modify context change events in the future.

fiftyone/operators/operations.py (2)

319-319: LGTM! Consider a minor docstring improvement.

The addition of the on_change_group_slice parameter is well-implemented and consistent with other similar parameters. It's correctly added to the method signature, docstring, and params dictionary.

Consider adding a brief explanation of what a "group slice" is in the docstring, as it might not be immediately clear to all users. For example:

-            on_change_group_slice (None): an operator to invoke when the group slice changes
+            on_change_group_slice (None): an operator to invoke when the group slice (subset of samples within a group) changes

Also applies to: 357-357, 380-380


Line range hint 638-644: LGTM! Consider adding a docstring.

The addition of the set_group_slice method is a good complement to the new on_change_group_slice parameter in register_panel. The implementation looks correct.

Consider adding a docstring to the set_group_slice method to provide more context and usage information. For example:

def set_group_slice(self, slice):
    """Set the active group slice in the App.

    This method triggers an event to update the group slice, which represents
    a subset of samples within a group.

    Args:
        slice: the group slice to activate
    """
    return self._ctx.trigger("set_group_slice", {"slice": slice})
app/packages/operators/src/state.ts (4)

Line range hint 96-107: LGTM! Consider sorting the properties alphabetically.

The addition of groupSlice to the globalContextSelector is implemented correctly and aligns with the existing pattern. This change supports the PR objective of adding group slice support.

For better readability and consistency, consider sorting the properties in the returned object alphabetically. This would make it easier to locate specific properties in the future.

 return {
   datasetName,
+  extendedSelection,
+  groupSlice,
   view,
   extended,
   filters,
   selectedSamples,
   selectedLabels,
   viewName,
-  extendedSelection,
-  groupSlice,
 };

Line range hint 1-1000: Consider adding JSDoc comments to complex functions.

To improve code readability and maintainability, consider adding JSDoc comments to complex functions throughout the file. This will help other developers understand the purpose, parameters, and return values of these functions more easily.

For example, you could add a JSDoc comment to the useOperatorExecutor function:

/**
 * Hook for executing an operator with the given URI.
 * @param {string} uri - The URI of the operator to execute.
 * @param {Object} handlers - Optional handlers for success and error cases.
 * @returns {Object} An object containing execution state and methods.
 */
export function useOperatorExecutor(uri, handlers: any = {}) {
  // ... existing implementation
}

Line range hint 1-1000: Consider breaking down long functions for better maintainability.

Some functions in this file are quite long and complex. Consider breaking them down into smaller, more focused functions to improve readability and maintainability.

For example, the useOperatorPrompt function (starting around line 330) could be split into smaller functions, each handling a specific aspect of the operator prompt logic.


Line range hint 1000-1100: Improve error handling in the execute function.

In the execute function of useOperatorExecutor, consider improving the error handling to provide more specific error messages and potentially handle different types of errors differently.

You could enhance the error handling like this:

try {
  // ... existing code ...
} catch (e) {
  callback?.(new OperatorResult(operator, null, ctx.executor, e, false));
  const isAbortError = e.name === "AbortError" || e instanceof DOMException;
  if (!isAbortError) {
    setError(e);
    setResult(null);
    handlers.onError?.(e);
    console.error("Error executing operator", operator, ctx);
    console.error(e);
    
    let errorMessage = "Failed to execute an operation";
    if (e instanceof TypeError) {
      errorMessage = "Type error occurred during operation execution";
    } else if (e instanceof RangeError) {
      errorMessage = "Range error occurred during operation execution";
    }
    // Add more specific error types as needed
    
    notify({ msg: errorMessage, variant: "error" });
  }
}

This approach provides more specific error messages based on the type of error that occurred, which can be helpful for debugging and user feedback.

app/packages/operators/src/operators.ts (3)

93-93: LGTM. Consider adding documentation for the new groupSlice property.

The addition of the groupSlice property to the RawContext type is a good enhancement for supporting group slice functionality. To improve maintainability and clarity for other developers, consider adding a brief comment explaining the purpose and expected format of this property.


136-138: LGTM. Consider specifying the return type for the groupSlice getter.

The addition of the groupSlice getter is consistent with the class structure and provides access to the new property. To improve type safety, consider specifying the return type as string instead of any:

-  public get groupSlice(): any {
+  public get groupSlice(): string {
     return this._currentContext.groupSlice;
   }

This change would align the getter's type with the RawContext type definition.


811-811: LGTM. Consider refactoring to reduce duplication in server request objects.

The addition of the group_slice property to the server requests in resolveRemoteType, resolveExecutionOptions, and fetchRemotePlacements functions is consistent and completes the integration of the group slice functionality across all relevant API calls.

To improve maintainability and reduce duplication, consider creating a helper function that constructs the common parts of these server request objects, including the group_slice property. This would centralize the logic and make future changes easier to implement across all API calls.

Example:

function createBaseServerRequest(ctx: ExecutionContext) {
  const currentContext = ctx._currentContext;
  return {
    current_sample: currentContext.currentSample,
    dataset_name: currentContext.datasetName,
    // ... other common properties ...
    group_slice: currentContext.groupSlice,
  };
}

// Usage in functions:
const serverRequest = {
  ...createBaseServerRequest(ctx),
  // Add function-specific properties here
};

This refactoring would make the code more DRY and easier to maintain.

Also applies to: 885-885, 916-916

fiftyone/operators/builtin.py (2)

1522-1523: LGTM! Consider adding a comment for clarity.

The added conditional statement correctly updates the current context's group slice when the renamed slice is active. This change aligns well with the PR objectives of enhancing group slice support.

Consider adding a brief comment explaining the purpose of this condition for better code readability:

 if ctx.group_slice == name:
+    # Update current context if the renamed slice was active
     ctx.ops.set_group_slice(ctx.dataset.default_group_slice)

1570-1571: LGTM! Consider adding a comment for consistency.

The added conditional statement correctly updates the current context's group slice when the deleted slice is active. This change is consistent with the implementation in the RenameGroupSlice class and aligns well with the PR objectives.

For consistency with the suggested change in the RenameGroupSlice class, consider adding a brief comment explaining the purpose of this condition:

 if ctx.group_slice == name:
+    # Update current context if the deleted slice was active
     ctx.ops.set_group_slice(ctx.dataset.default_group_slice)
docs/source/plugins/developing_plugins.rst (1)

2050-2062: Ensure consistency with other on_change methods

The new on_change_group_slice method follows a similar structure to other on_change methods in this section, which is good for consistency. However, to fully align with the existing pattern:

  1. Consider adding a code example within the method docstring, similar to other methods like on_change_dataset and on_change_view.
  2. The indentation of the method body (lines 2057-2062) appears to be one level too deep compared to other methods. Adjust the indentation to match the surrounding code.

These small adjustments will ensure the new method seamlessly integrates with the existing documentation style.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0db69e2 and 60de364.

📒 Files selected for processing (10)
  • app/packages/operators/src/CustomPanel.tsx (2 hunks)
  • app/packages/operators/src/hooks.ts (3 hunks)
  • app/packages/operators/src/operators.ts (7 hunks)
  • app/packages/operators/src/state.ts (5 hunks)
  • app/packages/operators/src/useCustomPanelHooks.ts (2 hunks)
  • docs/source/plugins/developing_plugins.rst (1 hunks)
  • fiftyone/operators/builtin.py (2 hunks)
  • fiftyone/operators/executor.py (1 hunks)
  • fiftyone/operators/operations.py (3 hunks)
  • fiftyone/operators/panel.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
app/packages/operators/src/CustomPanel.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/operators/src/hooks.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/operators/src/operators.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/operators/src/state.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/operators/src/useCustomPanelHooks.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 (9)
app/packages/operators/src/hooks.ts (1)

28-28: LGTM! Note on potential performance impact.

The addition of groupSlice to the context and dependency array looks good and aligns with the PR objectives. However, be aware that this change might increase the frequency of context updates if groupSlice changes often. Monitor the performance impact, especially if groupSlice updates frequently or if the context is used by many components.

To help assess the potential impact, you can run the following script to check how often groupSlice is used or updated in the codebase:

Also applies to: 51-51, 63-63

✅ Verification successful

Performance Impact Monitoring Recommended

The verification confirms that groupSlice is referenced in multiple files across the codebase. While the number of potential update locations is limited, it's advisable to monitor the application's performance to ensure that adding groupSlice to the context and dependency array does not lead to excessive context updates or re-renders.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage and updates of groupSlice in the codebase

echo "Files referencing groupSlice:"
rg --type typescript --type tsx "groupSlice" -l

echo "\nPotential update locations for groupSlice:"
rg --type typescript --type tsx "set.*groupSlice|groupSlice.*set" -n

Length of output: 356


Script:

#!/bin/bash
# Description: Check usage and updates of groupSlice in the codebase using file extensions

echo "Files referencing groupSlice:"
rg "groupSlice" --glob "*.ts" --glob "*.tsx" -l

echo "\nPotential update locations for groupSlice:"
rg "set.*groupSlice|groupSlice.*set" --glob "*.ts" --glob "*.tsx" -n

Length of output: 15657

app/packages/operators/src/useCustomPanelHooks.ts (1)

28-28: Overall impact: Enhances group slice support as intended.

The changes successfully implement group slice support in custom panels, aligning with the PR objectives. The modifications are consistent with existing patterns and are well-integrated into the codebase.

To ensure proper adoption of this new feature:

  1. Update any relevant documentation to include information about the new onChangeGroupSlice property and its usage.
  2. Consider adding or updating examples that demonstrate how to use the group slice functionality in custom panels.
  3. Ensure that any related components or hooks that might interact with custom panels are aware of this new capability.

To verify the impact and usage of the new group slice functionality, you can run the following script:

This will help identify any existing usage and potential places where the new functionality could be applied.

Also applies to: 133-138

✅ Verification successful

Confirmation: onChangeGroupSlice usage detected and correctly implemented.

The onChangeGroupSlice property is properly defined in useCustomPanelHooks.ts and utilized within CustomPanel.tsx, ensuring that group slice support is effectively integrated as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of onChangeGroupSlice in the codebase
echo "Searching for onChangeGroupSlice usage:"
rg --type typescript --type typescript "onChangeGroupSlice" -C 3

# Search for potential places where group slice functionality might be relevant
echo "\nSearching for potential places to use group slice functionality:"
rg --type typescript --type typescript "groupSlice" -C 3

Length of output: 423


Script:

#!/bin/bash
# Search for usage of onChangeGroupSlice in TypeScript files
echo "Searching for onChangeGroupSlice usage in .ts and .tsx files:"
rg "onChangeGroupSlice" -g "*.ts" -g "*.tsx" -C 3

# Search for potential places where group slice functionality might be relevant in TypeScript files
echo -e "\nSearching for potential places to use group slice functionality in .ts and .tsx files:"
rg "groupSlice" -g "*.ts" -g "*.tsx" -C 3

Length of output: 63624

fiftyone/operators/operations.py (1)

Line range hint 1-644: Summary: Group slice support well-implemented

The changes to add group slice support in the Operations class have been implemented correctly and consistently. The new on_change_group_slice parameter in the register_panel method and the set_group_slice method work together to provide this functionality.

These changes align well with the PR objectives of enhancing group slice functionality within the FiftyOne application. The implementation is consistent with existing patterns in the code, making it easy to understand and maintain.

To further improve the code:

  1. Consider adding brief explanations of "group slice" in the docstrings to enhance clarity for users.
  2. Add a docstring to the new set_group_slice method to provide usage information.

These minor documentation improvements will help users better understand and utilize the new group slice features.

app/packages/operators/src/state.ts (1)

Line range hint 147-179: LGTM! Changes are consistent and follow best practices.

The addition of groupSlice to the useExecutionContext hook is implemented correctly. The changes are consistent with the addition to the global context, and follow React best practices by including groupSlice in the dependency array of the useMemo hook.

app/packages/operators/src/operators.ts (2)

545-545: LGTM. The group_slice property is correctly included in the server request.

The addition of the group_slice property to the server request in the executeOperatorAsGenerator function is consistent with the earlier changes and ensures that the group slice information is properly communicated to the server.


708-708: LGTM. The group_slice property is correctly included in the server request.

The addition of the group_slice property to the server request in the executeOperatorWithContext function is consistent with the earlier changes and ensures that the group slice information is properly communicated to the server for context-based operator execution.

fiftyone/operators/executor.py (1)

700-703: LGTM with minor suggestions.

The new group_slice property is a good addition to the ExecutionContext class. It provides a convenient way to access the group slice information. Here are a few suggestions for improvement:

  1. Consider expanding the docstring to provide more context about what a "group slice" represents and its potential values.
  2. You might want to add type hinting for the return value to improve code readability and IDE support.

Example with improvements:

@property
def group_slice(self) -> Optional[Any]:
    """
    The group slice of the view.
    
    Returns:
        The group slice value if present in the request parameters, otherwise None.
        The type of the group slice depends on how it's set in the request.
    """
    return self.request_params.get("group_slice", None)
fiftyone/operators/builtin.py (1)

1522-1523: Overall, the changes improve group slice handling.

The modifications in both the RenameGroupSlice and DeleteGroupSlice classes enhance the handling of group slices by ensuring that the current context is updated when an active slice is renamed or deleted. These changes align well with the PR objectives of improving group slice support and contribute to a more robust implementation.

Also applies to: 1570-1571

docs/source/plugins/developing_plugins.rst (1)

2050-2062: New method on_change_group_slice added to Panel interface

The new on_change_group_slice method has been added to handle changes in the current group slice. This addition enhances the Panel interface by providing a way to respond to group slice changes.

A few suggestions to improve the documentation:

  1. Consider adding a brief explanation of what a "group slice" is, as it might not be immediately clear to all users.
  2. It would be helpful to provide an example of how this method might be used in practice.
  3. Ensure that this new method is mentioned in the overview or summary of Panel methods, if such a section exists in this document.

fiftyone/operators/panel.py Show resolved Hide resolved
fiftyone/operators/executor.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
fiftyone/operators/executor.py (1)

511-536: LGTM! Consider adding type hints and docstring.

The addition of the group_slice property and the related changes in the dataset property are well-implemented. They enhance the functionality by properly handling group slices for grouped media.

Consider adding type hints and a docstring to the group_slice property for better code clarity:

    @property
-   def group_slice(self):
+   def group_slice(self) -> Optional[str]:
+       """
+       The current group slice of the view (if any).
+
+       Returns:
+           Optional[str]: The group slice value or None if not set.
+       """
        return self.request_params.get("group_slice", None)

Also applies to: 711-715

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 60de364 and 808260c.

📒 Files selected for processing (4)
  • docs/source/plugins/developing_plugins.rst (2 hunks)
  • fiftyone/operators/builtin.py (2 hunks)
  • fiftyone/operators/executor.py (3 hunks)
  • fiftyone/operators/operations.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/source/plugins/developing_plugins.rst
  • fiftyone/operators/builtin.py
  • fiftyone/operators/operations.py

brimoor
brimoor previously approved these changes Sep 26, 2024
Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

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

@imanjra this is fantastic! works great!

Are you open to rebasing on release/v1.0.0 so we can squash those todos in the builtin operators? 😄

@imanjra
Copy link
Contributor Author

imanjra commented Sep 26, 2024

Are you open to rebasing on release/v1.0.0 so we can squash those todos in the builtin operators? 😄

Yah, totally! I am happy to rebase this if there are no objections from the release POV. This should be a clean rebase. I think it might be as simple as updating the base branch of the PR. 🙂

@brimoor brimoor changed the base branch from develop to release/v1.0.0 September 27, 2024 00:24
@brimoor brimoor dismissed their stale review September 27, 2024 00:24

The base branch was changed.

Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

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

Retargeted to release/v1.0.0

@brimoor brimoor merged commit 864604b into release/v1.0.0 Sep 27, 2024
13 checks passed
@brimoor brimoor deleted the feat/grp-slice-ctx branch September 27, 2024 00:25
@coderabbitai coderabbitai bot mentioned this pull request Oct 17, 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.

2 participants