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

record_result(target: str, result: str = 'OK')[source]

Records the result.

Parameters:
  • target (str) – the target component(s) that is called

  • result (str) – the result generated by calling the target component(s)

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.

handle_event(event_type: str, fl_ctx: FLContext)[source]

Handles events.

Parameters:
  • event_type (str) – event type fired by workflow.

  • fl_ctx (FLContext) – FLContext information.