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

add option to auto-execute operator on params change #4251

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

imanjra
Copy link
Contributor

@imanjra imanjra commented Apr 9, 2024

What changes are proposed in this pull request?

Add support for auto_execute. When set to True, the operator will automatically execute when an operator prompt input change

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

Usage

class LiveSavedView(foo.Operator):
    @property
    def config(self):
        return foo.OperatorConfig(
            name="playground_py_live_saved_view",
            label="Playground_Py: Live Saved View",
        )

    def resolve_input(self, ctx):
        inputs = types.Object()
        inputs.enum("saved_view", ctx.dataset.list_saved_views(), label="Saved View")
        return types.Property(
            inputs,
            view=types.DrawerView(
                auto_execute=True, auto_execute_delay=250, placement="left"
            ),
        )

    def execute(self, ctx):
        saved_view = ctx.params.get("saved_view", None)
        if saved_view:
            ctx.ops.set_view(name=saved_view)
        return {}

Preview

Kapture.2024-04-23.at.11.01.05.mp4

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.

Add support for execute_on_change. When set to True, the operator will automatically execute when a operator prompt input 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
    • Enhanced responsiveness in certain operations, improving the execution flow and output resolution based on specific conditions.

Copy link
Contributor

coderabbitai bot commented Apr 9, 2024

Walkthrough

The recent update brings significant changes to the operator functionality in the application. It introduces new constants for default auto-execute delays, refines the executeOnChange behavior based on conditions, and enhances the auto-execution flow for operators, both remote and local.

Changes

File Path Change Summary
.../operators/src/constants.ts
.../operators/src/state.ts
.../operators/src/utils.ts
Added constants for default auto-execute delays.
Updated useOperatorPrompt logic to handle executeOnChange based on conditions and auto-execution settings.
Adjusted getOperatorPromptConfigs to reset callbacks if auto-execute on change is enabled.
fiftyone/operators/types.py Extended PromptView and DrawerView classes with auto_execute and auto_execute_delay parameters for controlling automatic execution on parameter change.

🐰✨
A hop of code, a leap in flow,
New constants set, the changes glow.
In the burrow of the script, tweaks align,
Now watch the logic finely intertwine.
Cheers to the devs, with every line refine! 🎉
🐇💻


Recent Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between a57a5ac and a8a8116.
Files selected for processing (4)
  • app/packages/operators/src/constants.ts (1 hunks)
  • app/packages/operators/src/state.ts (7 hunks)
  • app/packages/operators/src/utils.ts (1 hunks)
  • fiftyone/operators/types.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • app/packages/operators/src/constants.ts
Additional Context Used
Path-based Instructions (2)
app/packages/operators/src/utils.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.

Additional comments not posted (5)
app/packages/operators/src/utils.ts (1)

77-80: Ensure proper handling of onSubmit and onCancel when autoExecuteOnChange is true.

Please verify that setting onSubmit and onCancel to undefined when autoExecuteOnChange is true does not lead to any unintended side effects elsewhere in the application. This change could potentially affect user interactions in scenarios where manual submission or cancellation is expected.

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

16-17: Introduction of new constants for auto-execute delay.

The introduction of LOCAL_OPERATOR_DEFAULT_AUTO_EXECUTE_DELAY and REMOTE_OPERATOR_DEFAULT_AUTO_EXECUTE_DELAY constants is a good practice for managing different delays based on the operator type. This allows for better customization and potentially different user experiences based on whether the operator is local or remote.


318-327: Handling of autoExecuteOnChange and autoExecuteDelay.

Please ensure that the logic for determining autoExecuteDelay correctly handles both the provided delay and the default values. It's crucial that this logic robustly supports scenarios where no delay is provided, and defaults are correctly applied based on whether the operator is remote or local.

fiftyone/operators/types.py (2)

1650-1651: The addition of auto_execute and auto_execute_delay parameters to PromptView aligns with the PR objectives. Please ensure the default values are appropriate for the intended behavior.


1779-1780: The addition of auto_execute and auto_execute_delay parameters to DrawerView aligns with the PR objectives. The validation for the placement parameter is a good practice to prevent incorrect values.

Warning

Following problems were encountered

  • Git: Failed to clone repository. Please contact CodeRabbit support.

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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@imanjra imanjra force-pushed the feat/live-operator-prompt branch 2 times, most recently from dfa59ca to 47d0f85 Compare April 15, 2024 13:56
@imanjra imanjra marked this pull request as ready for review April 15, 2024 13:57
@imanjra imanjra changed the base branch from feat/operator-drawer-view to develop April 15, 2024 13:57
@imanjra imanjra requested review from ritch and a team April 15, 2024 13:59
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

Out of diff range and nitpick comments (1)
app/packages/operators/src/state.ts (1)

508-523: Implementation of debounced auto-execution function.

Consider adding error handling or a cancellation mechanism within the debouncedAutoExecute function to manage scenarios where the execution needs to be stopped or modified based on changing conditions. This could enhance the robustness of the feature, especially in dynamic environments where operator parameters might change frequently.

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.

None yet

1 participant