nvflare.private.fed.simulator.simulator_server module

class SimulatorRunManager(server_name, engine: ~nvflare.apis.server_engine_spec.ServerEngineSpec, job_id, workspace: ~nvflare.apis.workspace.Workspace, components: {<class 'str'>: <class 'nvflare.apis.fl_component.FLComponent'>}, client_manager: ~nvflare.private.fed.server.client_manager.ClientManager | None = None, handlers: ~typing.List[~nvflare.apis.fl_component.FLComponent] | None = None)[source]

Bases: RunManager

Manage run.

Parameters:
  • server_name – server name

  • engine (ServerEngineSpec) – server engine

  • job_id – job id

  • workspace (Workspace) – workspace

  • components (dict) – A dict of extra python objects {id: object}

  • client_manager (ClientManager, optional) – client manager

  • handlers (List[FLComponent], optional) – handlers

create_job_processing_context_properties(workspace, job_id)[source]
class SimulatorServer(project_name=None, min_num_clients=2, max_num_clients=10, cmd_modules=None, heart_beat_timeout=600, handlers: List[FLComponent] | None = None, args=None, secure_train=False, enable_byoc=False, snapshot_persistor=None, overseer_agent=None)[source]

Bases: FederatedServer

Federated server services.

Parameters:
  • project_name – server project name.

  • min_num_clients – minimum number of contributors at each round.

  • max_num_clients – maximum number of contributors at each round.

  • cmd_modules – command modules.

  • heart_beat_timeout – heartbeat timeout

  • handlers – A list of handler

  • args – arguments

  • secure_train – whether to use secure communication

authentication_check(request: Message, state_check)[source]
client_cleanup()[source]
create_run_manager(workspace, job_id)[source]
deploy(args, grpc_args=None, secure_train=False)[source]

Start a grpc server and listening the designated port.

stop_run_engine_cell()[source]
stop_training()[source]
class SimulatorServerEngine(server, args, client_manager: ClientManager, snapshot_persistor, workers=3)[source]

Bases: ServerEngine

Server engine.

Parameters:
  • server – server

  • args – arguments

  • client_manager (ClientManager) – client manager.

  • workers – number of worker threads.

fire_event(event_type: str, fl_ctx: FLContext)[source]
persist_components(fl_ctx: FLContext, completed: bool)[source]

To persist the FL running components

Parameters:
  • fl_ctx – FLContext

  • completed – flag to indicate where the run is complete

Returns:

send_aux_request(targets: [], topic: str, request: Shareable, timeout: float, fl_ctx: FLContext, optional=False, secure=False) dict[source]

Send a request to specified clients via the aux channel.

Implementation: simply calls the ServerAuxRunner’s send_aux_request method.

Parameters:
  • targets – target clients. None or empty list means all clients

  • topic – topic of the request

  • request – request to be sent

  • timeout – number of secs to wait for replies. 0 means fire-and-forget.

  • fl_ctx – FL context

  • optional – whether this message is optional

  • secure – send the aux request in a secure way

Returns: a dict of replies (client name => reply Shareable)

sync_clients_from_main_process()[source]

To fetch the participating clients from the main parent process

Returns: clients

update_job_run_status()[source]

To update the job run status to parent process.