nvflare.app_opt.flower.applet module

class FlowerClientApplet(extra_env: dict | None = None)[source]

Bases: CLIApplet

Constructor of FlowerClientApplet, which extends CLIApplet.

get_command(ctx: dict) CommandDescriptor[source]

Implementation of the get_command method required by the super class CLIApplet. It returns the CLI command for starting Flower’s client app, as well as the full path of the log file for the client app.

Parameters:

ctx – the applet run context

Returns: CLI command for starting client app and name of log file.

class FlowerServerApplet(database: str, superlink_ready_timeout: float, server_app_args: list | None = None)[source]

Bases: Applet

Constructor of FlowerServerApplet.

Parameters:
  • database – database spec to be used by the server app

  • superlink_ready_timeout – how long to wait for the superlink process to become ready

  • server_app_args – an optional list that contains additional command args passed to flower server app

is_stopped() -> (<class 'bool'>, <class 'int'>)[source]

Check whether the server applet is already stopped

Returns: a tuple of: whether the applet is stopped, exit code if stopped.

Note: if either superlink or server app is stopped, we treat the applet as stopped.

start(app_ctx: dict)[source]

Start the applet.

Flower requires two processes for server application:

superlink: this process is responsible for client communication server_app: this process performs server side of training.

We start the superlink first, and wait for it to become ready, then start the server app. Each process will have its own log file in the job’s run dir. The superlink’s log file is named “superlink_log.txt”. The server app’s log file is named “server_app_log.txt”.

Parameters:

app_ctx – the run context of the applet.

Returns:

stop(timeout=0.0) int[source]

Stop the server applet’s superlink and server app processes.

Parameters:

timeout – how long to wait before forcefully stopping (kill) the process.

Note: we always stop the process immediately - do not wait for the process to stop itself.

Returns: