flwr-nightly 1.19.0.dev20250523__py3-none-any.whl → 1.19.0.dev20250524__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,174 @@
1
+ # Copyright 2025 Flower Labs GmbH. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+ """Flower server app."""
16
+
17
+
18
+ import sys
19
+ from logging import INFO
20
+ from typing import Optional
21
+
22
+ from flwr.common import GRPC_MAX_MESSAGE_LENGTH, EventType, event
23
+ from flwr.common.address import parse_address
24
+ from flwr.common.constant import FLEET_API_GRPC_BIDI_DEFAULT_ADDRESS
25
+ from flwr.common.exit_handlers import register_exit_handlers
26
+ from flwr.common.logger import log, warn_deprecated_feature
27
+ from flwr.server.client_manager import ClientManager
28
+ from flwr.server.history import History
29
+ from flwr.server.server import Server, init_defaults, run_fl
30
+ from flwr.server.server_config import ServerConfig
31
+ from flwr.server.strategy import Strategy
32
+ from flwr.server.superlink.fleet.grpc_bidi.grpc_server import start_grpc_server
33
+
34
+
35
+ def start_server( # pylint: disable=too-many-arguments,too-many-locals
36
+ *,
37
+ server_address: str = FLEET_API_GRPC_BIDI_DEFAULT_ADDRESS,
38
+ server: Optional[Server] = None,
39
+ config: Optional[ServerConfig] = None,
40
+ strategy: Optional[Strategy] = None,
41
+ client_manager: Optional[ClientManager] = None,
42
+ grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,
43
+ certificates: Optional[tuple[bytes, bytes, bytes]] = None,
44
+ ) -> History:
45
+ """Start a Flower server using the gRPC transport layer.
46
+
47
+ Warning
48
+ -------
49
+ This function is deprecated since 1.13.0. Use the :code:`flower-superlink` command
50
+ instead to start a SuperLink.
51
+
52
+ Parameters
53
+ ----------
54
+ server_address : Optional[str]
55
+ The IPv4 or IPv6 address of the server. Defaults to `"[::]:8080"`.
56
+ server : Optional[flwr.server.Server] (default: None)
57
+ A server implementation, either `flwr.server.Server` or a subclass
58
+ thereof. If no instance is provided, then `start_server` will create
59
+ one.
60
+ config : Optional[ServerConfig] (default: None)
61
+ Currently supported values are `num_rounds` (int, default: 1) and
62
+ `round_timeout` in seconds (float, default: None).
63
+ strategy : Optional[flwr.server.Strategy] (default: None).
64
+ An implementation of the abstract base class
65
+ `flwr.server.strategy.Strategy`. If no strategy is provided, then
66
+ `start_server` will use `flwr.server.strategy.FedAvg`.
67
+ client_manager : Optional[flwr.server.ClientManager] (default: None)
68
+ An implementation of the abstract base class
69
+ `flwr.server.ClientManager`. If no implementation is provided, then
70
+ `start_server` will use
71
+ `flwr.server.client_manager.SimpleClientManager`.
72
+ grpc_max_message_length : int (default: 536_870_912, this equals 512MB)
73
+ The maximum length of gRPC messages that can be exchanged with the
74
+ Flower clients. The default should be sufficient for most models.
75
+ Users who train very large models might need to increase this
76
+ value. Note that the Flower clients need to be started with the
77
+ same value (see `flwr.client.start_client`), otherwise clients will
78
+ not know about the increased limit and block larger messages.
79
+ certificates : Tuple[bytes, bytes, bytes] (default: None)
80
+ Tuple containing root certificate, server certificate, and private key
81
+ to start a secure SSL-enabled server. The tuple is expected to have
82
+ three bytes elements in the following order:
83
+
84
+ * CA certificate.
85
+ * server certificate.
86
+ * server private key.
87
+
88
+ Returns
89
+ -------
90
+ hist : flwr.server.history.History
91
+ Object containing training and evaluation metrics.
92
+
93
+ Examples
94
+ --------
95
+ Starting an insecure server::
96
+
97
+ start_server()
98
+
99
+ Starting a TLS-enabled server::
100
+
101
+ start_server(
102
+ certificates=(
103
+ Path("/crts/root.pem").read_bytes(),
104
+ Path("/crts/localhost.crt").read_bytes(),
105
+ Path("/crts/localhost.key").read_bytes()
106
+ )
107
+ )
108
+ """
109
+ msg = (
110
+ "flwr.server.start_server() is deprecated."
111
+ "\n\tInstead, use the `flower-superlink` CLI command to start a SuperLink "
112
+ "as shown below:"
113
+ "\n\n\t\t$ flower-superlink --insecure"
114
+ "\n\n\tTo view usage and all available options, run:"
115
+ "\n\n\t\t$ flower-superlink --help"
116
+ "\n\n\tUsing `start_server()` is deprecated."
117
+ )
118
+ warn_deprecated_feature(name=msg)
119
+
120
+ event(EventType.START_SERVER_ENTER)
121
+
122
+ # Parse IP address
123
+ parsed_address = parse_address(server_address)
124
+ if not parsed_address:
125
+ sys.exit(f"Server IP address ({server_address}) cannot be parsed.")
126
+ host, port, is_v6 = parsed_address
127
+ address = f"[{host}]:{port}" if is_v6 else f"{host}:{port}"
128
+
129
+ # Initialize server and server config
130
+ initialized_server, initialized_config = init_defaults(
131
+ server=server,
132
+ config=config,
133
+ strategy=strategy,
134
+ client_manager=client_manager,
135
+ )
136
+ log(
137
+ INFO,
138
+ "Starting Flower server, config: %s",
139
+ initialized_config,
140
+ )
141
+
142
+ # Start gRPC server
143
+ grpc_server = start_grpc_server(
144
+ client_manager=initialized_server.client_manager(),
145
+ server_address=address,
146
+ max_message_length=grpc_max_message_length,
147
+ certificates=certificates,
148
+ )
149
+ log(
150
+ INFO,
151
+ "Flower ECE: gRPC server running (%s rounds), SSL is %s",
152
+ initialized_config.num_rounds,
153
+ "enabled" if certificates is not None else "disabled",
154
+ )
155
+
156
+ # Graceful shutdown
157
+ register_exit_handlers(
158
+ event_type=EventType.START_SERVER_LEAVE,
159
+ exit_message="Flower server terminated gracefully.",
160
+ grpc_servers=[grpc_server],
161
+ )
162
+
163
+ # Start training
164
+ hist = run_fl(
165
+ server=initialized_server,
166
+ config=initialized_config,
167
+ )
168
+
169
+ # Stop the gRPC server
170
+ grpc_server.stop(grace=1)
171
+
172
+ event(EventType.START_SERVER_LEAVE)
173
+
174
+ return hist
flwr/server/__init__.py CHANGED
@@ -15,9 +15,9 @@
15
15
  """Flower server."""
16
16
 
17
17
 
18
+ from ..compat.server.app import start_server as start_server # Deprecated
18
19
  from . import strategy
19
20
  from . import workflow as workflow
20
- from .app import start_server as start_server
21
21
  from .client_manager import ClientManager as ClientManager
22
22
  from .client_manager import SimpleClientManager as SimpleClientManager
23
23
  from .compat import LegacyContext as LegacyContext
flwr/server/app.py CHANGED
@@ -43,7 +43,6 @@ from flwr.common.constant import (
43
43
  AUTH_TYPE_YAML_KEY,
44
44
  CLIENT_OCTET,
45
45
  EXEC_API_DEFAULT_SERVER_ADDRESS,
46
- FLEET_API_GRPC_BIDI_DEFAULT_ADDRESS,
47
46
  FLEET_API_GRPC_RERE_DEFAULT_ADDRESS,
48
47
  FLEET_API_REST_DEFAULT_ADDRESS,
49
48
  ISOLATION_MODE_PROCESS,
@@ -60,7 +59,7 @@ from flwr.common.event_log_plugin import EventLogWriterPlugin
60
59
  from flwr.common.exit import ExitCode, flwr_exit
61
60
  from flwr.common.exit_handlers import register_exit_handlers
62
61
  from flwr.common.grpc import generic_create_grpc_server
63
- from flwr.common.logger import log, warn_deprecated_feature
62
+ from flwr.common.logger import log
64
63
  from flwr.common.secure_aggregation.crypto.symmetric_encryption import (
65
64
  public_key_to_bytes,
66
65
  )
@@ -75,14 +74,8 @@ from flwr.supercore.object_store import ObjectStoreFactory
75
74
  from flwr.superexec.app import load_executor
76
75
  from flwr.superexec.exec_grpc import run_exec_api_grpc
77
76
 
78
- from .client_manager import ClientManager
79
- from .history import History
80
- from .server import Server, init_defaults, run_fl
81
- from .server_config import ServerConfig
82
- from .strategy import Strategy
83
77
  from .superlink.ffs.ffs_factory import FfsFactory
84
78
  from .superlink.fleet.grpc_adapter.grpc_adapter_servicer import GrpcAdapterServicer
85
- from .superlink.fleet.grpc_bidi.grpc_server import start_grpc_server
86
79
  from .superlink.fleet.grpc_rere.fleet_servicer import FleetServicer
87
80
  from .superlink.fleet.grpc_rere.server_interceptor import AuthenticateServerInterceptor
88
81
  from .superlink.linkstate import LinkStateFactory
@@ -124,148 +117,6 @@ except ImportError:
124
117
  )
125
118
 
126
119
 
127
- def start_server( # pylint: disable=too-many-arguments,too-many-locals
128
- *,
129
- server_address: str = FLEET_API_GRPC_BIDI_DEFAULT_ADDRESS,
130
- server: Optional[Server] = None,
131
- config: Optional[ServerConfig] = None,
132
- strategy: Optional[Strategy] = None,
133
- client_manager: Optional[ClientManager] = None,
134
- grpc_max_message_length: int = GRPC_MAX_MESSAGE_LENGTH,
135
- certificates: Optional[tuple[bytes, bytes, bytes]] = None,
136
- ) -> History:
137
- """Start a Flower server using the gRPC transport layer.
138
-
139
- Warning
140
- -------
141
- This function is deprecated since 1.13.0. Use the :code:`flower-superlink` command
142
- instead to start a SuperLink.
143
-
144
- Parameters
145
- ----------
146
- server_address : Optional[str]
147
- The IPv4 or IPv6 address of the server. Defaults to `"[::]:8080"`.
148
- server : Optional[flwr.server.Server] (default: None)
149
- A server implementation, either `flwr.server.Server` or a subclass
150
- thereof. If no instance is provided, then `start_server` will create
151
- one.
152
- config : Optional[ServerConfig] (default: None)
153
- Currently supported values are `num_rounds` (int, default: 1) and
154
- `round_timeout` in seconds (float, default: None).
155
- strategy : Optional[flwr.server.Strategy] (default: None).
156
- An implementation of the abstract base class
157
- `flwr.server.strategy.Strategy`. If no strategy is provided, then
158
- `start_server` will use `flwr.server.strategy.FedAvg`.
159
- client_manager : Optional[flwr.server.ClientManager] (default: None)
160
- An implementation of the abstract base class
161
- `flwr.server.ClientManager`. If no implementation is provided, then
162
- `start_server` will use
163
- `flwr.server.client_manager.SimpleClientManager`.
164
- grpc_max_message_length : int (default: 536_870_912, this equals 512MB)
165
- The maximum length of gRPC messages that can be exchanged with the
166
- Flower clients. The default should be sufficient for most models.
167
- Users who train very large models might need to increase this
168
- value. Note that the Flower clients need to be started with the
169
- same value (see `flwr.client.start_client`), otherwise clients will
170
- not know about the increased limit and block larger messages.
171
- certificates : Tuple[bytes, bytes, bytes] (default: None)
172
- Tuple containing root certificate, server certificate, and private key
173
- to start a secure SSL-enabled server. The tuple is expected to have
174
- three bytes elements in the following order:
175
-
176
- * CA certificate.
177
- * server certificate.
178
- * server private key.
179
-
180
- Returns
181
- -------
182
- hist : flwr.server.history.History
183
- Object containing training and evaluation metrics.
184
-
185
- Examples
186
- --------
187
- Starting an insecure server::
188
-
189
- start_server()
190
-
191
- Starting a TLS-enabled server::
192
-
193
- start_server(
194
- certificates=(
195
- Path("/crts/root.pem").read_bytes(),
196
- Path("/crts/localhost.crt").read_bytes(),
197
- Path("/crts/localhost.key").read_bytes()
198
- )
199
- )
200
- """
201
- msg = (
202
- "flwr.server.start_server() is deprecated."
203
- "\n\tInstead, use the `flower-superlink` CLI command to start a SuperLink "
204
- "as shown below:"
205
- "\n\n\t\t$ flower-superlink --insecure"
206
- "\n\n\tTo view usage and all available options, run:"
207
- "\n\n\t\t$ flower-superlink --help"
208
- "\n\n\tUsing `start_server()` is deprecated."
209
- )
210
- warn_deprecated_feature(name=msg)
211
-
212
- event(EventType.START_SERVER_ENTER)
213
-
214
- # Parse IP address
215
- parsed_address = parse_address(server_address)
216
- if not parsed_address:
217
- sys.exit(f"Server IP address ({server_address}) cannot be parsed.")
218
- host, port, is_v6 = parsed_address
219
- address = f"[{host}]:{port}" if is_v6 else f"{host}:{port}"
220
-
221
- # Initialize server and server config
222
- initialized_server, initialized_config = init_defaults(
223
- server=server,
224
- config=config,
225
- strategy=strategy,
226
- client_manager=client_manager,
227
- )
228
- log(
229
- INFO,
230
- "Starting Flower server, config: %s",
231
- initialized_config,
232
- )
233
-
234
- # Start gRPC server
235
- grpc_server = start_grpc_server(
236
- client_manager=initialized_server.client_manager(),
237
- server_address=address,
238
- max_message_length=grpc_max_message_length,
239
- certificates=certificates,
240
- )
241
- log(
242
- INFO,
243
- "Flower ECE: gRPC server running (%s rounds), SSL is %s",
244
- initialized_config.num_rounds,
245
- "enabled" if certificates is not None else "disabled",
246
- )
247
-
248
- # Graceful shutdown
249
- register_exit_handlers(
250
- event_type=EventType.START_SERVER_LEAVE,
251
- exit_message="Flower server terminated gracefully.",
252
- grpc_servers=[grpc_server],
253
- )
254
-
255
- # Start training
256
- hist = run_fl(
257
- server=initialized_server,
258
- config=initialized_config,
259
- )
260
-
261
- # Stop the gRPC server
262
- grpc_server.stop(grace=1)
263
-
264
- event(EventType.START_SERVER_LEAVE)
265
-
266
- return hist
267
-
268
-
269
120
  # pylint: disable=too-many-branches, too-many-locals, too-many-statements
270
121
  def run_superlink() -> None:
271
122
  """Run Flower SuperLink (ServerAppIo API and Fleet API)."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: flwr-nightly
3
- Version: 1.19.0.dev20250523
3
+ Version: 1.19.0.dev20250524
4
4
  Summary: Flower: A Friendly Federated AI Framework
5
5
  License: Apache-2.0
6
6
  Keywords: Artificial Intelligence,Federated AI,Federated Analytics,Federated Evaluation,Federated Learning,Flower,Machine Learning
@@ -161,6 +161,7 @@ flwr/compat/client/grpc_client/__init__.py,sha256=MDOckOODn-FJnkkFEfb2JO-2G97wrB
161
161
  flwr/compat/client/grpc_client/connection.py,sha256=xAyvcTVr7bkwUfR5P3D_LKlZYiyySpt5sEwORA1h8Gc,9189
162
162
  flwr/compat/common/__init__.py,sha256=OMnKw4ad0qYMSIA9LZRa2gOkhSOXwAZCpAHnBQE_hFc,746
163
163
  flwr/compat/server/__init__.py,sha256=TGVSoOTuf5T5JHUVrK5wuorQF7L6Wvdem8B4uufvMJY,746
164
+ flwr/compat/server/app.py,sha256=_lIe7Q4KUk-olq9PYBxIsO3UaOn6N92CWgWQ4hRcAZw,6490
164
165
  flwr/compat/simulation/__init__.py,sha256=MApGa-tysDDw34iSdxZ7TWOKtGJM-z3i8fIRJa0qbZ8,750
165
166
  flwr/proto/__init__.py,sha256=S3VbQzVwNC1P-3_9EdrXuwgptO-BVuuAe20Z_OUc1cQ,683
166
167
  flwr/proto/clientappio_pb2.py,sha256=aroQDv0D2GquQ5Ujqml7n7l6ObZoXqMvDa0XVO-_8Cc,3703
@@ -224,8 +225,8 @@ flwr/proto/transport_pb2.pyi,sha256=ipHQ03eFBqsxtAuAVefZ2lVr04BZ4YifJCS2eauNmy8,
224
225
  flwr/proto/transport_pb2_grpc.py,sha256=vLN3EHtx2aEEMCO4f1Upu-l27BPzd3-5pV-u8wPcosk,2598
225
226
  flwr/proto/transport_pb2_grpc.pyi,sha256=AGXf8RiIiW2J5IKMlm_3qT3AzcDa4F3P5IqUjve_esA,766
226
227
  flwr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
227
- flwr/server/__init__.py,sha256=e5PjIYUkzaQpcrUrvgb_6rDGzNqw1RfRsggdHlhfeyY,1569
228
- flwr/server/app.py,sha256=cWJuEhnizI_7XJObT8dTm6X8yvY-A9Idp6Co8jonSmU,34150
228
+ flwr/server/__init__.py,sha256=LQQHiuL2jy7TpNaKastRdGsexlxSt5ZWAQNVqitDnrY,1598
229
+ flwr/server/app.py,sha256=VLvatu0jNb7FvgnUt_kc21jzdvdVfBAwpXolwI2jINQ,28737
229
230
  flwr/server/client_manager.py,sha256=5jCGavVli7XdupvWWo7ru3PdFTlRU8IGvHFSSoUVLRs,6227
230
231
  flwr/server/client_proxy.py,sha256=sv0E9AldBYOvc3pusqFh-GnyreeMfsXQ1cuTtxTq_wY,2399
231
232
  flwr/server/compat/__init__.py,sha256=0IsttWvY15qO98_1GyzVC-vR1e_ZPXOdu2qUlOkYMPE,886
@@ -352,7 +353,7 @@ flwr/supernode/nodestate/in_memory_nodestate.py,sha256=brV7TMMzS93tXk6ntpoYjtPK5
352
353
  flwr/supernode/nodestate/nodestate.py,sha256=-LAjZOnS7VyHC05ll3b31cYDjwAt6l4WmYt7duVLRKk,1024
353
354
  flwr/supernode/nodestate/nodestate_factory.py,sha256=UYTDCcwK_baHUmkzkJDxL0UEqvtTfOMlQRrROMCd0Xo,1430
354
355
  flwr/supernode/start_client_internal.py,sha256=4z9qtwT7ZwNwahpX1SRfuaoYw1HCICPFUvjPBLHgsA0,18806
355
- flwr_nightly-1.19.0.dev20250523.dist-info/METADATA,sha256=9-WhjxFCBkKSfaVdbgEMccDDHsMsc7yc6YOxyPGARiQ,15910
356
- flwr_nightly-1.19.0.dev20250523.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
357
- flwr_nightly-1.19.0.dev20250523.dist-info/entry_points.txt,sha256=08k99PaHg3Wr6W49rFXYtjmgcfIdpFLNeu6O0bXDYnU,370
358
- flwr_nightly-1.19.0.dev20250523.dist-info/RECORD,,
356
+ flwr_nightly-1.19.0.dev20250524.dist-info/METADATA,sha256=wciHfcEhok_S6e8SueDdMCIL-QcOhUZGUI46AyGWPak,15910
357
+ flwr_nightly-1.19.0.dev20250524.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
358
+ flwr_nightly-1.19.0.dev20250524.dist-info/entry_points.txt,sha256=08k99PaHg3Wr6W49rFXYtjmgcfIdpFLNeu6O0bXDYnU,370
359
+ flwr_nightly-1.19.0.dev20250524.dist-info/RECORD,,