Flower CLI 参考

flwr CLI

flwr

flwr is the Flower command line interface.

flwr [OPTIONS] COMMAND [ARGS]...

Options

--install-completion

Install completion for the current shell.

--show-completion

Show completion for the current shell, to copy it or customize the installation.

build

Build a Flower App into a Flower App Bundle (FAB).

You can run flwr build without any arguments to bundle the app located in the current directory. Alternatively, you can you can specify a path using the --app option to bundle an app located at the provided path. For example:

flwr build --app ./apps/flower-hello-world.

flwr build [OPTIONS]

Options

--app <app>

Path of the Flower App to bundle into a FAB

install

Install a Flower App Bundle.

It can be ran with a single FAB file argument:

flwr install ./target_project.fab

The target install directory can be specified with --flwr-dir:

flwr install ./target_project.fab --flwr-dir ./docs/flwr

This will install target_project to ./docs/flwr/. By default, flwr-dir is equal to:

  • $FLWR_HOME/ if $FLWR_HOME is defined

  • $XDG_DATA_HOME/.flwr/ if $XDG_DATA_HOME is defined

  • $HOME/.flwr/ in all other cases

flwr install [OPTIONS] source

Options

--flwr-dir <flwr_dir>

The desired install path.

Arguments

source

Optional argument

The source FAB file to install.

log

Get logs from a Flower project run.

flwr log [OPTIONS] RUN_ID [APP] [FEDERATION]

Options

--stream, --show

Flag to stream or print logs from the Flower run

Default:

True

Arguments

RUN_ID

Required argument

The Flower run ID to query

APP

Optional argument

Path of the Flower project to run

FEDERATION

Optional argument

Name of the federation to run the app on

new

Create new Flower App.

flwr new [OPTIONS] [APP_NAME]

Options

--framework <framework>

The ML framework to use

Options:

PyTorch | TensorFlow | sklearn | HuggingFace | JAX | MLX | NumPy | FlowerTune | Flower Baseline

--username <username>

The Flower username of the author

Arguments

APP_NAME

Optional argument

The name of the Flower App

run

Run Flower App.

flwr run [OPTIONS] [APP] [FEDERATION]

Options

-c, --run-config <config_overrides>

Override configuration key-value pairs, should be of the format:

--run-config 'key1="value1" key2="value2"' --run-config 'key3="value3"'

Note that key1, key2, and key3 in this example need to exist inside the pyproject.toml in order to be properly overriden.

--stream

Use --stream with flwr run to display logs; logs are not streamed by default.

Default:

False

Arguments

APP

Optional argument

Path of the Flower App to run.

FEDERATION

Optional argument

Name of the federation to run the app on.

flower-simulation

Start a Flower simulation

usage: flower-simulation [-h] [--app APP] [--server-app SERVER_APP]
                         [--client-app CLIENT_APP] --num-supernodes
                         NUM_SUPERNODES [--run-config RUN_CONFIG]
                         [--backend BACKEND] [--backend-config BACKEND_CONFIG]
                         [--enable-tf-gpu-growth] [--delay-start DELAY_START]
                         [--verbose] [--app-dir APP_DIR] [--flwr-dir FLWR_DIR]
                         [--run-id RUN_ID]

Named Arguments

--app

Path to a directory containing a FAB-like structure with a pyproject.toml.

--server-app

(DEPRECATED: use --app instead) For example: server:app or project.package.module:wrapper.app

--client-app

(DEPRECATED: use --app instead) For example: client:app or project.package.module:wrapper.app

--num-supernodes

Number of simulated SuperNodes.

--run-config

Override configuration key-value pairs.

--backend

Simulation backend that executes the ClientApp.

Default: "ray"

--backend-config

A JSON formatted stream, e.g '{"<keyA>":<value>, "<keyB>":<value>}' to configure a backend. Values supported in <value> are those included by flwr.common.typing.ConfigsRecordValues.

Default: "{}"

--enable-tf-gpu-growth

Enables GPU growth on the main thread. This is desirable if you make use of a TensorFlow model on your ServerApp while having your ClientApp running on the same GPU. Without enabling this, you might encounter an out-of-memory error because TensorFlow by default allocates all GPU memory.Read more about how tf.config.experimental.set_memory_growth() works in the TensorFlow documentation: https://www.tensorflow.org/api/stable.

Default: False

--delay-start

Buffer time (in seconds) to delay the start the simulation engine after the ServerApp, which runs in a separate thread, has been launched.

Default: 3

--verbose

When unset, only INFO, WARNING and ERROR log messages will be shown. If set, DEBUG-level logs will be displayed.

Default: False

--app-dir

Add specified directory to the PYTHONPATH and loadClientApp and ServerApp from there. Default: current working directory.

Default: ""

--flwr-dir
The path containing installed Flower Apps.

By default, this value is equal to:

  • $FLWR_HOME/ if $FLWR_HOME is defined

  • $XDG_DATA_HOME/.flwr/ if $XDG_DATA_HOME is defined

  • $HOME/.flwr/ in all other cases

--run-id

Sets the ID of the run started by the Simulation Engine.

flower-supernode

Start a Flower SuperNode

usage: flower-supernode [-h] [--insecure]
                        [--grpc-rere | --grpc-adapter | --rest]
                        [--root-certificates ROOT_CERT] [--server SERVER]
                        [--superlink SUPERLINK] [--max-retries MAX_RETRIES]
                        [--max-wait-time MAX_WAIT_TIME]
                        [--auth-supernode-private-key AUTH_SUPERNODE_PRIVATE_KEY]
                        [--auth-supernode-public-key AUTH_SUPERNODE_PUBLIC_KEY]
                        [--node-config NODE_CONFIG] [--flwr-dir FLWR_DIR]
                        [--isolation {subprocess,process}]
                        [--supernode-address SUPERNODE_ADDRESS]
                        [app]

Positional Arguments

app

Specify the path of the Flower App to load and run the ClientApp. The pyproject.toml file must be located in the root of this path. When this argument is provided, the SuperNode will exclusively respond to messages from the corresponding ServerApp by matching the FAB ID and FAB version. An error will be raised if a message is received from any other ServerApp.

Named Arguments

--insecure

Run the client without HTTPS. By default, the client runs with HTTPS enabled. Use this flag only if you understand the risks.

Default: False

--grpc-rere

Use grpc-rere as a transport layer for the client.

Default: "grpc-rere"

--grpc-adapter

Use grpc-adapter as a transport layer for the client.

--rest

Use REST as a transport layer for the client.

--root-certificates

Specifies the path to the PEM-encoded root certificate file for establishing secure HTTPS connections.

--server

Server address

Default: "0.0.0.0:9092"

--superlink

SuperLink Fleet API (gRPC-rere) address (IPv4, IPv6, or a domain name)

Default: "0.0.0.0:9092"

--max-retries

The maximum number of times the client will try to reconnect to theSuperLink before giving up in case of a connection error. By default,it is set to None, meaning there is no limit to the number of tries.

--max-wait-time

The maximum duration before the client stops trying toconnect to the SuperLink in case of connection error. By default, itis set to None, meaning there is no limit to the total time.

--auth-supernode-private-key

The SuperNode's private key (as a path str) to enable authentication.

--auth-supernode-public-key

The SuperNode's public key (as a path str) to enable authentication.

--node-config

A space separated list of key/value pairs (separated by =) to configure the SuperNode. E.g. --node-config 'key1="value1" partition-id=0 num-partitions=100'

--flwr-dir
The path containing installed Flower Apps.

By default, this value is equal to:

  • $FLWR_HOME/ if $FLWR_HOME is defined

  • $XDG_DATA_HOME/.flwr/ if $XDG_DATA_HOME is defined

  • $HOME/.flwr/ in all other cases

--isolation

Possible choices: subprocess, process

Isolation mode when running ClientApp (optional, possible values: subprocess, process). By default, ClientApp runs in the same process that executes the SuperNode. Use subprocess to configure SuperNode to run ClientApp in a subprocess. Use process to indicate that a separate independent process gets created outside of SuperNode.

--supernode-address

Set the SuperNode gRPC server address. Defaults to 0.0.0.0:9094.

Default: "0.0.0.0:9094"

flower-server-app

Note

Note that since version 1.11.0, flower-server-app no longer supports passing a reference to a ServerApp attribute. Instead, you need to pass the path to Flower app via the argument --app. This is the path to a directory containing a pyproject.toml. You can create a valid Flower app by executing flwr new and following the prompt.

Start a Flower server app

usage: flower-server-app [-h] [--insecure] [--verbose]
                         [--root-certificates ROOT_CERT] [--server SERVER]
                         [--superlink SUPERLINK] [--run-id RUN_ID]
                         [--flwr-dir FLWR_DIR]
                         [app]

Positional Arguments

app

Load and run the ServerApp from the specified Flower App path. The pyproject.toml file must be located in the root of this path.

Named Arguments

--insecure

Run the ServerApp without HTTPS. By default, the app runs with HTTPS enabled. Use this flag only if you understand the risks.

Default: False

--verbose

Set the logging to DEBUG.

Default: False

--root-certificates

Specifies the path to the PEM-encoded root certificate file for establishing secure HTTPS connections.

--server

Server address

Default: "0.0.0.0:9091"

--superlink

SuperLink Driver API (gRPC-rere) address (IPv4, IPv6, or a domain name)

Default: "0.0.0.0:9091"

--run-id

The identifier of the run.

--flwr-dir
The path containing installed Flower Apps.

By default, this value is equal to:

  • $FLWR_HOME/ if $FLWR_HOME is defined

  • $XDG_DATA_HOME/.flwr/ if $XDG_DATA_HOME is defined

  • $HOME/.flwr/ in all other cases

flower-superexec

Start a Flower SuperExec

usage: flower-superexec [-h] [--address ADDRESS] [--executor EXECUTOR]
                        [--executor-dir EXECUTOR_DIR]
                        [--executor-config EXECUTOR_CONFIG] [--insecure]
                        [--ssl-certfile SSL_CERTFILE]
                        [--ssl-keyfile SSL_KEYFILE]
                        [--ssl-ca-certfile SSL_CA_CERTFILE]

Named Arguments

--address

SuperExec (gRPC) server address (IPv4, IPv6, or a domain name)

Default: "0.0.0.0:9093"

--executor

For example: deployment:exec or project.package.module:wrapper.exec.

Default: "flwr.superexec.deployment:executor"

--executor-dir

The directory for the executor.

Default: "."

--executor-config

Key-value pairs for the executor config, separated by spaces. For example:

--executor-config 'superlink="superlink:9091" root-certificates="certificates/superlink-ca.crt"'

--insecure

Run the SuperExec without HTTPS, regardless of whether certificate paths are provided. By default, the server runs with HTTPS enabled. Use this flag only if you understand the risks.

Default: False

--ssl-certfile

SuperExec server SSL certificate file (as a path str) to create a secure connection.

--ssl-keyfile

SuperExec server SSL private key file (as a path str) to create a secure connection.

--ssl-ca-certfile

SuperExec server SSL CA certificate file (as a path str) to create a secure connection.