Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,27 @@ class ApprovalOperator(HITLOperator, SkipMixin):

FIXED_ARGS = ["options", "multiple"]

APPROVE = "Approve"
REJECT = "Reject"

def __init__(self, ignore_downstream_trigger_rules: bool = False, **kwargs) -> None:
for arg in self.FIXED_ARGS:
if arg in kwargs:
raise ValueError(f"Passing {arg} to ApprovalOperator is not allowed.")

self.ignore_downstream_trigger_rules = ignore_downstream_trigger_rules

super().__init__(options=["Approve", "Reject"], multiple=False, **kwargs)
super().__init__(
options=[self.APPROVE, self.REJECT],
multiple=False,
**kwargs,
)

def execute_complete(self, context: Context, event: dict[str, Any]) -> Any:
ret = super().execute_complete(context=context, event=event)

chosen_option = ret["chosen_options"][0]
if chosen_option == "Approve":
if chosen_option == self.APPROVE:
self.log.info("Approved. Proceeding with downstream tasks...")
return ret

Expand Down Expand Up @@ -224,11 +231,13 @@ def execute_complete(self, context: Context, event: dict[str, Any]) -> None:
class HITLEntryOperator(HITLOperator):
"""Human-in-the-loop Operator that is used to accept user input through TriggerForm."""

OK = "OK"

def __init__(self, **kwargs) -> None:
if "options" not in kwargs:
kwargs["options"] = ["OK"]
kwargs["options"] = [self.OK]

if "defaults" not in kwargs:
kwargs["defaults"] = ["OK"]
kwargs["defaults"] = [self.OK]

super().__init__(**kwargs)