ServerApp#

class ServerApp(server: Server | None = None, config: ServerConfig | None = None, strategy: Strategy | None = None, client_manager: ClientManager | None = None)[源代码]#

基类:object

Flower ServerApp.

示例

Use the ServerApp with an existing Strategy:

>>> server_config = ServerConfig(num_rounds=3)
>>> strategy = FedAvg()
>>>
>>> app = ServerApp()
>>>     server_config=server_config,
>>>     strategy=strategy,
>>> )

Use the ServerApp with a custom main function:

>>> app = ServerApp()
>>>
>>> @app.main()
>>> def main(driver: Driver, context: Context) -> None:
>>>    print("ServerApp running")

Methods

main()

Return a decorator that registers the main fn with the server app.

main() Callable[[Callable[[Driver, Context], None]], Callable[[Driver, Context], None]][源代码]#

Return a decorator that registers the main fn with the server app.

示例

>>> app = ServerApp()
>>>
>>> @app.main()
>>> def main(driver: Driver, context: Context) -> None:
>>>    print("ServerApp running")