ServerApp

class ServerApp(server: Server | None = None, config: ServerConfig | None = None, strategy: Strategy | None = None, client_manager: ClientManager | None = None, server_fn: Callable[[Context], ServerAppComponents] | None = None)[소스]

기반 클래스: object

Flower 서버.

예제

Use the ServerApp with an existing Strategy:

>>> def server_fn(context: Context):
>>>     server_config = ServerConfig(num_rounds=3)
>>>     strategy = FedAvg()
>>>     return ServerAppComponents(
>>>         strategy=strategy,
>>>         server_config=server_config,
>>>     )
>>>
>>> app = ServerApp(server_fn=server_fn)

Use the ServerApp with a custom main function:

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

메소드

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")