nvflare.app_opt.flower.recipe module
- class FlowerRecipe(flower_content: str | None = None, flower_app_path: str | None = None, name: str = 'flower_job', min_clients: int = 1, mandatory_clients: list[str] | None = None, database: str = '', superlink_ready_timeout: float = 10.0, configure_task_timeout=10, start_task_timeout=10, max_client_op_interval: float = 90.0, progress_timeout: float = 3600.0, per_msg_timeout=10.0, tx_timeout=100.0, client_shutdown_timeout=5.0, extra_env: dict | None = None, run_config: dict | None = None, allow_runtime_dependency_installation: bool = False)[source]
Bases:
RecipeRecipe class for Flower federated learning using NVFlare.
This class provides a high-level interface for configuring Flower federated learning jobs. It wraps the FlowerJob and provides a recipe-based interface for easier job configuration and execution.
Enables metric streaming and use of client API by default.
- Flower CLI compatibility:
This recipe requires
flwr>=1.26. The integration uses Flower Configuration under$FLWR_HOME/config.tomland the newer SuperLink-based CLI workflow.- Example usage:
```python recipe = FlowerRecipe(
name=”my_flower_job”, flower_content=”/path/to/flower/content”, min_clients=2, stream_metrics=True
)
# Pre-deployed mode (no BYOC needed): recipe = FlowerRecipe(
name=”my_flower_job”, flower_app_path=”local/custom/my_app”, min_clients=2,
- Parameters:
flower_content (str, optional) – Local directory path containing Flower app code (BYOC mode).
flower_app_path (str, optional) – Relative path to pre-deployed Flower app under workspace’s local/custom/ directory (pre-deployed mode, no BYOC needed). The server distributes the app to clients via Flower’s FAB mechanism.
name (str) – Name of the job. Defaults to “flower_job”.
min_clients (int, optional) – The minimum number of clients for the job. Defaults to 1.
mandatory_clients (List[str], optional) – List of mandatory clients for the job. Defaults to None.
database (str, optional) – Database string. Defaults to “”.
superlink_ready_timeout (float, optional) – Timeout for the superlink to be ready. Defaults to 10.0 seconds.
configure_task_timeout (float, optional) – Timeout for configuring the task. Defaults to Constant.CONFIG_TASK_TIMEOUT.
start_task_timeout (float, optional) – Timeout for starting the task. Defaults to Constant.START_TASK_TIMEOUT.
max_client_op_interval (float, optional) – Maximum interval between client operations. Defaults to Constant.MAX_CLIENT_OP_INTERVAL.
progress_timeout (float, optional) – Timeout for workflow progress. Defaults to Constant.WORKFLOW_PROGRESS_TIMEOUT.
per_msg_timeout (float, optional) – Timeout for receiving individual messages. Defaults to 10.0 seconds.
tx_timeout (float, optional) – Timeout for transmitting data. Defaults to 100.0 seconds.
client_shutdown_timeout (float, optional) – Timeout for client shutdown. Defaults to 5.0 seconds.
extra_env (dict, optional) – optional extra env variables to be passed to Flower client.
run_config (dict, optional) – optional dict for flwr run –run-config arguments.
allow_runtime_dependency_installation (bool, optional) – whether to allow dynamic dependency installation (only flwr>=1.29). Defaults to False.
Initialize the FlowerRecipe.
Creates a FlowerJob and wraps it in the Recipe interface.