nvflare.app_opt.xgboost.histogram_based_v2.adaptors.adaptor module

class AppAdaptor(app_name: str, in_process: bool)[source]

Bases: ABC, FLComponent

AppAdaptors are used to integrate FLARE with App Target (Server or Client) in run time.

For example, an XGB server could be run as a gRPC server process, or be run as part of the FLARE’s FL server process. Similarly, an XGB client could be run as a gRPC client process, or be run as part of the FLARE’s FL client process.

Each type of XGB Target requires an appropriate adaptor to integrate it with FLARE’s XGB Controller or Executor.

The XGBAdaptor class defines commonly required methods for all adaptor implementations.

abstract configure(config: dict, fl_ctx: FLContext)[source]

Called by XGB Controller/Executor to configure the adaptor. If any error occurs, this method should raise an exception.

Parameters:
  • config – config data

  • fl_ctx – the FL context

Returns: None

initialize(fl_ctx: FLContext)[source]

Called by the Controller/Executor to initialize the adaptor.

Parameters:

fl_ctx – the FL context

Returns: None

is_runner_stopped() -> (<class 'bool'>, <class 'int'>)[source]
monitor_target(fl_ctx: FLContext, target_stopped_cb)[source]

Called by XGB Controller/Executor to monitor the health of the target.

The monitor periodically checks the abort signal. Once set, it calls the adaptor’s stop() method to stop the running of the target.

The monitor also periodically checks whether the target is already stopped (by calling the is_stopped method). If the target is stopped, the monitor will call the specified target_stopped_cb.

Parameters:
  • fl_ctx – FL context

  • target_stopped_cb – the callback function to be called when the target is stopped.

Returns: None

set_abort_signal(abort_signal: Signal)[source]

Called by XGB Controller/Executor to set the abort_signal.

The abort_signal is assigned by FLARE’s XGB Controller/Executor. It is used by the Controller/Executor to tell the adaptor that the job has been aborted.

Parameters:

abort_signal – the abort signal assigned by the caller.

Returns: None

set_runner(runner: AppRunner)[source]

Set the App Runner that will be used to run app processing logic. Note that the adaptor is only responsible for starting the runner appropriately (in a thread or in a separate process).

Parameters:

runner – the runner to be set

Returns: None

abstract start(fl_ctx: FLContext)[source]

Called by XGB Controller/Executor to start the target. If any error occurs when starting the target, this method should raise an exception.

Parameters:

fl_ctx – the FL context.

Returns: None

start_runner(run_ctx: dict, fl_ctx: FLContext)[source]
abstract stop(fl_ctx: FLContext)[source]

Called by XGB Controller/Executor to stop the target. If any error occurs when stopping the target, this method should raise an exception.

Parameters:

fl_ctx – the FL context.

Returns: None

stop_runner()[source]