diff --git a/app/packages/operators/src/built-in-operators.ts b/app/packages/operators/src/built-in-operators.ts index ae210641fd..99d99b1d46 100644 --- a/app/packages/operators/src/built-in-operators.ts +++ b/app/packages/operators/src/built-in-operators.ts @@ -1027,6 +1027,7 @@ class PromptUserForOperation extends Operator { inputs.obj("params", { label: "Params" }); inputs.str("on_success", { label: "On success" }); inputs.str("on_error", { label: "On error" }); + inputs.bool("skip_prompt", { label: "Skip prompt", default: false }); return new types.Property(inputs); } useHooks(ctx: ExecutionContext): {} { @@ -1037,22 +1038,27 @@ class PromptUserForOperation extends Operator { const { params, operator_uri, on_success, on_error } = ctx.params; const { triggerEvent } = ctx.hooks; const panelId = ctx.getCurrentPanelId(); + const shouldPrompt = !ctx.params.skip_prompt; triggerEvent(panelId, { operator: operator_uri, params, - prompt: true, + prompt: shouldPrompt, callback: (result: OperatorResult) => { if (result.error) { - triggerEvent(panelId, { - operator: on_error, - params: { error: result.error }, - }); + if (on_error) { + triggerEvent(panelId, { + operator: on_error, + params: { error: result.error }, + }); + } } else { - triggerEvent(panelId, { - operator: on_success, - params: { result: result.result }, - }); + if (on_success) { + triggerEvent(panelId, { + operator: on_success, + params: { result: result.result }, + }); + } } }, }); diff --git a/fiftyone/operators/executor.py b/fiftyone/operators/executor.py index 50c177f423..40a43eb07f 100644 --- a/fiftyone/operators/executor.py +++ b/fiftyone/operators/executor.py @@ -744,6 +744,7 @@ def prompt( params=None, on_success=None, on_error=None, + skip_prompt=False, ): """Prompts the user to execute the operator with the given URI. @@ -753,6 +754,7 @@ def prompt( on_success (None): a callback to invoke if the user successfully executes the operator on_error (None): a callback to invoke if the execution fails + skip_prompt (False): whether to skip the prompt Returns: a :class:`fiftyone.operators.message.GeneratedMessage` containing @@ -767,6 +769,7 @@ def prompt( "params": params, "on_success": on_success, "on_error": on_error, + "skip_prompt": skip_prompt, } ), )