nvflare.app_common.ccwf.swarm_client_ctl module¶
- class Gatherer(task_data: Shareable, fl_ctx: FLContext, for_round: int, executor: ClientSideController, aggregator: Aggregator, metric_comparator: MetricComparator, all_clients: list, trainers: list, min_responses_required: int, wait_time_after_min_resps_received: float, timeout)[source]¶
Bases:
FLComponent
Init FLComponent.
The FLComponent is the base class of all FL Components. (executors, controllers, responders, filters, aggregators, and widgets are all FLComponents)
FLComponents have the capability to handle and fire events and contain various methods for logging.
- class SwarmClientController(task_name_prefix='swarm', learn_task_name='train', persistor_id='persistor', shareable_generator_id='shareable_generator', aggregator_id='aggregator', metric_comparator_id=None, learn_task_check_interval=1.0, learn_task_abort_timeout=5.0, learn_task_ack_timeout=10, learn_task_timeout=None, final_result_ack_timeout=10, min_responses_required: int = 1, wait_time_after_min_resps_received: float = 10.0)[source]¶
Bases:
ClientSideController
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
- do_learn_task(name: str, task_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.
- 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.
- process_config(fl_ctx: FLContext)[source]¶
This is called to allow the subclass to process config props.
Returns: None
- 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: