Service Group#
The Service Group module contains the ServiceGroup class, which is used to represent a group of related services.
This class provides a way to organize and manage multiple services as a single unit, allowing for easier management and organization of the services within the pipeline.
- class ServiceGroup(**data)[source]#
Bases:
PipelineComponentA service group class.
- components: List[Union[Service, ServiceGroup]]#
A
ServiceGroupobject, that will be added to the group.
- fully_concurrent: bool#
Whether this should run all components inside it concurrently (regardless of their concurrent attribute. This is not recursive (applies only to first level components). Default value is False.
- before_handler: BeforeHandler#
BeforeHandler, associated with this component.
- after_handler: AfterHandler#
AfterHandler, associated with this component.
- timeout: Optional[float]#
Maximum component execution time (in seconds), if it exceeds this time, it is interrupted.
- concurrent: bool#
Optional flag that indicates whether this component should be executed concurrently with adjacent concurrent components.
- start_condition: AnyCondition#
AnyConditionthat is invoked before each component execution; component is executed only if it returnsTrue.
- name: Optional[str]#
Name of the component. Defaults to
computed_namepotentially modified byrename_component_incrementing().See
validate_name()for rules.
- path: Optional[str]#
Separated by dots path to component, is universally unique.
- classmethod components_validator(data)[source]#
Add support for initializing from a list of
PipelineComponent.
- async run_component(ctx)[source]#
Run components of this service group.
If
fully_concurrentflag is set to True, allcomponentswill run concurrently (viaasyncio.gather).Otherwise, all non-concurrent components execute one after another while consecutive concurrent components are run concurrently (via
asyncio.gather).- Parameters:
ctx (
Context) – Current dialog context.- Return type:
Optional[ComponentExecutionState]- Returns:
ComponentExecutionState.FAILEDif any component failed.
- add_extra_handler(extra_handler_type, extra_handler, condition=<function ServiceGroup.<lambda>>)[source]#
Add extra handler to this group.
For every component in the group,
conditionis called with the path of that component to determine whether to add extra handler to that component.- Parameters:
extra_handler_type (ExtraHandlerType) – Extra handler type (before or after).
extra_handler (
ExtraHandlerFunction) – Function to add as an extra handler.condition (
ExtraHandlerConditionFunction) – Condition function to determine if extra handler should be added to specific subcomponents. Defaults to a function returning False.
- property computed_name: str#
“service_group”
- ServiceGroupInitTypes#
Types that
ServiceGroupcan be validated from.alias of
ServiceGroup|Annotated[List[Actor|Service|Annotated[dict, ‘dict following the Service data model’] |Annotated[Callable, ‘handler for the service’] |Annotated[BaseProcessing, ‘handler for the service’] |ServiceGroupInitTypes], ‘list of components’] |Annotated[Actor|Service|Annotated[dict, ‘dict following the Service data model’] |Annotated[Callable, ‘handler for the service’] |Annotated[BaseProcessing, ‘handler for the service’] |ServiceGroupInitTypes, ‘single component of the group’] |Annotated[dict, ‘dict following the ServiceGroup data model’]