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

Allow legacy orchestration #5176

Merged
merged 6 commits into from
Nov 22, 2024
Merged

Allow legacy orchestration #5176

merged 6 commits into from
Nov 22, 2024

Conversation

brimoor
Copy link
Contributor

@brimoor brimoor commented Nov 22, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new configuration option to enable legacy orchestrators, enhancing flexibility in operation management.
    • Updated descriptions for execution options to improve clarity and context for users.
  • Documentation

    • Enhanced documentation for plugin management, including new environment variable requirements and clearer instructions for operations.
    • Updated configuration guide to include new fields and improved clarity on settings.
    • Expanded the plugin development guide with detailed explanations and examples.
  • User Interface Improvements

    • Added visual feedback for interactive menu items in the SplitButton component to enhance user experience.

@brimoor brimoor added the enhancement Code enhancement label Nov 22, 2024
Copy link
Contributor

coderabbitai bot commented Nov 22, 2024

Walkthrough

The changes in this pull request involve updates to the OperatorExecutionOption type and the useOperatorPromptSubmitOptions function in state.ts, allowing for more flexible description types and making the onClick method optional. Documentation has been enhanced to include a new environment variable, FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS, and a configuration field, allow_legacy_orchestrators, for managing legacy orchestrators. Additionally, the ExecutionOptions class now dynamically determines orchestrator registration based on the new configuration. Minor UI improvements were made to the SplitButton component.

Changes

File Change Summary
app/packages/operators/src/state.ts Updated OperatorExecutionOption type: description accepts `string
docs/source/plugins/using_plugins.rst Added section on FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS for managing legacy orchestrators. Enhanced plugin management instructions.
docs/source/user_guide/config.rst Added allow_legacy_orchestrators configuration field (default False). Updated configuration viewing instructions and examples.
fiftyone/core/config.py Added allow_legacy_orchestrators attribute to FiftyOneConfig, initialized from input dictionary.
fiftyone/operators/executor.py Updated orchestrator_registration_enabled property to return dynamic value based on allow_legacy_orchestrators.
app/packages/operators/src/SplitButton.tsx Added sx prop to MenuItem for conditional cursor styling based on option.onClick. Updated PrimaryWithTag function to include disabled parameter.
docs/source/plugins/developing_plugins.rst Enhanced clarity and comprehensiveness of the plugin development guide. Added new examples and sections.

Possibly related PRs

  • DashboardView #4557: The changes in the main PR regarding the OperatorExecutionOption type and the useOperatorPromptSubmitOptions function may relate to the DashboardView component, which involves managing dynamic layouts and user interactions, potentially utilizing similar execution options.
  • [DOCS] clarify env vars for plugin orchestrator #4785: The updates to the documentation regarding environment variables for the plugin orchestrator may connect to the changes in the main PR that involve execution options, as both deal with orchestrating operations within the application.
  • better group slice support for operators #4850: The enhancements to group slice support in operators could relate to the changes in the main PR, as both involve modifications to how execution options and context are managed within the application.
  • add spaces context to operators #4902: The addition of spaces context to operators aligns with the changes in the main PR, which also deals with execution options and context management, enhancing the overall functionality of operator execution.
  • always disable orchestrator registration #5111: The change to always disable orchestrator registration may relate to the main PR's focus on execution options, as both involve aspects of how operations are managed within the application.
  • Update docs to mention builtin orchestrator #5140: The documentation updates regarding the builtin orchestrator may connect to the main PR's changes, as both involve clarifying how operations and execution contexts are handled within the application.

Suggested labels

documentation

Suggested reviewers

  • ritch
  • swheaton

🐰 In the code, we hop and play,
With options new, we pave the way.
Legacy orchestrators now take flight,
In FiftyOne's realm, all feels just right!
With buttons split and styles so neat,
Our changes make the app a treat! 🥕


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 (4)
fiftyone/core/config.py (1)

123-128: LGTM! Consider adding docstring documentation.

The implementation follows the established patterns and uses a secure default value of False. However, consider adding a docstring to document the purpose and impact of this configuration option.

 def __init__(self, d=None):
     if d is None:
         d = {}
+    # Whether to allow legacy orchestrators for backward compatibility
+    # Default is False for security
     self.allow_legacy_orchestrators = self.parse_bool(
         d,
         "allow_legacy_orchestrators",
         env_var="FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS",
         default=False,
     )
app/packages/operators/src/state.ts (1)

290-290: Consider providing more context in the description

While "Run this operation in the background" is user-friendly, it might be too vague. Consider adding more context about resource usage and execution environment.

-      description: "Run this operation in the background",
+      description: "Run this operation in the background using dedicated compute resources",
docs/source/plugins/using_plugins.rst (1)

894-901: LGTM! Consider adding a note about persistence.

The documentation clearly explains the requirement for the FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS environment variable.

Consider adding a note about persisting this configuration in the FiftyOne config file for a more permanent solution:

    export FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS=true
+
+.. note::
+
+    You can also set this configuration permanently in your
+    :ref:`FiftyOne config <configuring-fiftyone>`:
+
+    .. code-block:: json
+
+        {
+            "allow_legacy_orchestrators": true
+        }
fiftyone/operators/executor.py (1)

1280-1280: LGTM! Consider adding a docstring.

The logic change correctly implements dynamic orchestrator registration control based on the allow_legacy_orchestrators configuration.

Add a docstring to clarify the property's behavior:

    @property
    def orchestrator_registration_enabled(self):
+        """Whether orchestrator registration is enabled.
+        
+        Returns:
+            bool: True if registration is enabled (legacy orchestrators disabled),
+                 False if registration is disabled (legacy orchestrators allowed)
+        """
        return not fo.config.allow_legacy_orchestrators
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c5a74a5 and 102847c.

📒 Files selected for processing (5)
  • app/packages/operators/src/state.ts (2 hunks)
  • docs/source/plugins/using_plugins.rst (1 hunks)
  • docs/source/user_guide/config.rst (3 hunks)
  • fiftyone/core/config.py (1 hunks)
  • fiftyone/operators/executor.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
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.

🔇 Additional comments (4)
fiftyone/core/config.py (1)

123-128: Verify environment variable usage.

Let's verify that the environment variable FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS is properly referenced throughout the codebase.

✅ Verification successful

Environment variable FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS is properly referenced and used

The environment variable is consistently used across the codebase:

  • Properly defined in config.py with correct default value (False)
  • Correctly documented in user guides with clear description
  • Actively used in executor.py for controlling operation scheduling behavior
  • Well-documented in plugin usage guides with examples
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to the environment variable
echo "Searching for environment variable references..."
rg "FIFTYONE_ALLOW_LEGACY_ORCHESTRATORS"

# Search for any code that might be checking this configuration
echo "Searching for configuration usage..."
rg "allow_legacy_orchestrators"

# Search for any legacy orchestrator related code
echo "Searching for legacy orchestrator references..."
rg -i "legacy.*orchestrator"

Length of output: 2463

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

372-373: LGTM! Clear and informative warning message

The updated warning message effectively guides users by:

  1. Explaining the requirement for delegated execution
  2. Providing documentation links
  3. Offering a clear upgrade path
docs/source/user_guide/config.rst (2)

113-115: LGTM! Well-documented configuration field.

The new configuration field allow_legacy_orchestrators is properly documented with clear description, environment variable, and default value.


183-183: LGTM! Consistent example updates.

The new configuration field is properly added to both Python and CLI example outputs, maintaining consistency with the configuration table.

Also applies to: 233-233

swheaton
swheaton previously approved these changes Nov 22, 2024
Copy link
Contributor

@swheaton swheaton left a comment

Choose a reason for hiding this comment

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

looks fine to me

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 (3)
app/packages/operators/src/SplitButton.tsx (3)

131-133: LGTM! Consider using MUI's built-in button styles

The cursor style implementation is correct, but consider using MUI's built-in disabled button styling for consistency.

 sx={{
-  cursor: option.onClick ? "pointer" : "default",
+  ...(!option.onClick && {
+    pointerEvents: "none",
+    cursor: "default"
+  })
 }}

Line range hint 28-35: Add TypeScript interface for component props

The component lacks proper TypeScript type definitions which impacts maintainability and type safety.

interface Option {
  id: string;
  label: string;
  choiceLabel?: string;
  description?: string;
  tag?: string;
  selected?: boolean;
  default?: boolean;
  disabled?: boolean;
  onClick?: () => void;
  onSelect: () => void;
}

interface SplitButtonProps {
  options: Option[];
  submitOnEnter?: boolean;
  onSubmit: () => void;
  disabled?: boolean;
  disabledReason?: string;
}

Line range hint 42-44: Add prop-types validation for runtime checking

While TypeScript provides compile-time type checking, consider adding prop-types for runtime validation.

import PropTypes from 'prop-types';

SplitButton.propTypes = {
  options: PropTypes.arrayOf(
    PropTypes.shape({
      id: PropTypes.string.isRequired,
      label: PropTypes.string.isRequired,
      choiceLabel: PropTypes.string,
      description: PropTypes.string,
      tag: PropTypes.string,
      selected: PropTypes.bool,
      default: PropTypes.bool,
      disabled: PropTypes.bool,
      onClick: PropTypes.func,
      onSelect: PropTypes.func.isRequired,
    })
  ).isRequired,
  submitOnEnter: PropTypes.bool,
  onSubmit: PropTypes.func.isRequired,
  disabled: PropTypes.bool,
  disabledReason: PropTypes.string,
};
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e9b089a and 09764f2.

📒 Files selected for processing (3)
  • app/packages/operators/src/SplitButton.tsx (1 hunks)
  • app/packages/operators/src/constants.ts (1 hunks)
  • app/packages/operators/src/state.ts (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/packages/operators/src/state.ts
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/operators/src/SplitButton.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/constants.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 (1)
app/packages/operators/src/constants.ts (1)

19-19: Verify the usage patterns of IS_OSS constant

Let's verify how this constant is used across the codebase to ensure our suggested changes are safe.

@@ -16,3 +16,4 @@ export enum QueueItemStatus {
}
export const PANEL_STATE_CHANGE_DEBOUNCE = 500;
export const PANEL_STATE_PATH_CHANGE_DEBOUNCE = 250;
export const IS_OSS = true; // false in fiftyone-teams
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

Consider improving the configuration management approach

The hard-coded boolean with an inline comment suggesting manual modification for different versions could lead to maintenance issues. Consider these improvements:

  1. Add explicit type annotation for better type safety
  2. Consider moving this to a configuration system that can be controlled at build/runtime
- export const IS_OSS = true; // false in fiftyone-teams
+ export const IS_OSS: boolean = process.env.FIFTYONE_IS_OSS === 'true';

Consider these architectural improvements:

  1. Use environment variables or build-time configuration
  2. Implement feature flags system for version-specific features
  3. Consider using dependency injection for version-specific behavior

Committable suggestion skipped: line range outside the PR's diff.

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 (5)
app/packages/operators/src/SplitButton.tsx (3)

132-134: Consider using a more semantic approach for cursor styling

While the current implementation works, it would be more semantic to base the cursor style on the disabled state rather than the presence of onClick.

 sx={{
-  cursor: option.onClick ? "pointer" : "default",
+  cursor: option.disabled ? "default" : "pointer",
 }}

151-160: Consider using theme typography instead of hardcoded font size

The hardcoded font size could be replaced with theme-based typography for better consistency and maintainability.

 <Box
   sx={{
-    fontSize: "11px",
-    "& *": { fontSize: "inherit" },
+    typography: 'caption',
+    "& *": { fontSize: 'inherit' },
   }}
 >

175-181: Enhance component performance and styling consistency

Consider these improvements:

  1. Memoize the component to prevent unnecessary rerenders in lists
  2. Move inline styles to sx prop for consistency with Material-UI patterns
-function PrimaryWithTag({ label, tag, disabled }) {
+const PrimaryWithTag = React.memo(({ label, tag, disabled }: PrimaryWithTagProps) => {
   const theme = useTheme();
   const tagEl = tag ? (
     <span
-      style={{
-        fontSize: "11px",
-        color: disabled ? theme.text.secondary : theme.custom.primarySoft,
-        marginLeft: "5px",
-      }}
+      sx={{
+        typography: 'caption',
+        color: (theme) => disabled ? theme.text.secondary : theme.custom.primarySoft,
+        ml: 1,
+      }}
     >
       {tag}
     </span>
   ) : null;
   return (
-    <div style={{ display: "flex", alignItems: "center" }}>
+    <Box sx={{ display: "flex", alignItems: "center" }}>
       {label}
       {tagEl}
-    </div>
+    </Box>
   );
-}
+});
app/packages/operators/src/state.ts (2)

331-349: LGTM: Enhanced UX for unavailable orchestrators

Good addition of user guidance when orchestrators are not available. The Markdown component effectively provides a documentation link for self-help.

Consider adding error boundary around the Markdown component for resilience:

-    const markdownDesc = React.createElement(
-      Markdown,
-      null,
-      "[Learn how](https://docs.voxel51.com/plugins/using_plugins.html#delegated-operations) to run this operation in the background"
-    );
+    const markdownDesc = React.createElement(
+      React.Suspense,
+      { fallback: "Loading documentation link..." },
+      React.createElement(
+        Markdown,
+        null,
+        "[Learn how](https://docs.voxel51.com/plugins/using_plugins.html#delegated-operations) to run this operation in the background"
+      )
+    );

397-399: LGTM: Clear warning message with documentation link

The warning message effectively communicates the requirement for delegated execution and provides a helpful documentation link.

Consider adding error boundary similar to the previous suggestion:

-  const warningMessage = React.createElement(Markdown, null, warningStr);
+  const warningMessage = React.createElement(
+    React.Suspense,
+    { fallback: "Loading warning message..." },
+    React.createElement(Markdown, null, warningStr)
+  );
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f692b3a and 1b8709d.

📒 Files selected for processing (2)
  • app/packages/operators/src/SplitButton.tsx (4 hunks)
  • app/packages/operators/src/state.ts (8 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
app/packages/operators/src/SplitButton.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/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.

🔇 Additional comments (4)
app/packages/operators/src/SplitButton.tsx (1)

14-14: LGTM!

The Box import is correctly added and follows Material-UI import conventions.

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

241-242: LGTM: Type improvements enhance flexibility

The changes improve type definitions by:

  • Allowing rich content (React nodes) in descriptions
  • Making onClick optional which better reflects the component's behavior

261-261: LGTM: Fixed typo in variable name

Corrected spelling from "hasAvailableOrchestators" to "hasAvailableOrchestrators".


297-297: LGTM: Improved user-facing message clarity

The description now uses more generic and user-friendly language, focusing on the user's perspective rather than implementation details.

app/packages/operators/src/SplitButton.tsx 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)
docs/source/plugins/developing_plugins.rst (1)

995-996: Documentation enhancement for execution context properties

The addition of ctx.delegated and ctx.requesting_delegated_execution properties provides important context about the execution mode of operations. This helps developers understand whether their operation is being executed immediately or has been delegated to a background task.

Consider adding examples showing how these properties can be used in practice, such as:

def execute(self, ctx):
    if ctx.delegated:
        # Configure for background execution
        batch_size = 1000
    else:
        # Configure for immediate execution
        batch_size = 100
    
    # Process in batches
    for batch in ctx.dataset.iter_batches(batch_size):
        # Process batch
        pass
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1b8709d and 2ede748.

⛔ Files ignored due to path filters (1)
  • docs/source/images/plugins/operators/operator-user-delegation.png is excluded by !**/*.png, !**/*.png
📒 Files selected for processing (2)
  • docs/source/plugins/developing_plugins.rst (1 hunks)
  • fiftyone/operators/executor.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • fiftyone/operators/executor.py

@brimoor brimoor merged commit 7b079dc into release/v1.1.0 Nov 22, 2024
12 of 13 checks passed
@brimoor brimoor deleted the legacy-orcs branch November 22, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Code enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants