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 skip_prompt #4992

Merged
merged 2 commits into from
Oct 28, 2024
Merged

add skip_prompt #4992

merged 2 commits into from
Oct 28, 2024

Conversation

ritch
Copy link
Contributor

@ritch ritch commented Oct 25, 2024

Allows disabling of prompt when using ctx.prompt(), which will execute the operator immediately given the params.

Summary by CodeRabbit

  • New Features

    • Introduced a skip_prompt option for the PromptUserForOperation class, allowing users to bypass prompts during operation execution.
    • Added a skip_prompt parameter to the prompt method in the ExecutionContext class for enhanced control over user prompts.
  • Documentation

    • Updated method signatures and documentation to reflect the new skip_prompt parameter, improving clarity on its usage.

Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes introduce a new optional parameter, skip_prompt, to the resolveInput and execute methods of the PromptUserForOperation class in the built-in-operators.ts file. This parameter allows users to bypass prompts during operation execution. Similarly, the prompt method in the ExecutionContext class has been updated to include the skip_prompt parameter, enhancing the flexibility of user interaction. The default value for skip_prompt is set to false, ensuring that prompts are displayed unless specified otherwise.

Changes

File Path Change Summary
app/packages/operators/src/built-in-operators.ts Added skip_prompt parameter to resolveInput and execute methods in PromptUserForOperation. Updated logic to determine prompt display based on skip_prompt.
fiftyone/operators/executor.py Updated prompt method in ExecutionContext class to include skip_prompt parameter, allowing control over prompt invocation.

Poem

In the garden where prompts used to bloom,
A new path emerges, dispelling the gloom.
With skip_prompt in hand, we leap and we play,
Bypassing the chatter, we dance on our way.
Hops of delight in the code we now weave,
A flexible dance, oh, how we believe! 🐇✨


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 (1)
fiftyone/operators/executor.py (1)

Line range hint 747-757: Implementation incomplete: skip_prompt parameter is not being used.

While the skip_prompt parameter has been added to the method signature and documented, it's not being passed through to the underlying operation. The parameter needs to be included in the params dictionary that's passed to the trigger call.

Apply this diff to include the parameter:

     def prompt(
         self,
         operator_uri,
         params=None,
         on_success=None,
         on_error=None,
         skip_prompt=False,
     ):
         return self.trigger(
             "prompt_user_for_operation",
             params=_convert_callables_to_operator_uris(
                 {
                     "operator_uri": operator_uri,
                     "panel_id": self.panel_id,
                     "params": params,
                     "on_success": on_success,
                     "on_error": on_error,
+                    "skip_prompt": skip_prompt,
                 }
             ),
         )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d44e464 and d2323de.

📒 Files selected for processing (2)
  • app/packages/operators/src/built-in-operators.ts (2 hunks)
  • fiftyone/operators/executor.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/operators/src/built-in-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.

Comment on lines 1041 to 1046
const shouldPrompt = !params.skip_prompt;

triggerEvent(panelId, {
operator: operator_uri,
params,
prompt: true,
prompt: shouldPrompt,
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

Improve parameter access consistency and simplify logic.

The skip_prompt parameter is accessed differently from other parameters and the logic can be simplified.

Apply this diff to improve the code:

-    const shouldPrompt = !params.skip_prompt;
+    const { operator_uri, on_success, on_error, skip_prompt } = params;
+    const shouldPrompt = !skip_prompt;

     triggerEvent(panelId, {
       operator: operator_uri,
       params,
-      prompt: shouldPrompt,
+      prompt: !skip_prompt,
       callback: (result: OperatorResult) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const shouldPrompt = !params.skip_prompt;
triggerEvent(panelId, {
operator: operator_uri,
params,
prompt: true,
prompt: shouldPrompt,
const { operator_uri, on_success, on_error, skip_prompt } = params;
const shouldPrompt = !skip_prompt;
triggerEvent(panelId, {
operator: operator_uri,
params,
prompt: !skip_prompt,

@@ -1027,6 +1027,7 @@
inputs.obj("params", { label: "Params" });
inputs.str("on_success", { label: "On success" });
inputs.str("on_error", { label: "On error" });
inputs.str("skip_prompt", { label: "Skip prompt", default: false });
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix type mismatch for skip_prompt parameter.

The skip_prompt parameter is defined as a string but used as a boolean in the execute method. This could lead to unexpected behavior.

Apply this diff to fix the type and improve the description:

-    inputs.str("skip_prompt", { label: "Skip prompt", default: false });
+    inputs.bool("skip_prompt", { 
+      label: "Skip prompt",
+      description: "When true, bypasses the user prompt and executes immediately with provided parameters",
+      default: false 
+    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
inputs.str("skip_prompt", { label: "Skip prompt", default: false });
inputs.bool("skip_prompt", {
label: "Skip prompt",
description: "When true, bypasses the user prompt and executes immediately with provided parameters",
default: false
});

Copy link
Contributor

@Br2850 Br2850 left a comment

Choose a reason for hiding this comment

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

👍🏽 LGTM

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)
app/packages/operators/src/built-in-operators.ts (1)

1030-1030: Add a description for the skip_prompt parameter.

Consider adding a description to clarify the purpose and impact of skipping the prompt.

-    inputs.bool("skip_prompt", { label: "Skip prompt", default: false });
+    inputs.bool("skip_prompt", { 
+      label: "Skip prompt",
+      description: "When true, bypasses the user prompt and executes immediately with the provided parameters",
+      default: false 
+    });
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d2323de and 1285df7.

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

🔇 Additional comments (2)
app/packages/operators/src/built-in-operators.ts (2)

1041-1046: Reuse existing review comment about parameter access consistency.


1049-1061: LGTM! Error handling and success callbacks are well implemented.

The implementation properly handles both error and success cases, with appropriate type checking and event triggering.

@Br2850
Copy link
Contributor

Br2850 commented Oct 28, 2024

Working as of latest skip_prompt branch 👍🏽 🎉

@ritch ritch merged commit cf5a33d into develop Oct 28, 2024
13 checks passed
@ritch ritch deleted the skip_prompt branch October 28, 2024 21:37
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