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:
PipelineComponent
A service group class.
- components: List[Union[Service, ServiceGroup]]#
A
ServiceGroup
object, 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#
AnyCondition
that is invoked before each component execution; component is executed only if it returnsTrue
.
- name: Optional[str]#
Name of the component. Defaults to
computed_name
potentially 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_concurrent
flag is set to True, allcomponents
will 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.FAILED
if 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,
condition
is 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
ServiceGroup
can be validated from.alias of
Union
[ServiceGroup
,List
[Union
[Actor
,Service
, typing.Annotated[dict, ‘dict following the Service data model’],Callable
[Callable
],BaseProcessing
[BaseProcessing
],ServiceGroupInitTypes
]][List
[Union
[Actor
,Service
, typing.Annotated[dict, ‘dict following the Service data model’],Callable
[Callable
],BaseProcessing
[BaseProcessing
],ServiceGroupInitTypes
]]],Union
[Actor
,Service
, typing.Annotated[dict, ‘dict following the Service data model’],Callable
[Callable
],BaseProcessing
[BaseProcessing
],ServiceGroupInitTypes
][Union
[Actor
,Service
, typing.Annotated[dict, ‘dict following the Service data model’],Callable
[Callable
],BaseProcessing
[BaseProcessing
],ServiceGroupInitTypes
]], typing.Annotated[dict, ‘dict following the ServiceGroup data model’]]