flwr-nightly 1.8.0.dev20240315__py3-none-any.whl → 1.15.0.dev20250114__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. flwr/cli/app.py +16 -2
  2. flwr/cli/build.py +181 -0
  3. flwr/cli/cli_user_auth_interceptor.py +90 -0
  4. flwr/cli/config_utils.py +343 -0
  5. flwr/cli/example.py +4 -1
  6. flwr/cli/install.py +253 -0
  7. flwr/cli/log.py +182 -0
  8. flwr/{server/superlink/state → cli/login}/__init__.py +4 -10
  9. flwr/cli/login/login.py +88 -0
  10. flwr/cli/ls.py +327 -0
  11. flwr/cli/new/__init__.py +1 -0
  12. flwr/cli/new/new.py +210 -66
  13. flwr/cli/new/templates/app/.gitignore.tpl +163 -0
  14. flwr/cli/new/templates/app/LICENSE.tpl +202 -0
  15. flwr/cli/new/templates/app/README.baseline.md.tpl +127 -0
  16. flwr/cli/new/templates/app/README.flowertune.md.tpl +66 -0
  17. flwr/cli/new/templates/app/README.md.tpl +16 -32
  18. flwr/cli/new/templates/app/code/__init__.baseline.py.tpl +1 -0
  19. flwr/cli/new/templates/app/code/__init__.py.tpl +1 -1
  20. flwr/cli/new/templates/app/code/client.baseline.py.tpl +58 -0
  21. flwr/cli/new/templates/app/code/client.huggingface.py.tpl +55 -0
  22. flwr/cli/new/templates/app/code/client.jax.py.tpl +50 -0
  23. flwr/cli/new/templates/app/code/client.mlx.py.tpl +73 -0
  24. flwr/cli/new/templates/app/code/client.numpy.py.tpl +7 -7
  25. flwr/cli/new/templates/app/code/client.pytorch.py.tpl +30 -21
  26. flwr/cli/new/templates/app/code/client.sklearn.py.tpl +63 -0
  27. flwr/cli/new/templates/app/code/client.tensorflow.py.tpl +57 -1
  28. flwr/cli/new/templates/app/code/dataset.baseline.py.tpl +36 -0
  29. flwr/cli/new/templates/app/code/flwr_tune/__init__.py +15 -0
  30. flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl +126 -0
  31. flwr/cli/new/templates/app/code/flwr_tune/dataset.py.tpl +87 -0
  32. flwr/cli/new/templates/app/code/flwr_tune/models.py.tpl +78 -0
  33. flwr/cli/new/templates/app/code/flwr_tune/server_app.py.tpl +94 -0
  34. flwr/cli/new/templates/app/code/flwr_tune/strategy.py.tpl +83 -0
  35. flwr/cli/new/templates/app/code/model.baseline.py.tpl +80 -0
  36. flwr/cli/new/templates/app/code/server.baseline.py.tpl +46 -0
  37. flwr/cli/new/templates/app/code/server.huggingface.py.tpl +38 -0
  38. flwr/cli/new/templates/app/code/server.jax.py.tpl +26 -0
  39. flwr/cli/new/templates/app/code/server.mlx.py.tpl +31 -0
  40. flwr/cli/new/templates/app/code/server.numpy.py.tpl +22 -9
  41. flwr/cli/new/templates/app/code/server.pytorch.py.tpl +21 -18
  42. flwr/cli/new/templates/app/code/server.sklearn.py.tpl +36 -0
  43. flwr/cli/new/templates/app/code/server.tensorflow.py.tpl +29 -1
  44. flwr/cli/new/templates/app/code/strategy.baseline.py.tpl +1 -0
  45. flwr/cli/new/templates/app/code/task.huggingface.py.tpl +102 -0
  46. flwr/cli/new/templates/app/code/task.jax.py.tpl +57 -0
  47. flwr/cli/new/templates/app/code/task.mlx.py.tpl +102 -0
  48. flwr/cli/new/templates/app/code/task.numpy.py.tpl +7 -0
  49. flwr/cli/new/templates/app/code/task.pytorch.py.tpl +29 -24
  50. flwr/cli/new/templates/app/code/task.sklearn.py.tpl +67 -0
  51. flwr/cli/new/templates/app/code/task.tensorflow.py.tpl +53 -0
  52. flwr/cli/new/templates/app/code/utils.baseline.py.tpl +1 -0
  53. flwr/cli/new/templates/app/pyproject.baseline.toml.tpl +138 -0
  54. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +68 -0
  55. flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl +46 -0
  56. flwr/cli/new/templates/app/pyproject.jax.toml.tpl +35 -0
  57. flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +39 -0
  58. flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +25 -12
  59. flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +29 -14
  60. flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +35 -0
  61. flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +29 -14
  62. flwr/cli/run/__init__.py +1 -0
  63. flwr/cli/run/run.py +212 -34
  64. flwr/cli/stop.py +130 -0
  65. flwr/cli/utils.py +240 -5
  66. flwr/client/__init__.py +3 -2
  67. flwr/client/app.py +432 -255
  68. flwr/client/client.py +1 -11
  69. flwr/client/client_app.py +74 -13
  70. flwr/client/clientapp/__init__.py +22 -0
  71. flwr/client/clientapp/app.py +259 -0
  72. flwr/client/clientapp/clientappio_servicer.py +244 -0
  73. flwr/client/clientapp/utils.py +115 -0
  74. flwr/client/dpfedavg_numpy_client.py +7 -8
  75. flwr/client/grpc_adapter_client/__init__.py +15 -0
  76. flwr/client/grpc_adapter_client/connection.py +98 -0
  77. flwr/client/grpc_client/connection.py +21 -7
  78. flwr/client/grpc_rere_client/__init__.py +1 -1
  79. flwr/client/grpc_rere_client/client_interceptor.py +176 -0
  80. flwr/client/grpc_rere_client/connection.py +163 -56
  81. flwr/client/grpc_rere_client/grpc_adapter.py +167 -0
  82. flwr/client/heartbeat.py +74 -0
  83. flwr/client/message_handler/__init__.py +1 -1
  84. flwr/client/message_handler/message_handler.py +10 -11
  85. flwr/client/mod/__init__.py +5 -5
  86. flwr/client/mod/centraldp_mods.py +4 -2
  87. flwr/client/mod/comms_mods.py +5 -4
  88. flwr/client/mod/localdp_mod.py +10 -5
  89. flwr/client/mod/secure_aggregation/__init__.py +1 -1
  90. flwr/client/mod/secure_aggregation/secaggplus_mod.py +26 -26
  91. flwr/client/mod/utils.py +2 -4
  92. flwr/client/nodestate/__init__.py +26 -0
  93. flwr/client/nodestate/in_memory_nodestate.py +38 -0
  94. flwr/client/nodestate/nodestate.py +31 -0
  95. flwr/client/nodestate/nodestate_factory.py +38 -0
  96. flwr/client/numpy_client.py +8 -31
  97. flwr/client/rest_client/__init__.py +1 -1
  98. flwr/client/rest_client/connection.py +199 -176
  99. flwr/client/run_info_store.py +112 -0
  100. flwr/client/supernode/__init__.py +24 -0
  101. flwr/client/supernode/app.py +321 -0
  102. flwr/client/typing.py +1 -0
  103. flwr/common/__init__.py +17 -11
  104. flwr/common/address.py +47 -3
  105. flwr/common/args.py +153 -0
  106. flwr/common/auth_plugin/__init__.py +24 -0
  107. flwr/common/auth_plugin/auth_plugin.py +121 -0
  108. flwr/common/config.py +243 -0
  109. flwr/common/constant.py +132 -1
  110. flwr/common/context.py +32 -2
  111. flwr/common/date.py +22 -4
  112. flwr/common/differential_privacy.py +2 -2
  113. flwr/common/dp.py +2 -4
  114. flwr/common/exit_handlers.py +3 -3
  115. flwr/common/grpc.py +164 -5
  116. flwr/common/logger.py +230 -12
  117. flwr/common/message.py +191 -106
  118. flwr/common/object_ref.py +179 -44
  119. flwr/common/pyproject.py +1 -0
  120. flwr/common/record/__init__.py +2 -1
  121. flwr/common/record/configsrecord.py +58 -18
  122. flwr/common/record/metricsrecord.py +57 -17
  123. flwr/common/record/parametersrecord.py +88 -20
  124. flwr/common/record/recordset.py +153 -30
  125. flwr/common/record/typeddict.py +30 -55
  126. flwr/common/recordset_compat.py +31 -12
  127. flwr/common/retry_invoker.py +123 -30
  128. flwr/common/secure_aggregation/__init__.py +1 -1
  129. flwr/common/secure_aggregation/crypto/__init__.py +1 -1
  130. flwr/common/secure_aggregation/crypto/shamir.py +11 -11
  131. flwr/common/secure_aggregation/crypto/symmetric_encryption.py +68 -4
  132. flwr/common/secure_aggregation/ndarrays_arithmetic.py +17 -17
  133. flwr/common/secure_aggregation/quantization.py +8 -8
  134. flwr/common/secure_aggregation/secaggplus_constants.py +1 -1
  135. flwr/common/secure_aggregation/secaggplus_utils.py +10 -12
  136. flwr/common/serde.py +298 -19
  137. flwr/common/telemetry.py +65 -29
  138. flwr/common/typing.py +120 -19
  139. flwr/common/version.py +17 -3
  140. flwr/proto/clientappio_pb2.py +45 -0
  141. flwr/proto/clientappio_pb2.pyi +132 -0
  142. flwr/proto/clientappio_pb2_grpc.py +135 -0
  143. flwr/proto/clientappio_pb2_grpc.pyi +53 -0
  144. flwr/proto/exec_pb2.py +62 -0
  145. flwr/proto/exec_pb2.pyi +212 -0
  146. flwr/proto/exec_pb2_grpc.py +237 -0
  147. flwr/proto/exec_pb2_grpc.pyi +93 -0
  148. flwr/proto/fab_pb2.py +31 -0
  149. flwr/proto/fab_pb2.pyi +65 -0
  150. flwr/proto/fab_pb2_grpc.py +4 -0
  151. flwr/proto/fab_pb2_grpc.pyi +4 -0
  152. flwr/proto/fleet_pb2.py +42 -23
  153. flwr/proto/fleet_pb2.pyi +123 -1
  154. flwr/proto/fleet_pb2_grpc.py +170 -0
  155. flwr/proto/fleet_pb2_grpc.pyi +61 -0
  156. flwr/proto/grpcadapter_pb2.py +32 -0
  157. flwr/proto/grpcadapter_pb2.pyi +43 -0
  158. flwr/proto/grpcadapter_pb2_grpc.py +66 -0
  159. flwr/proto/grpcadapter_pb2_grpc.pyi +24 -0
  160. flwr/proto/log_pb2.py +29 -0
  161. flwr/proto/log_pb2.pyi +39 -0
  162. flwr/proto/log_pb2_grpc.py +4 -0
  163. flwr/proto/log_pb2_grpc.pyi +4 -0
  164. flwr/proto/message_pb2.py +41 -0
  165. flwr/proto/message_pb2.pyi +128 -0
  166. flwr/proto/message_pb2_grpc.py +4 -0
  167. flwr/proto/message_pb2_grpc.pyi +4 -0
  168. flwr/proto/node_pb2.py +1 -1
  169. flwr/proto/recordset_pb2.py +35 -33
  170. flwr/proto/recordset_pb2.pyi +40 -14
  171. flwr/proto/run_pb2.py +64 -0
  172. flwr/proto/run_pb2.pyi +268 -0
  173. flwr/proto/run_pb2_grpc.py +4 -0
  174. flwr/proto/run_pb2_grpc.pyi +4 -0
  175. flwr/proto/serverappio_pb2.py +52 -0
  176. flwr/proto/{driver_pb2.pyi → serverappio_pb2.pyi} +62 -20
  177. flwr/proto/serverappio_pb2_grpc.py +410 -0
  178. flwr/proto/serverappio_pb2_grpc.pyi +160 -0
  179. flwr/proto/simulationio_pb2.py +38 -0
  180. flwr/proto/simulationio_pb2.pyi +65 -0
  181. flwr/proto/simulationio_pb2_grpc.py +239 -0
  182. flwr/proto/simulationio_pb2_grpc.pyi +94 -0
  183. flwr/proto/task_pb2.py +7 -8
  184. flwr/proto/task_pb2.pyi +8 -5
  185. flwr/proto/transport_pb2.py +8 -8
  186. flwr/proto/transport_pb2.pyi +9 -6
  187. flwr/server/__init__.py +2 -10
  188. flwr/server/app.py +579 -402
  189. flwr/server/client_manager.py +8 -6
  190. flwr/server/compat/app.py +6 -62
  191. flwr/server/compat/app_utils.py +14 -8
  192. flwr/server/compat/driver_client_proxy.py +25 -58
  193. flwr/server/compat/legacy_context.py +5 -4
  194. flwr/server/driver/__init__.py +2 -0
  195. flwr/server/driver/driver.py +36 -131
  196. flwr/server/driver/grpc_driver.py +217 -81
  197. flwr/server/driver/inmemory_driver.py +182 -0
  198. flwr/server/history.py +28 -29
  199. flwr/server/run_serverapp.py +15 -126
  200. flwr/server/server.py +50 -44
  201. flwr/server/server_app.py +59 -10
  202. flwr/server/serverapp/__init__.py +22 -0
  203. flwr/server/serverapp/app.py +256 -0
  204. flwr/server/serverapp_components.py +52 -0
  205. flwr/server/strategy/__init__.py +2 -2
  206. flwr/server/strategy/aggregate.py +37 -23
  207. flwr/server/strategy/bulyan.py +9 -9
  208. flwr/server/strategy/dp_adaptive_clipping.py +25 -25
  209. flwr/server/strategy/dp_fixed_clipping.py +23 -22
  210. flwr/server/strategy/dpfedavg_adaptive.py +8 -8
  211. flwr/server/strategy/dpfedavg_fixed.py +13 -12
  212. flwr/server/strategy/fault_tolerant_fedavg.py +11 -11
  213. flwr/server/strategy/fedadagrad.py +9 -9
  214. flwr/server/strategy/fedadam.py +20 -10
  215. flwr/server/strategy/fedavg.py +16 -16
  216. flwr/server/strategy/fedavg_android.py +17 -17
  217. flwr/server/strategy/fedavgm.py +9 -9
  218. flwr/server/strategy/fedmedian.py +5 -5
  219. flwr/server/strategy/fedopt.py +6 -6
  220. flwr/server/strategy/fedprox.py +7 -7
  221. flwr/server/strategy/fedtrimmedavg.py +8 -8
  222. flwr/server/strategy/fedxgb_bagging.py +12 -12
  223. flwr/server/strategy/fedxgb_cyclic.py +10 -10
  224. flwr/server/strategy/fedxgb_nn_avg.py +6 -6
  225. flwr/server/strategy/fedyogi.py +9 -9
  226. flwr/server/strategy/krum.py +9 -9
  227. flwr/server/strategy/qfedavg.py +16 -16
  228. flwr/server/strategy/strategy.py +10 -10
  229. flwr/server/superlink/driver/__init__.py +2 -2
  230. flwr/server/superlink/driver/serverappio_grpc.py +61 -0
  231. flwr/server/superlink/driver/serverappio_servicer.py +363 -0
  232. flwr/server/superlink/ffs/__init__.py +24 -0
  233. flwr/server/superlink/ffs/disk_ffs.py +108 -0
  234. flwr/server/superlink/ffs/ffs.py +79 -0
  235. flwr/server/superlink/ffs/ffs_factory.py +47 -0
  236. flwr/server/superlink/fleet/__init__.py +1 -1
  237. flwr/server/superlink/fleet/grpc_adapter/__init__.py +15 -0
  238. flwr/server/superlink/fleet/grpc_adapter/grpc_adapter_servicer.py +162 -0
  239. flwr/server/superlink/fleet/grpc_bidi/__init__.py +1 -1
  240. flwr/server/superlink/fleet/grpc_bidi/flower_service_servicer.py +4 -2
  241. flwr/server/superlink/fleet/grpc_bidi/grpc_bridge.py +3 -2
  242. flwr/server/superlink/fleet/grpc_bidi/grpc_client_proxy.py +1 -1
  243. flwr/server/superlink/fleet/grpc_bidi/grpc_server.py +5 -154
  244. flwr/server/superlink/fleet/grpc_rere/__init__.py +1 -1
  245. flwr/server/superlink/fleet/grpc_rere/fleet_servicer.py +120 -13
  246. flwr/server/superlink/fleet/grpc_rere/server_interceptor.py +228 -0
  247. flwr/server/superlink/fleet/message_handler/__init__.py +1 -1
  248. flwr/server/superlink/fleet/message_handler/message_handler.py +153 -9
  249. flwr/server/superlink/fleet/rest_rere/__init__.py +1 -1
  250. flwr/server/superlink/fleet/rest_rere/rest_api.py +119 -81
  251. flwr/server/superlink/fleet/vce/__init__.py +1 -0
  252. flwr/server/superlink/fleet/vce/backend/__init__.py +4 -4
  253. flwr/server/superlink/fleet/vce/backend/backend.py +8 -9
  254. flwr/server/superlink/fleet/vce/backend/raybackend.py +87 -68
  255. flwr/server/superlink/fleet/vce/vce_api.py +208 -146
  256. flwr/server/superlink/linkstate/__init__.py +28 -0
  257. flwr/server/superlink/linkstate/in_memory_linkstate.py +581 -0
  258. flwr/server/superlink/linkstate/linkstate.py +389 -0
  259. flwr/server/superlink/{state/state_factory.py → linkstate/linkstate_factory.py} +19 -10
  260. flwr/server/superlink/linkstate/sqlite_linkstate.py +1236 -0
  261. flwr/server/superlink/linkstate/utils.py +389 -0
  262. flwr/server/superlink/simulation/__init__.py +15 -0
  263. flwr/server/superlink/simulation/simulationio_grpc.py +65 -0
  264. flwr/server/superlink/simulation/simulationio_servicer.py +186 -0
  265. flwr/server/superlink/utils.py +65 -0
  266. flwr/server/typing.py +2 -0
  267. flwr/server/utils/__init__.py +1 -1
  268. flwr/server/utils/tensorboard.py +5 -5
  269. flwr/server/utils/validator.py +31 -11
  270. flwr/server/workflow/default_workflows.py +70 -26
  271. flwr/server/workflow/secure_aggregation/secagg_workflow.py +1 -0
  272. flwr/server/workflow/secure_aggregation/secaggplus_workflow.py +40 -27
  273. flwr/simulation/__init__.py +12 -5
  274. flwr/simulation/app.py +247 -315
  275. flwr/simulation/legacy_app.py +402 -0
  276. flwr/simulation/ray_transport/__init__.py +1 -1
  277. flwr/simulation/ray_transport/ray_actor.py +42 -67
  278. flwr/simulation/ray_transport/ray_client_proxy.py +37 -17
  279. flwr/simulation/ray_transport/utils.py +1 -0
  280. flwr/simulation/run_simulation.py +306 -163
  281. flwr/simulation/simulationio_connection.py +89 -0
  282. flwr/superexec/__init__.py +15 -0
  283. flwr/superexec/app.py +59 -0
  284. flwr/superexec/deployment.py +188 -0
  285. flwr/superexec/exec_grpc.py +80 -0
  286. flwr/superexec/exec_servicer.py +231 -0
  287. flwr/superexec/exec_user_auth_interceptor.py +101 -0
  288. flwr/superexec/executor.py +96 -0
  289. flwr/superexec/simulation.py +124 -0
  290. {flwr_nightly-1.8.0.dev20240315.dist-info → flwr_nightly-1.15.0.dev20250114.dist-info}/METADATA +33 -26
  291. flwr_nightly-1.15.0.dev20250114.dist-info/RECORD +328 -0
  292. flwr_nightly-1.15.0.dev20250114.dist-info/entry_points.txt +12 -0
  293. flwr/cli/flower_toml.py +0 -140
  294. flwr/cli/new/templates/app/flower.toml.tpl +0 -13
  295. flwr/cli/new/templates/app/requirements.numpy.txt.tpl +0 -2
  296. flwr/cli/new/templates/app/requirements.pytorch.txt.tpl +0 -4
  297. flwr/cli/new/templates/app/requirements.tensorflow.txt.tpl +0 -4
  298. flwr/client/node_state.py +0 -48
  299. flwr/client/node_state_tests.py +0 -65
  300. flwr/proto/driver_pb2.py +0 -44
  301. flwr/proto/driver_pb2_grpc.py +0 -169
  302. flwr/proto/driver_pb2_grpc.pyi +0 -66
  303. flwr/server/superlink/driver/driver_grpc.py +0 -54
  304. flwr/server/superlink/driver/driver_servicer.py +0 -129
  305. flwr/server/superlink/state/in_memory_state.py +0 -230
  306. flwr/server/superlink/state/sqlite_state.py +0 -630
  307. flwr/server/superlink/state/state.py +0 -154
  308. flwr_nightly-1.8.0.dev20240315.dist-info/RECORD +0 -211
  309. flwr_nightly-1.8.0.dev20240315.dist-info/entry_points.txt +0 -9
  310. {flwr_nightly-1.8.0.dev20240315.dist-info → flwr_nightly-1.15.0.dev20250114.dist-info}/LICENSE +0 -0
  311. {flwr_nightly-1.8.0.dev20240315.dist-info → flwr_nightly-1.15.0.dev20250114.dist-info}/WHEEL +0 -0
@@ -19,7 +19,7 @@ Paper: arxiv.org/abs/1602.05629
19
19
 
20
20
 
21
21
  from logging import WARNING
22
- from typing import Callable, Dict, List, Optional, Tuple, Union
22
+ from typing import Callable, Optional, Union
23
23
 
24
24
  from flwr.common import (
25
25
  EvaluateIns,
@@ -99,12 +99,12 @@ class FedAvg(Strategy):
99
99
  min_available_clients: int = 2,
100
100
  evaluate_fn: Optional[
101
101
  Callable[
102
- [int, NDArrays, Dict[str, Scalar]],
103
- Optional[Tuple[float, Dict[str, Scalar]]],
102
+ [int, NDArrays, dict[str, Scalar]],
103
+ Optional[tuple[float, dict[str, Scalar]]],
104
104
  ]
105
105
  ] = None,
106
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
107
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
106
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
107
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
108
108
  accept_failures: bool = True,
109
109
  initial_parameters: Optional[Parameters] = None,
110
110
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -138,12 +138,12 @@ class FedAvg(Strategy):
138
138
  rep = f"FedAvg(accept_failures={self.accept_failures})"
139
139
  return rep
140
140
 
141
- def num_fit_clients(self, num_available_clients: int) -> Tuple[int, int]:
141
+ def num_fit_clients(self, num_available_clients: int) -> tuple[int, int]:
142
142
  """Return the sample size and the required number of available clients."""
143
143
  num_clients = int(num_available_clients * self.fraction_fit)
144
144
  return max(num_clients, self.min_fit_clients), self.min_available_clients
145
145
 
146
- def num_evaluation_clients(self, num_available_clients: int) -> Tuple[int, int]:
146
+ def num_evaluation_clients(self, num_available_clients: int) -> tuple[int, int]:
147
147
  """Use a fraction of available clients for evaluation."""
148
148
  num_clients = int(num_available_clients * self.fraction_evaluate)
149
149
  return max(num_clients, self.min_evaluate_clients), self.min_available_clients
@@ -158,7 +158,7 @@ class FedAvg(Strategy):
158
158
 
159
159
  def evaluate(
160
160
  self, server_round: int, parameters: Parameters
161
- ) -> Optional[Tuple[float, Dict[str, Scalar]]]:
161
+ ) -> Optional[tuple[float, dict[str, Scalar]]]:
162
162
  """Evaluate model parameters using an evaluation function."""
163
163
  if self.evaluate_fn is None:
164
164
  # No evaluation function provided
@@ -172,7 +172,7 @@ class FedAvg(Strategy):
172
172
 
173
173
  def configure_fit(
174
174
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
175
- ) -> List[Tuple[ClientProxy, FitIns]]:
175
+ ) -> list[tuple[ClientProxy, FitIns]]:
176
176
  """Configure the next round of training."""
177
177
  config = {}
178
178
  if self.on_fit_config_fn is not None:
@@ -193,7 +193,7 @@ class FedAvg(Strategy):
193
193
 
194
194
  def configure_evaluate(
195
195
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
196
- ) -> List[Tuple[ClientProxy, EvaluateIns]]:
196
+ ) -> list[tuple[ClientProxy, EvaluateIns]]:
197
197
  """Configure the next round of evaluation."""
198
198
  # Do not configure federated evaluation if fraction eval is 0.
199
199
  if self.fraction_evaluate == 0.0:
@@ -220,9 +220,9 @@ class FedAvg(Strategy):
220
220
  def aggregate_fit(
221
221
  self,
222
222
  server_round: int,
223
- results: List[Tuple[ClientProxy, FitRes]],
224
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
225
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
223
+ results: list[tuple[ClientProxy, FitRes]],
224
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
225
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
226
226
  """Aggregate fit results using weighted average."""
227
227
  if not results:
228
228
  return None, {}
@@ -256,9 +256,9 @@ class FedAvg(Strategy):
256
256
  def aggregate_evaluate(
257
257
  self,
258
258
  server_round: int,
259
- results: List[Tuple[ClientProxy, EvaluateRes]],
260
- failures: List[Union[Tuple[ClientProxy, EvaluateRes], BaseException]],
261
- ) -> Tuple[Optional[float], Dict[str, Scalar]]:
259
+ results: list[tuple[ClientProxy, EvaluateRes]],
260
+ failures: list[Union[tuple[ClientProxy, EvaluateRes], BaseException]],
261
+ ) -> tuple[Optional[float], dict[str, Scalar]]:
262
262
  """Aggregate evaluation losses using weighted average."""
263
263
  if not results:
264
264
  return None, {}
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ Paper: arxiv.org/abs/1602.05629
18
18
  """
19
19
 
20
20
 
21
- from typing import Callable, Dict, List, Optional, Tuple, Union, cast
21
+ from typing import Callable, Optional, Union, cast
22
22
 
23
23
  import numpy as np
24
24
 
@@ -81,12 +81,12 @@ class FedAvgAndroid(Strategy):
81
81
  min_available_clients: int = 2,
82
82
  evaluate_fn: Optional[
83
83
  Callable[
84
- [int, NDArrays, Dict[str, Scalar]],
85
- Optional[Tuple[float, Dict[str, Scalar]]],
84
+ [int, NDArrays, dict[str, Scalar]],
85
+ Optional[tuple[float, dict[str, Scalar]]],
86
86
  ]
87
87
  ] = None,
88
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
89
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
88
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
89
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
90
90
  accept_failures: bool = True,
91
91
  initial_parameters: Optional[Parameters] = None,
92
92
  ) -> None:
@@ -107,12 +107,12 @@ class FedAvgAndroid(Strategy):
107
107
  rep = f"FedAvg(accept_failures={self.accept_failures})"
108
108
  return rep
109
109
 
110
- def num_fit_clients(self, num_available_clients: int) -> Tuple[int, int]:
110
+ def num_fit_clients(self, num_available_clients: int) -> tuple[int, int]:
111
111
  """Return the sample size and the required number of available clients."""
112
112
  num_clients = int(num_available_clients * self.fraction_fit)
113
113
  return max(num_clients, self.min_fit_clients), self.min_available_clients
114
114
 
115
- def num_evaluation_clients(self, num_available_clients: int) -> Tuple[int, int]:
115
+ def num_evaluation_clients(self, num_available_clients: int) -> tuple[int, int]:
116
116
  """Use a fraction of available clients for evaluation."""
117
117
  num_clients = int(num_available_clients * self.fraction_evaluate)
118
118
  return max(num_clients, self.min_evaluate_clients), self.min_available_clients
@@ -127,7 +127,7 @@ class FedAvgAndroid(Strategy):
127
127
 
128
128
  def evaluate(
129
129
  self, server_round: int, parameters: Parameters
130
- ) -> Optional[Tuple[float, Dict[str, Scalar]]]:
130
+ ) -> Optional[tuple[float, dict[str, Scalar]]]:
131
131
  """Evaluate model parameters using an evaluation function."""
132
132
  if self.evaluate_fn is None:
133
133
  # No evaluation function provided
@@ -141,7 +141,7 @@ class FedAvgAndroid(Strategy):
141
141
 
142
142
  def configure_fit(
143
143
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
144
- ) -> List[Tuple[ClientProxy, FitIns]]:
144
+ ) -> list[tuple[ClientProxy, FitIns]]:
145
145
  """Configure the next round of training."""
146
146
  config = {}
147
147
  if self.on_fit_config_fn is not None:
@@ -162,7 +162,7 @@ class FedAvgAndroid(Strategy):
162
162
 
163
163
  def configure_evaluate(
164
164
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
165
- ) -> List[Tuple[ClientProxy, EvaluateIns]]:
165
+ ) -> list[tuple[ClientProxy, EvaluateIns]]:
166
166
  """Configure the next round of evaluation."""
167
167
  # Do not configure federated evaluation if fraction_evaluate is 0
168
168
  if self.fraction_evaluate == 0.0:
@@ -189,9 +189,9 @@ class FedAvgAndroid(Strategy):
189
189
  def aggregate_fit(
190
190
  self,
191
191
  server_round: int,
192
- results: List[Tuple[ClientProxy, FitRes]],
193
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
194
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
192
+ results: list[tuple[ClientProxy, FitRes]],
193
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
194
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
195
195
  """Aggregate fit results using weighted average."""
196
196
  if not results:
197
197
  return None, {}
@@ -208,9 +208,9 @@ class FedAvgAndroid(Strategy):
208
208
  def aggregate_evaluate(
209
209
  self,
210
210
  server_round: int,
211
- results: List[Tuple[ClientProxy, EvaluateRes]],
212
- failures: List[Union[Tuple[ClientProxy, EvaluateRes], BaseException]],
213
- ) -> Tuple[Optional[float], Dict[str, Scalar]]:
211
+ results: list[tuple[ClientProxy, EvaluateRes]],
212
+ failures: list[Union[tuple[ClientProxy, EvaluateRes], BaseException]],
213
+ ) -> tuple[Optional[float], dict[str, Scalar]]:
214
214
  """Aggregate evaluation losses using weighted average."""
215
215
  if not results:
216
216
  return None, {}
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ Paper: arxiv.org/pdf/1909.06335.pdf
19
19
 
20
20
 
21
21
  from logging import WARNING
22
- from typing import Callable, Dict, List, Optional, Tuple, Union
22
+ from typing import Callable, Optional, Union
23
23
 
24
24
  from flwr.common import (
25
25
  FitRes,
@@ -84,12 +84,12 @@ class FedAvgM(FedAvg):
84
84
  min_available_clients: int = 2,
85
85
  evaluate_fn: Optional[
86
86
  Callable[
87
- [int, NDArrays, Dict[str, Scalar]],
88
- Optional[Tuple[float, Dict[str, Scalar]]],
87
+ [int, NDArrays, dict[str, Scalar]],
88
+ Optional[tuple[float, dict[str, Scalar]]],
89
89
  ]
90
90
  ] = None,
91
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
92
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
91
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
92
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
93
93
  accept_failures: bool = True,
94
94
  initial_parameters: Optional[Parameters] = None,
95
95
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -132,9 +132,9 @@ class FedAvgM(FedAvg):
132
132
  def aggregate_fit(
133
133
  self,
134
134
  server_round: int,
135
- results: List[Tuple[ClientProxy, FitRes]],
136
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
137
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
135
+ results: list[tuple[ClientProxy, FitRes]],
136
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
137
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
138
138
  """Aggregate fit results using weighted average."""
139
139
  if not results:
140
140
  return None, {}
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ Paper: arxiv.org/pdf/1803.01498v1.pdf
19
19
 
20
20
 
21
21
  from logging import WARNING
22
- from typing import Dict, List, Optional, Tuple, Union
22
+ from typing import Optional, Union
23
23
 
24
24
  from flwr.common import (
25
25
  FitRes,
@@ -46,9 +46,9 @@ class FedMedian(FedAvg):
46
46
  def aggregate_fit(
47
47
  self,
48
48
  server_round: int,
49
- results: List[Tuple[ClientProxy, FitRes]],
50
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
51
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
49
+ results: list[tuple[ClientProxy, FitRes]],
50
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
51
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
52
52
  """Aggregate fit results using median."""
53
53
  if not results:
54
54
  return None, {}
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ Paper: arxiv.org/abs/2003.00295
18
18
  """
19
19
 
20
20
 
21
- from typing import Callable, Dict, Optional, Tuple
21
+ from typing import Callable, Optional
22
22
 
23
23
  from flwr.common import (
24
24
  MetricsAggregationFn,
@@ -86,12 +86,12 @@ class FedOpt(FedAvg):
86
86
  min_available_clients: int = 2,
87
87
  evaluate_fn: Optional[
88
88
  Callable[
89
- [int, NDArrays, Dict[str, Scalar]],
90
- Optional[Tuple[float, Dict[str, Scalar]]],
89
+ [int, NDArrays, dict[str, Scalar]],
90
+ Optional[tuple[float, dict[str, Scalar]]],
91
91
  ]
92
92
  ] = None,
93
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
94
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
93
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
94
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
95
95
  accept_failures: bool = True,
96
96
  initial_parameters: Parameters,
97
97
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ Paper: arxiv.org/abs/1812.06127
18
18
  """
19
19
 
20
20
 
21
- from typing import Callable, Dict, List, Optional, Tuple
21
+ from typing import Callable, Optional
22
22
 
23
23
  from flwr.common import FitIns, MetricsAggregationFn, NDArrays, Parameters, Scalar
24
24
  from flwr.server.client_manager import ClientManager
@@ -113,12 +113,12 @@ class FedProx(FedAvg):
113
113
  min_available_clients: int = 2,
114
114
  evaluate_fn: Optional[
115
115
  Callable[
116
- [int, NDArrays, Dict[str, Scalar]],
117
- Optional[Tuple[float, Dict[str, Scalar]]],
116
+ [int, NDArrays, dict[str, Scalar]],
117
+ Optional[tuple[float, dict[str, Scalar]]],
118
118
  ]
119
119
  ] = None,
120
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
121
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
120
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
121
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
122
122
  accept_failures: bool = True,
123
123
  initial_parameters: Optional[Parameters] = None,
124
124
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -148,7 +148,7 @@ class FedProx(FedAvg):
148
148
 
149
149
  def configure_fit(
150
150
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
151
- ) -> List[Tuple[ClientProxy, FitIns]]:
151
+ ) -> list[tuple[ClientProxy, FitIns]]:
152
152
  """Configure the next round of training.
153
153
 
154
154
  Sends the proximal factor mu to the clients
@@ -17,7 +17,7 @@
17
17
  Paper: arxiv.org/abs/1803.01498
18
18
  """
19
19
  from logging import WARNING
20
- from typing import Callable, Dict, List, Optional, Tuple, Union
20
+ from typing import Callable, Optional, Union
21
21
 
22
22
  from flwr.common import (
23
23
  FitRes,
@@ -78,12 +78,12 @@ class FedTrimmedAvg(FedAvg):
78
78
  min_available_clients: int = 2,
79
79
  evaluate_fn: Optional[
80
80
  Callable[
81
- [int, NDArrays, Dict[str, Scalar]],
82
- Optional[Tuple[float, Dict[str, Scalar]]],
81
+ [int, NDArrays, dict[str, Scalar]],
82
+ Optional[tuple[float, dict[str, Scalar]]],
83
83
  ]
84
84
  ] = None,
85
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
86
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
85
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
86
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
87
87
  accept_failures: bool = True,
88
88
  initial_parameters: Optional[Parameters] = None,
89
89
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -114,9 +114,9 @@ class FedTrimmedAvg(FedAvg):
114
114
  def aggregate_fit(
115
115
  self,
116
116
  server_round: int,
117
- results: List[Tuple[ClientProxy, FitRes]],
118
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
119
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
117
+ results: list[tuple[ClientProxy, FitRes]],
118
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
119
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
120
120
  """Aggregate fit results using trimmed average."""
121
121
  if not results:
122
122
  return None, {}
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
17
17
 
18
18
  import json
19
19
  from logging import WARNING
20
- from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
20
+ from typing import Any, Callable, Optional, Union, cast
21
21
 
22
22
  from flwr.common import EvaluateRes, FitRes, Parameters, Scalar
23
23
  from flwr.common.logger import log
@@ -34,8 +34,8 @@ class FedXgbBagging(FedAvg):
34
34
  self,
35
35
  evaluate_function: Optional[
36
36
  Callable[
37
- [int, Parameters, Dict[str, Scalar]],
38
- Optional[Tuple[float, Dict[str, Scalar]]],
37
+ [int, Parameters, dict[str, Scalar]],
38
+ Optional[tuple[float, dict[str, Scalar]]],
39
39
  ]
40
40
  ] = None,
41
41
  **kwargs: Any,
@@ -52,9 +52,9 @@ class FedXgbBagging(FedAvg):
52
52
  def aggregate_fit(
53
53
  self,
54
54
  server_round: int,
55
- results: List[Tuple[ClientProxy, FitRes]],
56
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
57
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
55
+ results: list[tuple[ClientProxy, FitRes]],
56
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
57
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
58
58
  """Aggregate fit results using bagging."""
59
59
  if not results:
60
60
  return None, {}
@@ -79,9 +79,9 @@ class FedXgbBagging(FedAvg):
79
79
  def aggregate_evaluate(
80
80
  self,
81
81
  server_round: int,
82
- results: List[Tuple[ClientProxy, EvaluateRes]],
83
- failures: List[Union[Tuple[ClientProxy, EvaluateRes], BaseException]],
84
- ) -> Tuple[Optional[float], Dict[str, Scalar]]:
82
+ results: list[tuple[ClientProxy, EvaluateRes]],
83
+ failures: list[Union[tuple[ClientProxy, EvaluateRes], BaseException]],
84
+ ) -> tuple[Optional[float], dict[str, Scalar]]:
85
85
  """Aggregate evaluation metrics using average."""
86
86
  if not results:
87
87
  return None, {}
@@ -101,7 +101,7 @@ class FedXgbBagging(FedAvg):
101
101
 
102
102
  def evaluate(
103
103
  self, server_round: int, parameters: Parameters
104
- ) -> Optional[Tuple[float, Dict[str, Scalar]]]:
104
+ ) -> Optional[tuple[float, dict[str, Scalar]]]:
105
105
  """Evaluate model parameters using an evaluation function."""
106
106
  if self.evaluate_function is None:
107
107
  # No evaluation function provided
@@ -152,7 +152,7 @@ def aggregate(
152
152
  return bst_prev_bytes
153
153
 
154
154
 
155
- def _get_tree_nums(xgb_model_org: bytes) -> Tuple[int, int]:
155
+ def _get_tree_nums(xgb_model_org: bytes) -> tuple[int, int]:
156
156
  xgb_model = json.loads(bytearray(xgb_model_org))
157
157
  # Get the number of trees
158
158
  tree_num = int(
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
  from logging import WARNING
19
- from typing import Any, Dict, List, Optional, Tuple, Union, cast
19
+ from typing import Any, Optional, Union, cast
20
20
 
21
21
  from flwr.common import EvaluateIns, EvaluateRes, FitIns, FitRes, Parameters, Scalar
22
22
  from flwr.common.logger import log
@@ -45,9 +45,9 @@ class FedXgbCyclic(FedAvg):
45
45
  def aggregate_fit(
46
46
  self,
47
47
  server_round: int,
48
- results: List[Tuple[ClientProxy, FitRes]],
49
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
50
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
48
+ results: list[tuple[ClientProxy, FitRes]],
49
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
50
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
51
51
  """Aggregate fit results using bagging."""
52
52
  if not results:
53
53
  return None, {}
@@ -69,9 +69,9 @@ class FedXgbCyclic(FedAvg):
69
69
  def aggregate_evaluate(
70
70
  self,
71
71
  server_round: int,
72
- results: List[Tuple[ClientProxy, EvaluateRes]],
73
- failures: List[Union[Tuple[ClientProxy, EvaluateRes], BaseException]],
74
- ) -> Tuple[Optional[float], Dict[str, Scalar]]:
72
+ results: list[tuple[ClientProxy, EvaluateRes]],
73
+ failures: list[Union[tuple[ClientProxy, EvaluateRes], BaseException]],
74
+ ) -> tuple[Optional[float], dict[str, Scalar]]:
75
75
  """Aggregate evaluation metrics using average."""
76
76
  if not results:
77
77
  return None, {}
@@ -91,7 +91,7 @@ class FedXgbCyclic(FedAvg):
91
91
 
92
92
  def configure_fit(
93
93
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
94
- ) -> List[Tuple[ClientProxy, FitIns]]:
94
+ ) -> list[tuple[ClientProxy, FitIns]]:
95
95
  """Configure the next round of training."""
96
96
  config = {}
97
97
  if self.on_fit_config_fn is not None:
@@ -117,7 +117,7 @@ class FedXgbCyclic(FedAvg):
117
117
 
118
118
  def configure_evaluate(
119
119
  self, server_round: int, parameters: Parameters, client_manager: ClientManager
120
- ) -> List[Tuple[ClientProxy, EvaluateIns]]:
120
+ ) -> list[tuple[ClientProxy, EvaluateIns]]:
121
121
  """Configure the next round of evaluation."""
122
122
  # Do not configure federated evaluation if fraction eval is 0.
123
123
  if self.fraction_evaluate == 0.0:
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ Paper: arxiv.org/abs/2304.07537
22
22
 
23
23
 
24
24
  from logging import WARNING
25
- from typing import Any, Dict, List, Optional, Tuple, Union
25
+ from typing import Any, Optional, Union
26
26
 
27
27
  from flwr.common import FitRes, Scalar, ndarrays_to_parameters, parameters_to_ndarrays
28
28
  from flwr.common.logger import log, warn_deprecated_feature
@@ -56,7 +56,7 @@ class FedXgbNnAvg(FedAvg):
56
56
 
57
57
  def evaluate(
58
58
  self, server_round: int, parameters: Any
59
- ) -> Optional[Tuple[float, Dict[str, Scalar]]]:
59
+ ) -> Optional[tuple[float, dict[str, Scalar]]]:
60
60
  """Evaluate model parameters using an evaluation function."""
61
61
  if self.evaluate_fn is None:
62
62
  # No evaluation function provided
@@ -70,9 +70,9 @@ class FedXgbNnAvg(FedAvg):
70
70
  def aggregate_fit(
71
71
  self,
72
72
  server_round: int,
73
- results: List[Tuple[ClientProxy, FitRes]],
74
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
75
- ) -> Tuple[Optional[Any], Dict[str, Scalar]]:
73
+ results: list[tuple[ClientProxy, FitRes]],
74
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
75
+ ) -> tuple[Optional[Any], dict[str, Scalar]]:
76
76
  """Aggregate fit results using weighted average."""
77
77
  if not results:
78
78
  return None, {}
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ Paper: arxiv.org/abs/2003.00295
18
18
  """
19
19
 
20
20
 
21
- from typing import Callable, Dict, List, Optional, Tuple, Union
21
+ from typing import Callable, Optional, Union
22
22
 
23
23
  import numpy as np
24
24
 
@@ -93,12 +93,12 @@ class FedYogi(FedOpt):
93
93
  min_available_clients: int = 2,
94
94
  evaluate_fn: Optional[
95
95
  Callable[
96
- [int, NDArrays, Dict[str, Scalar]],
97
- Optional[Tuple[float, Dict[str, Scalar]]],
96
+ [int, NDArrays, dict[str, Scalar]],
97
+ Optional[tuple[float, dict[str, Scalar]]],
98
98
  ]
99
99
  ] = None,
100
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
101
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
100
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
101
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
102
102
  accept_failures: bool = True,
103
103
  initial_parameters: Parameters,
104
104
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -137,9 +137,9 @@ class FedYogi(FedOpt):
137
137
  def aggregate_fit(
138
138
  self,
139
139
  server_round: int,
140
- results: List[Tuple[ClientProxy, FitRes]],
141
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
142
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
140
+ results: list[tuple[ClientProxy, FitRes]],
141
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
142
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
143
143
  """Aggregate fit results using weighted average."""
144
144
  fedavg_parameters_aggregated, metrics_aggregated = super().aggregate_fit(
145
145
  server_round=server_round, results=results, failures=failures
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ Paper: proceedings.neurips.cc/paper/2017/file/f4b9ec30ad9f68f89b29639786cb62ef-P
21
21
 
22
22
 
23
23
  from logging import WARNING
24
- from typing import Callable, Dict, List, Optional, Tuple, Union
24
+ from typing import Callable, Optional, Union
25
25
 
26
26
  from flwr.common import (
27
27
  FitRes,
@@ -87,12 +87,12 @@ class Krum(FedAvg):
87
87
  num_clients_to_keep: int = 0,
88
88
  evaluate_fn: Optional[
89
89
  Callable[
90
- [int, NDArrays, Dict[str, Scalar]],
91
- Optional[Tuple[float, Dict[str, Scalar]]],
90
+ [int, NDArrays, dict[str, Scalar]],
91
+ Optional[tuple[float, dict[str, Scalar]]],
92
92
  ]
93
93
  ] = None,
94
- on_fit_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
95
- on_evaluate_config_fn: Optional[Callable[[int], Dict[str, Scalar]]] = None,
94
+ on_fit_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
95
+ on_evaluate_config_fn: Optional[Callable[[int], dict[str, Scalar]]] = None,
96
96
  accept_failures: bool = True,
97
97
  initial_parameters: Optional[Parameters] = None,
98
98
  fit_metrics_aggregation_fn: Optional[MetricsAggregationFn] = None,
@@ -123,9 +123,9 @@ class Krum(FedAvg):
123
123
  def aggregate_fit(
124
124
  self,
125
125
  server_round: int,
126
- results: List[Tuple[ClientProxy, FitRes]],
127
- failures: List[Union[Tuple[ClientProxy, FitRes], BaseException]],
128
- ) -> Tuple[Optional[Parameters], Dict[str, Scalar]]:
126
+ results: list[tuple[ClientProxy, FitRes]],
127
+ failures: list[Union[tuple[ClientProxy, FitRes], BaseException]],
128
+ ) -> tuple[Optional[Parameters], dict[str, Scalar]]:
129
129
  """Aggregate fit results using Krum."""
130
130
  if not results:
131
131
  return None, {}