Skip to content

Commit

Permalink
skip_prompt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ritch committed Oct 28, 2024
1 parent 78f3a19 commit cf5a33d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/packages/operators/src/built-in-operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +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.str("skip_prompt", { label: "Skip prompt", default: false });
inputs.bool("skip_prompt", { label: "Skip prompt", default: false });
return new types.Property(inputs);
}
useHooks(ctx: ExecutionContext): {} {
Expand All @@ -1038,23 +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 = !params.skip_prompt;
const shouldPrompt = !ctx.params.skip_prompt;

triggerEvent(panelId, {
operator: operator_uri,
params,
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 },
});
}
}
},
});
Expand Down
1 change: 1 addition & 0 deletions fiftyone/operators/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ def prompt(
"params": params,
"on_success": on_success,
"on_error": on_error,
"skip_prompt": skip_prompt,
}
),
)
Expand Down

0 comments on commit cf5a33d

Please sign in to comment.