flwr 1.17.0__py3-none-any.whl → 1.18.0__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.
Files changed (223) hide show
  1. flwr/__init__.py +1 -1
  2. flwr/cli/__init__.py +1 -1
  3. flwr/cli/app.py +21 -2
  4. flwr/cli/build.py +1 -1
  5. flwr/cli/cli_user_auth_interceptor.py +1 -1
  6. flwr/cli/config_utils.py +53 -17
  7. flwr/cli/example.py +1 -1
  8. flwr/cli/install.py +1 -1
  9. flwr/cli/log.py +1 -1
  10. flwr/cli/login/__init__.py +1 -1
  11. flwr/cli/login/login.py +12 -1
  12. flwr/cli/ls.py +1 -1
  13. flwr/cli/new/__init__.py +1 -1
  14. flwr/cli/new/new.py +4 -4
  15. flwr/cli/new/templates/__init__.py +1 -1
  16. flwr/cli/new/templates/app/__init__.py +1 -1
  17. flwr/cli/new/templates/app/code/__init__.py +1 -1
  18. flwr/cli/new/templates/app/code/flwr_tune/__init__.py +1 -1
  19. flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl +4 -4
  20. flwr/cli/new/templates/app/code/task.sklearn.py.tpl +1 -1
  21. flwr/cli/new/templates/app/pyproject.baseline.toml.tpl +1 -1
  22. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +4 -4
  23. flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl +1 -1
  24. flwr/cli/new/templates/app/pyproject.jax.toml.tpl +1 -1
  25. flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +1 -1
  26. flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +1 -1
  27. flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +1 -1
  28. flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +1 -1
  29. flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +1 -1
  30. flwr/cli/run/__init__.py +1 -1
  31. flwr/cli/run/run.py +1 -1
  32. flwr/cli/stop.py +1 -1
  33. flwr/cli/utils.py +11 -12
  34. flwr/client/__init__.py +1 -1
  35. flwr/client/app.py +52 -52
  36. flwr/client/client.py +1 -1
  37. flwr/client/client_app.py +139 -137
  38. flwr/client/clientapp/__init__.py +1 -1
  39. flwr/client/clientapp/app.py +1 -1
  40. flwr/client/clientapp/clientappio_servicer.py +1 -1
  41. flwr/client/clientapp/utils.py +1 -1
  42. flwr/client/dpfedavg_numpy_client.py +1 -1
  43. flwr/client/grpc_adapter_client/__init__.py +1 -1
  44. flwr/client/grpc_adapter_client/connection.py +1 -1
  45. flwr/client/grpc_client/__init__.py +1 -1
  46. flwr/client/grpc_client/connection.py +13 -13
  47. flwr/client/grpc_rere_client/__init__.py +1 -1
  48. flwr/client/grpc_rere_client/client_interceptor.py +1 -1
  49. flwr/client/grpc_rere_client/connection.py +1 -1
  50. flwr/client/grpc_rere_client/grpc_adapter.py +1 -1
  51. flwr/client/heartbeat.py +1 -1
  52. flwr/client/message_handler/__init__.py +1 -1
  53. flwr/client/message_handler/message_handler.py +1 -1
  54. flwr/client/mod/__init__.py +1 -1
  55. flwr/client/mod/centraldp_mods.py +1 -1
  56. flwr/client/mod/comms_mods.py +3 -3
  57. flwr/client/mod/localdp_mod.py +6 -6
  58. flwr/client/mod/secure_aggregation/__init__.py +1 -1
  59. flwr/client/mod/secure_aggregation/secagg_mod.py +1 -1
  60. flwr/client/mod/secure_aggregation/secaggplus_mod.py +1 -1
  61. flwr/client/mod/utils.py +1 -1
  62. flwr/client/nodestate/__init__.py +1 -1
  63. flwr/client/nodestate/in_memory_nodestate.py +1 -1
  64. flwr/client/nodestate/nodestate.py +1 -1
  65. flwr/client/nodestate/nodestate_factory.py +1 -1
  66. flwr/client/numpy_client.py +1 -1
  67. flwr/client/rest_client/__init__.py +1 -1
  68. flwr/client/rest_client/connection.py +1 -1
  69. flwr/client/run_info_store.py +1 -1
  70. flwr/client/supernode/__init__.py +1 -1
  71. flwr/client/supernode/app.py +1 -1
  72. flwr/client/typing.py +1 -1
  73. flwr/common/__init__.py +1 -1
  74. flwr/common/address.py +1 -1
  75. flwr/common/args.py +1 -1
  76. flwr/common/auth_plugin/__init__.py +1 -1
  77. flwr/common/auth_plugin/auth_plugin.py +1 -1
  78. flwr/common/config.py +1 -1
  79. flwr/common/constant.py +1 -1
  80. flwr/common/context.py +1 -1
  81. flwr/common/date.py +1 -1
  82. flwr/common/differential_privacy.py +1 -1
  83. flwr/common/differential_privacy_constants.py +1 -1
  84. flwr/common/dp.py +1 -1
  85. flwr/common/exit/exit.py +6 -6
  86. flwr/common/exit_handlers.py +1 -1
  87. flwr/common/grpc.py +1 -1
  88. flwr/common/logger.py +1 -1
  89. flwr/common/message.py +28 -11
  90. flwr/common/object_ref.py +1 -1
  91. flwr/common/parameter.py +1 -1
  92. flwr/common/pyproject.py +1 -1
  93. flwr/common/record/__init__.py +1 -1
  94. flwr/common/record/arrayrecord.py +31 -31
  95. flwr/common/record/configrecord.py +13 -13
  96. flwr/common/record/conversion_utils.py +1 -1
  97. flwr/common/record/metricrecord.py +16 -16
  98. flwr/common/record/recorddict.py +138 -89
  99. flwr/common/record/typeddict.py +1 -1
  100. flwr/common/retry_invoker.py +10 -10
  101. flwr/common/secure_aggregation/__init__.py +1 -1
  102. flwr/common/secure_aggregation/crypto/__init__.py +1 -1
  103. flwr/common/secure_aggregation/crypto/shamir.py +52 -30
  104. flwr/common/secure_aggregation/crypto/symmetric_encryption.py +1 -1
  105. flwr/common/secure_aggregation/ndarrays_arithmetic.py +1 -1
  106. flwr/common/secure_aggregation/quantization.py +1 -1
  107. flwr/common/secure_aggregation/secaggplus_constants.py +1 -1
  108. flwr/common/secure_aggregation/secaggplus_utils.py +1 -1
  109. flwr/common/serde.py +1 -1
  110. flwr/common/telemetry.py +2 -2
  111. flwr/common/typing.py +1 -1
  112. flwr/common/version.py +1 -1
  113. flwr/proto/__init__.py +1 -1
  114. flwr/server/__init__.py +1 -1
  115. flwr/server/app.py +11 -11
  116. flwr/server/client_manager.py +1 -1
  117. flwr/server/client_proxy.py +1 -1
  118. flwr/server/compat/__init__.py +1 -1
  119. flwr/server/compat/app.py +1 -1
  120. flwr/server/compat/app_utils.py +1 -1
  121. flwr/server/compat/legacy_context.py +1 -1
  122. flwr/server/criterion.py +1 -1
  123. flwr/server/grid/grid.py +3 -3
  124. flwr/server/history.py +1 -1
  125. flwr/server/run_serverapp.py +1 -1
  126. flwr/server/server.py +1 -1
  127. flwr/server/server_app.py +65 -58
  128. flwr/server/server_config.py +1 -1
  129. flwr/server/serverapp/__init__.py +1 -1
  130. flwr/server/serverapp/app.py +1 -1
  131. flwr/server/serverapp_components.py +1 -1
  132. flwr/server/strategy/__init__.py +1 -1
  133. flwr/server/strategy/aggregate.py +1 -1
  134. flwr/server/strategy/bulyan.py +2 -2
  135. flwr/server/strategy/dp_adaptive_clipping.py +17 -17
  136. flwr/server/strategy/dp_fixed_clipping.py +17 -17
  137. flwr/server/strategy/dpfedavg_adaptive.py +1 -1
  138. flwr/server/strategy/dpfedavg_fixed.py +1 -1
  139. flwr/server/strategy/fault_tolerant_fedavg.py +1 -1
  140. flwr/server/strategy/fedadagrad.py +1 -1
  141. flwr/server/strategy/fedadam.py +1 -1
  142. flwr/server/strategy/fedavg.py +1 -1
  143. flwr/server/strategy/fedavg_android.py +1 -1
  144. flwr/server/strategy/fedavgm.py +1 -1
  145. flwr/server/strategy/fedmedian.py +1 -1
  146. flwr/server/strategy/fedopt.py +1 -1
  147. flwr/server/strategy/fedprox.py +1 -1
  148. flwr/server/strategy/fedtrimmedavg.py +1 -1
  149. flwr/server/strategy/fedxgb_bagging.py +1 -1
  150. flwr/server/strategy/fedxgb_cyclic.py +1 -1
  151. flwr/server/strategy/fedxgb_nn_avg.py +3 -2
  152. flwr/server/strategy/fedyogi.py +1 -1
  153. flwr/server/strategy/krum.py +1 -1
  154. flwr/server/strategy/qfedavg.py +1 -1
  155. flwr/server/strategy/strategy.py +1 -1
  156. flwr/server/superlink/__init__.py +1 -1
  157. flwr/server/superlink/ffs/__init__.py +1 -1
  158. flwr/server/superlink/ffs/disk_ffs.py +1 -1
  159. flwr/server/superlink/ffs/ffs.py +1 -1
  160. flwr/server/superlink/ffs/ffs_factory.py +1 -1
  161. flwr/server/superlink/fleet/__init__.py +1 -1
  162. flwr/server/superlink/fleet/grpc_adapter/__init__.py +1 -1
  163. flwr/server/superlink/fleet/grpc_adapter/grpc_adapter_servicer.py +1 -1
  164. flwr/server/superlink/fleet/grpc_bidi/__init__.py +1 -1
  165. flwr/server/superlink/fleet/grpc_bidi/flower_service_servicer.py +1 -1
  166. flwr/server/superlink/fleet/grpc_bidi/grpc_bridge.py +1 -1
  167. flwr/server/superlink/fleet/grpc_bidi/grpc_client_proxy.py +1 -1
  168. flwr/server/superlink/fleet/grpc_bidi/grpc_server.py +13 -13
  169. flwr/server/superlink/fleet/grpc_rere/__init__.py +1 -1
  170. flwr/server/superlink/fleet/grpc_rere/fleet_servicer.py +1 -1
  171. flwr/server/superlink/fleet/grpc_rere/server_interceptor.py +1 -1
  172. flwr/server/superlink/fleet/message_handler/__init__.py +1 -1
  173. flwr/server/superlink/fleet/message_handler/message_handler.py +1 -1
  174. flwr/server/superlink/fleet/rest_rere/__init__.py +1 -1
  175. flwr/server/superlink/fleet/rest_rere/rest_api.py +1 -1
  176. flwr/server/superlink/fleet/vce/__init__.py +1 -1
  177. flwr/server/superlink/fleet/vce/backend/__init__.py +1 -1
  178. flwr/server/superlink/fleet/vce/backend/backend.py +1 -1
  179. flwr/server/superlink/fleet/vce/backend/raybackend.py +1 -1
  180. flwr/server/superlink/fleet/vce/vce_api.py +1 -1
  181. flwr/server/superlink/linkstate/__init__.py +1 -1
  182. flwr/server/superlink/linkstate/in_memory_linkstate.py +1 -1
  183. flwr/server/superlink/linkstate/linkstate.py +1 -1
  184. flwr/server/superlink/linkstate/linkstate_factory.py +1 -1
  185. flwr/server/superlink/linkstate/sqlite_linkstate.py +1 -1
  186. flwr/server/superlink/linkstate/utils.py +1 -1
  187. flwr/server/superlink/simulation/__init__.py +1 -1
  188. flwr/server/superlink/simulation/simulationio_grpc.py +1 -1
  189. flwr/server/superlink/simulation/simulationio_servicer.py +1 -1
  190. flwr/server/superlink/utils.py +1 -1
  191. flwr/server/typing.py +1 -1
  192. flwr/server/utils/__init__.py +1 -1
  193. flwr/server/utils/tensorboard.py +1 -1
  194. flwr/server/utils/validator.py +1 -1
  195. flwr/server/workflow/__init__.py +1 -1
  196. flwr/server/workflow/constant.py +1 -1
  197. flwr/server/workflow/default_workflows.py +1 -1
  198. flwr/server/workflow/secure_aggregation/__init__.py +1 -1
  199. flwr/server/workflow/secure_aggregation/secagg_workflow.py +1 -1
  200. flwr/server/workflow/secure_aggregation/secaggplus_workflow.py +1 -1
  201. flwr/simulation/__init__.py +1 -1
  202. flwr/simulation/app.py +1 -1
  203. flwr/simulation/legacy_app.py +1 -1
  204. flwr/simulation/ray_transport/__init__.py +1 -1
  205. flwr/simulation/ray_transport/ray_actor.py +1 -1
  206. flwr/simulation/ray_transport/ray_client_proxy.py +1 -1
  207. flwr/simulation/ray_transport/utils.py +1 -1
  208. flwr/simulation/run_simulation.py +2 -2
  209. flwr/simulation/simulationio_connection.py +1 -1
  210. flwr/superexec/__init__.py +1 -1
  211. flwr/superexec/app.py +1 -1
  212. flwr/superexec/deployment.py +1 -1
  213. flwr/superexec/exec_grpc.py +1 -1
  214. flwr/superexec/exec_servicer.py +1 -1
  215. flwr/superexec/exec_user_auth_interceptor.py +1 -1
  216. flwr/superexec/executor.py +1 -1
  217. flwr/superexec/simulation.py +1 -1
  218. {flwr-1.17.0.dist-info → flwr-1.18.0.dist-info}/METADATA +2 -2
  219. flwr-1.18.0.dist-info/RECORD +332 -0
  220. flwr-1.17.0.dist-info/LICENSE +0 -202
  221. flwr-1.17.0.dist-info/RECORD +0 -333
  222. {flwr-1.17.0.dist-info → flwr-1.18.0.dist-info}/WHEEL +0 -0
  223. {flwr-1.17.0.dist-info → flwr-1.18.0.dist-info}/entry_points.txt +0 -0
flwr/common/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/address.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/args.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/config.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/constant.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/context.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/date.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/dp.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/exit/exit.py CHANGED
@@ -37,13 +37,13 @@ def flwr_exit(
37
37
  ) -> NoReturn:
38
38
  """Handle application exit with an optional message.
39
39
 
40
- The exit message logged and displayed will follow this structure:
40
+ The exit message logged and displayed will follow this structure::
41
41
 
42
- >>> Exit Code: <code>
43
- >>> <message>
44
- >>> <short-help-message>
45
- >>>
46
- >>> For more information, visit: <help-page-url>
42
+ Exit Code: <code>
43
+ <message>
44
+ <short-help-message>
45
+
46
+ For more information, visit: <help-page-url>
47
47
 
48
48
  - `<code>`: The unique exit code representing the termination reason.
49
49
  - `<message>`: Optional context or additional information about the exit.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/grpc.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/logger.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/message.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -36,6 +36,19 @@ MESSAGE_INIT_ERROR_MESSAGE = (
36
36
  )
37
37
 
38
38
 
39
+ class _WarningTracker:
40
+ """A class to track warnings for deprecated properties."""
41
+
42
+ def __init__(self) -> None:
43
+ # These variables are used to ensure that the deprecation warnings
44
+ # for the deprecated properties/class are logged only once.
45
+ self.create_error_reply_logged = False
46
+ self.create_reply_logged = False
47
+
48
+
49
+ _warning_tracker = _WarningTracker()
50
+
51
+
39
52
  class MessageInitializationError(TypeError):
40
53
  """Error raised when initializing a message with invalid arguments."""
41
54
 
@@ -456,11 +469,13 @@ class Message:
456
469
  message : Message
457
470
  A Message containing only the relevant error and metadata.
458
471
  """
459
- warn_deprecated_feature(
460
- "`Message.create_error_reply` is deprecated. "
461
- "Instead of calling `some_message.create_error_reply(some_error, ttl=...)`"
462
- ", use `Message(some_error, reply_to=some_message, ttl=...)`."
463
- )
472
+ if not _warning_tracker.create_error_reply_logged:
473
+ _warning_tracker.create_error_reply_logged = True
474
+ warn_deprecated_feature(
475
+ "`Message.create_error_reply` is deprecated. "
476
+ "Instead of calling `some_message.create_error_reply(some_error, "
477
+ "ttl=...)`, use `Message(some_error, reply_to=some_message, ttl=...)`."
478
+ )
464
479
  if ttl is not None:
465
480
  return Message(error, reply_to=self, ttl=ttl)
466
481
  return Message(error, reply_to=self)
@@ -488,11 +503,13 @@ class Message:
488
503
  Message
489
504
  A new `Message` instance representing the reply.
490
505
  """
491
- warn_deprecated_feature(
492
- "`Message.create_reply` is deprecated. "
493
- "Instead of calling `some_message.create_reply(some_content, ttl=...)`"
494
- ", use `Message(some_content, reply_to=some_message, ttl=...)`."
495
- )
506
+ if not _warning_tracker.create_reply_logged:
507
+ _warning_tracker.create_reply_logged = True
508
+ warn_deprecated_feature(
509
+ "`Message.create_reply` is deprecated. "
510
+ "Instead of calling `some_message.create_reply(some_content, ttl=...)`"
511
+ ", use `Message(some_content, reply_to=some_message, ttl=...)`."
512
+ )
496
513
  if ttl is not None:
497
514
  return Message(content, reply_to=self, ttl=ttl)
498
515
  return Message(content, reply_to=self)
flwr/common/object_ref.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/parameter.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
flwr/common/pyproject.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -96,24 +96,24 @@ class Array:
96
96
 
97
97
  Examples
98
98
  --------
99
- Initializing by specifying all fields directly:
99
+ Initializing by specifying all fields directly::
100
100
 
101
- >>> arr1 = Array(
102
- >>> dtype="float32",
103
- >>> shape=[3, 3],
104
- >>> stype="numpy.ndarray",
105
- >>> data=b"serialized_data...",
106
- >>> )
101
+ arr1 = Array(
102
+ dtype="float32",
103
+ shape=[3, 3],
104
+ stype="numpy.ndarray",
105
+ data=b"serialized_data...",
106
+ )
107
107
 
108
- Initializing with a NumPy ndarray:
108
+ Initializing with a NumPy ndarray::
109
109
 
110
- >>> import numpy as np
111
- >>> arr2 = Array(np.random.randn(3, 3))
110
+ import numpy as np
111
+ arr2 = Array(np.random.randn(3, 3))
112
112
 
113
- Initializing with a PyTorch tensor:
113
+ Initializing with a PyTorch tensor::
114
114
 
115
- >>> import torch
116
- >>> arr3 = Array(torch.randn(3, 3))
115
+ import torch
116
+ arr3 = Array(torch.randn(3, 3))
117
117
  """
118
118
 
119
119
  dtype: str
@@ -315,33 +315,33 @@ class ArrayRecord(TypedDict[str, Array]):
315
315
 
316
316
  Examples
317
317
  --------
318
- Initializing an empty ArrayRecord:
318
+ Initializing an empty ArrayRecord::
319
319
 
320
- >>> record = ArrayRecord()
320
+ record = ArrayRecord()
321
321
 
322
- Initializing with a dictionary of :class:`Array`:
322
+ Initializing with a dictionary of :class:`Array`::
323
323
 
324
- >>> arr = Array("float32", [5, 5], "numpy.ndarray", b"serialized_data...")
325
- >>> record = ArrayRecord({"weight": arr})
324
+ arr = Array("float32", [5, 5], "numpy.ndarray", b"serialized_data...")
325
+ record = ArrayRecord({"weight": arr})
326
326
 
327
- Initializing with a list of NumPy arrays:
327
+ Initializing with a list of NumPy arrays::
328
328
 
329
- >>> import numpy as np
330
- >>> arr1 = np.random.randn(3, 3)
331
- >>> arr2 = np.random.randn(2, 2)
332
- >>> record = ArrayRecord([arr1, arr2])
329
+ import numpy as np
330
+ arr1 = np.random.randn(3, 3)
331
+ arr2 = np.random.randn(2, 2)
332
+ record = ArrayRecord([arr1, arr2])
333
333
 
334
- Initializing with a PyTorch model state_dict:
334
+ Initializing with a PyTorch model state_dict::
335
335
 
336
- >>> import torch.nn as nn
337
- >>> model = nn.Linear(10, 5)
338
- >>> record = ArrayRecord(model.state_dict())
336
+ import torch.nn as nn
337
+ model = nn.Linear(10, 5)
338
+ record = ArrayRecord(model.state_dict())
339
339
 
340
- Initializing with a TensorFlow model weights (a list of NumPy arrays):
340
+ Initializing with a TensorFlow model weights (a list of NumPy arrays)::
341
341
 
342
- >>> import tensorflow as tf
343
- >>> model = tf.keras.Sequential([tf.keras.layers.Dense(5, input_shape=(10,))])
344
- >>> record = ArrayRecord(model.get_weights())
342
+ import tensorflow as tf
343
+ model = tf.keras.Sequential([tf.keras.layers.Dense(5, input_shape=(10,))])
344
+ record = ArrayRecord(model.get_weights())
345
345
  """
346
346
 
347
347
  @overload
@@ -60,7 +60,7 @@ def _check_value(value: ConfigRecordValues) -> None:
60
60
 
61
61
 
62
62
  class ConfigRecord(TypedDict[str, ConfigRecordValues]):
63
- """Configs record.
63
+ """Config record.
64
64
 
65
65
  A :code:`ConfigRecord` is a Python dictionary designed to ensure that
66
66
  each key-value pair adheres to specified data types. A :code:`ConfigRecord`
@@ -90,18 +90,18 @@ class ConfigRecord(TypedDict[str, ConfigRecordValues]):
90
90
  encourage you to use a :code:`ArrayRecord` instead if these are of high
91
91
  dimensionality.
92
92
 
93
- Let's see some examples of how to construct a :code:`ConfigRecord` from scratch:
94
-
95
- >>> from flwr.common import ConfigRecord
96
- >>>
97
- >>> # A `ConfigRecord` is a specialized Python dictionary
98
- >>> record = ConfigRecord({"lr": 0.1, "batch-size": 128})
99
- >>> # You can add more content to an existing record
100
- >>> record["compute-average"] = True
101
- >>> # It also supports lists
102
- >>> record["loss-fn-coefficients"] = [0.4, 0.25, 0.35]
103
- >>> # And string values (among other types)
104
- >>> record["path-to-S3"] = "s3://bucket_name/folder1/fileA.json"
93
+ Let's see some examples of how to construct a :code:`ConfigRecord` from scratch::
94
+
95
+ from flwr.common import ConfigRecord
96
+
97
+ # A `ConfigRecord` is a specialized Python dictionary
98
+ record = ConfigRecord({"lr": 0.1, "batch-size": 128})
99
+ # You can add more content to an existing record
100
+ record["compute-average"] = True
101
+ # It also supports lists
102
+ record["loss-fn-coefficients"] = [0.4, 0.25, 0.35]
103
+ # And string values (among other types)
104
+ record["path-to-S3"] = "s3://bucket_name/folder1/fileA.json"
105
105
 
106
106
  Just like the other types of records in a :code:`flwr.common.RecordDict`, types are
107
107
  enforced. If you need to add a custom data structure or object, we recommend to
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2025 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.
@@ -60,7 +60,7 @@ def _check_value(value: MetricRecordValues) -> None:
60
60
 
61
61
 
62
62
  class MetricRecord(TypedDict[str, MetricRecordValues]):
63
- """Metrics recod.
63
+ """Metric record.
64
64
 
65
65
  A :code:`MetricRecord` is a Python dictionary designed to ensure that
66
66
  each key-value pair adheres to specified data types. A :code:`MetricRecord`
@@ -89,27 +89,27 @@ class MetricRecord(TypedDict[str, MetricRecordValues]):
89
89
  Common to these examples is that the output can be typically represented by
90
90
  a single scalar (:code:`int`, :code:`float`) or list of scalars.
91
91
 
92
- Let's see some examples of how to construct a :code:`MetricRecord` from scratch:
92
+ Let's see some examples of how to construct a :code:`MetricRecord` from scratch::
93
93
 
94
- >>> from flwr.common import MetricRecord
95
- >>>
96
- >>> # A `MetricRecord` is a specialized Python dictionary
97
- >>> record = MetricRecord({"accuracy": 0.94})
98
- >>> # You can add more content to an existing record
99
- >>> record["loss"] = 0.01
100
- >>> # It also supports lists
101
- >>> record["loss-historic"] = [0.9, 0.5, 0.01]
94
+ from flwr.common import MetricRecord
95
+
96
+ # A `MetricRecord` is a specialized Python dictionary
97
+ record = MetricRecord({"accuracy": 0.94})
98
+ # You can add more content to an existing record
99
+ record["loss"] = 0.01
100
+ # It also supports lists
101
+ record["loss-historic"] = [0.9, 0.5, 0.01]
102
102
 
103
103
  Since types are enforced, the types of the objects inserted are checked. For a
104
104
  :code:`MetricRecord`, value types allowed are those in defined in
105
105
  :code:`flwr.common.MetricRecordValues`. Similarly, only :code:`str` keys are
106
- allowed.
106
+ allowed::
107
+
108
+ from flwr.common import MetricRecord
107
109
 
108
- >>> from flwr.common import MetricRecord
109
- >>>
110
- >>> record = MetricRecord() # an empty record
111
- >>> # Add unsupported value
112
- >>> record["something-unsupported"] = {'a': 123} # Will throw a `TypeError`
110
+ record = MetricRecord() # an empty record
111
+ # Add unsupported value
112
+ record["something-unsupported"] = {'a': 123} # Will throw a `TypeError`
113
113
 
114
114
  If you need a more versatily type of record try :code:`ConfigRecord` or
115
115
  :code:`ArrayRecord`.