nvflare.widgets.comp_caller module¶
- class CallInfo(target: str, action: str, params: dict)[source]¶
Bases:
object
Required information to call a component.
- Parameters:
target (str) – target component(s) that the call is applied to
action (str) – action of the call
params (dict) – params of the call
- class ComponentCaller[source]¶
Bases:
Widget
A widget enables calling component(s).
- CTX_KEY_CALL_INFO = 'comp_caller.call_info'¶
- EVENT_TYPE_CALL_COMPONENT = 'comp_caller.call'¶
- call_components(target: str, action: str, params: dict)[source]¶
Makes a call to component(s).
- Parameters:
target (str) – the target spec of the component(s) to be called.
action (str) – action of the call
params (dict) – parameters for the call
- Returns:
comp name => result string
- Return type:
None or a dict of result
Note
- each component that wants to participate the call mechanism must:
Listen to the event EVENT_TYPE_CALL_COMPONENT
In the event handler, decide whether the call is applicable to it by comparing itself to the ‘target’. The target could be a specific component ID, or a type of components
decide further whether the call is applicable to it by looking at the ‘action’. Conceptually, the action is like a function to be called on the component. If the component doesn’t support the action, simply ignore the call.
if the call is applicable, always report the execution status to the call.