airflow.providers.standard.operators.hitl¶
Classes¶
Base class for all Human-in-the-loop Operators to inherit from. |
|
Human-in-the-loop Operator that has only 'Approval' and 'Reject' options. |
|
BranchOperator based on Human-in-the-loop Response. |
|
Human-in-the-loop Operator that is used to accept user input through TriggerForm. |
Module Contents¶
- class airflow.providers.standard.operators.hitl.HITLOperator(*, subject, options, body=None, defaults=None, multiple=False, params=None, notifiers=None, respondents=None, **kwargs)[source]¶
Bases:
airflow.providers.standard.version_compat.BaseOperator
Base class for all Human-in-the-loop Operators to inherit from.
- Parameters:
subject (str) – Headline/subject presented to the user for the interaction task.
options (list[str]) – List of options that the an user can select from to complete the task.
body (str | None) – Descriptive text (with Markdown support) that gives the details that are needed to decide.
defaults (str | list[str] | None) – The default options and the options that are taken if timeout is passed.
multiple (bool) – Whether the user can select one or multiple options.
params (airflow.sdk.definitions.param.ParamsDict | dict[str, Any] | None) – dictionary of parameter definitions that are in the format of Dag params such that a Form Field can be rendered. Entered data is validated (schema, required fields) like for a Dag run and added to XCom of the task result.
- template_fields: collections.abc.Collection[str] = ('subject', 'body')[source]¶
- notifiers: collections.abc.Sequence[airflow.sdk.bases.notifier.BaseNotifier][source]¶
- validate_options()[source]¶
Validate the options attribute of the instance.
- Raises:
ValueError: If options is empty.
- validate_params()[source]¶
Validate the params attribute of the instance.
- Raises:
ValueError: If “_options” key is present in params, which is not allowed.
- validate_defaults()[source]¶
Validate whether the given defaults pass the following criteria.
Default options should be the subset of options.
When multiple is False, there should only be one option.
- execute(context)[source]¶
Add a Human-in-the-loop Response and then defer to HITLTrigger and wait for user input.
- generate_link_to_ui(*, task_instance, base_url=None, options=None, params_input=None)[source]¶
Generate a URL link to the “required actions” page for a specific task instance.
This URL includes query parameters based on allowed options and parameters.
- Args:
task_instance: The task instance to generate the link for. base_url: Optional base URL to use. Defaults to
api.base_url
from config. options: Optional subset of allowed options to include in the URL. params_input: Optional subset of allowed params to include in the URL.- Raises:
ValueError: If any provided option or parameter is invalid. ValueError: If no base_url can be determined.
- Returns:
The full URL pointing to the required actions page with query parameters.
- static generate_link_to_ui_from_context(*, context, base_url=None, options=None, params_input=None)[source]¶
Generate a “required actions” page URL from a task context.
Delegates to
generate_link_to_ui
using the task and task_instance extracted from the provided context.- Args:
context: The Airflow task context containing ‘task’ and ‘task_instance’. base_url: Optional base URL to use. options: Optional list of allowed options to include. params_input: Optional dictionary of allowed parameters to include.
- Returns:
The full URL pointing to the required actions page with query parameters.
- class airflow.providers.standard.operators.hitl.ApprovalOperator(ignore_downstream_trigger_rules=False, **kwargs)[source]¶
Bases:
HITLOperator
,airflow.providers.standard.utils.skipmixin.SkipMixin
Human-in-the-loop Operator that has only ‘Approval’ and ‘Reject’ options.
- class airflow.providers.standard.operators.hitl.HITLBranchOperator(*, options_mapping=None, **kwargs)[source]¶
Bases:
HITLOperator
,airflow.providers.standard.operators.branch.BranchMixIn
BranchOperator based on Human-in-the-loop Response.
- inherits_from_skipmixin = True[source]¶
Used to determine if an Operator is inherited from SkipMixin or its subclasses (e.g., BranchMixin).
- class airflow.providers.standard.operators.hitl.HITLEntryOperator(**kwargs)[source]¶
Bases:
HITLOperator
Human-in-the-loop Operator that is used to accept user input through TriggerForm.