nvflare.app_common.ccwf.client_ctl module

class ClientSideController(task_name_prefix: str, learn_task_name='train', persistor_id='persistor', shareable_generator_id='shareable_generator', learn_task_check_interval=1.0, learn_task_ack_timeout=10, learn_task_abort_timeout=5.0, final_result_ack_timeout=10, allow_busy_task: bool = False)[source]

Bases: Executor, TaskController

Constructor of a ClientSideController object.

Parameters:
  • task_name_prefix – prefix of task names. All CCWF task names are prefixed with this.

  • learn_task_name – name for the Learning Task (LT)

  • persistor_id – ID of the persistor component

  • shareable_generator_id – ID of the shareable generator component

  • learn_task_check_interval – interval for checking incoming Learning Task (LT)

  • learn_task_ack_timeout – timeout for sending the LT to other client(s)

  • final_result_ack_timeout – timeout for sending final result to participating clients

  • learn_task_abort_timeout – time to wait for the LT to become stopped after aborting it

  • allow_busy_task – whether a new learn task is allowed when working on current learn task

broadcast_final_result(fl_ctx: FLContext, result_type: str, result: Learnable, metric=None, round_num=None)[source]
abstract do_learn_task(name: str, data: Shareable, fl_ctx: FLContext, abort_signal: Signal)[source]

This is called to do a Learn Task. Subclass must implement this method.

Parameters:
  • name – task name

  • data – task data

  • fl_ctx – FL context of the task

  • abort_signal – abort signal for the task execution

Returns:

execute(task_name: str, shareable: Shareable, fl_ctx: FLContext, abort_signal: Signal) Shareable[source]

Executes a task.

Parameters:
  • task_name (str) – task name.

  • shareable (Shareable) – input shareable.

  • fl_ctx (FLContext) – fl context.

  • abort_signal (Signal) – signal to check during execution to determine whether this task is aborted.

Returns:

An output shareable.

execute_learn_task(data: Shareable, fl_ctx: FLContext, abort_signal: Signal) Shareable[source]
finalize(fl_ctx: FLContext)[source]

Called to finalize the executor.

Parameters:

fl_ctx – the FL Context

Returns: None

get_config_prop(name: str, default=None)[source]

Get a specified config property.

Parameters:
  • name – name of the property

  • default – default value to return if the property is not defined.

Returns:

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.

initialize(fl_ctx: FLContext)[source]

Called to initialize the executor.

Parameters:

fl_ctx – The FL Context

Returns: None

is_task_secure(fl_ctx: FLContext) bool[source]

Determine whether the task should be secure. A secure task requires encrypted communication between the peers. The task is secure only when the training is in secure mode AND private_p2p is set to True.

process_config(fl_ctx: FLContext)[source]

This is called to allow the subclass to process config props.

Returns: None

record_last_result(fl_ctx: FLContext, round_num: int, result: Learnable)[source]
send_learn_task(targets: list, request: Shareable, fl_ctx: FLContext) bool[source]
set_learn_task(task_data: Shareable, fl_ctx: FLContext) bool[source]
start_run(fl_ctx: FLContext)[source]
abstract start_workflow(shareable: Shareable, fl_ctx: FLContext, abort_signal: Signal) Shareable[source]

This is called for the subclass to start the workflow. This only happens on the starting_client.

Parameters:
  • shareable – the initial task data (e.g. initial model weights)

  • fl_ctx – FL context

  • abort_signal – abort signal for task execution

Returns:

topic_for_my_workflow(base_topic: str)[source]
update_status(last_round=None, action=None, error=None, all_done=False)[source]