flwr-nightly 1.8.0.dev20240314__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.dev20240314.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.dev20240314.dist-info/RECORD +0 -211
  309. flwr_nightly-1.8.0.dev20240314.dist-info/entry_points.txt +0 -9
  310. {flwr_nightly-1.8.0.dev20240314.dist-info → flwr_nightly-1.15.0.dev20250114.dist-info}/LICENSE +0 -0
  311. {flwr_nightly-1.8.0.dev20240314.dist-info → flwr_nightly-1.15.0.dev20250114.dist-info}/WHEEL +0 -0
flwr/common/serde.py CHANGED
@@ -15,12 +15,19 @@
15
15
  """ProtoBuf serialization and deserialization."""
16
16
 
17
17
 
18
- from typing import Any, Dict, List, MutableMapping, OrderedDict, Type, TypeVar, cast
18
+ from collections import OrderedDict
19
+ from collections.abc import MutableMapping
20
+ from typing import Any, TypeVar, cast
19
21
 
20
22
  from google.protobuf.message import Message as GrpcMessage
21
23
 
22
24
  # pylint: disable=E0611
25
+ from flwr.proto.clientappio_pb2 import ClientAppOutputCode, ClientAppOutputStatus
23
26
  from flwr.proto.error_pb2 import Error as ProtoError
27
+ from flwr.proto.fab_pb2 import Fab as ProtoFab
28
+ from flwr.proto.message_pb2 import Context as ProtoContext
29
+ from flwr.proto.message_pb2 import Message as ProtoMessage
30
+ from flwr.proto.message_pb2 import Metadata as ProtoMetadata
24
31
  from flwr.proto.node_pb2 import Node
25
32
  from flwr.proto.recordset_pb2 import Array as ProtoArray
26
33
  from flwr.proto.recordset_pb2 import BoolList, BytesList
@@ -31,7 +38,9 @@ from flwr.proto.recordset_pb2 import MetricsRecord as ProtoMetricsRecord
31
38
  from flwr.proto.recordset_pb2 import MetricsRecordValue as ProtoMetricsRecordValue
32
39
  from flwr.proto.recordset_pb2 import ParametersRecord as ProtoParametersRecord
33
40
  from flwr.proto.recordset_pb2 import RecordSet as ProtoRecordSet
34
- from flwr.proto.recordset_pb2 import Sint64List, StringList
41
+ from flwr.proto.recordset_pb2 import SintList, StringList, UintList
42
+ from flwr.proto.run_pb2 import Run as ProtoRun
43
+ from flwr.proto.run_pb2 import RunStatus as ProtoRunStatus
35
44
  from flwr.proto.task_pb2 import Task, TaskIns, TaskRes
36
45
  from flwr.proto.transport_pb2 import (
37
46
  ClientMessage,
@@ -44,7 +53,15 @@ from flwr.proto.transport_pb2 import (
44
53
  )
45
54
 
46
55
  # pylint: enable=E0611
47
- from . import Array, ConfigsRecord, MetricsRecord, ParametersRecord, RecordSet, typing
56
+ from . import (
57
+ Array,
58
+ ConfigsRecord,
59
+ Context,
60
+ MetricsRecord,
61
+ ParametersRecord,
62
+ RecordSet,
63
+ typing,
64
+ )
48
65
  from .message import Error, Message, Metadata
49
66
  from .record.typeddict import TypedDict
50
67
 
@@ -58,7 +75,7 @@ def parameters_to_proto(parameters: typing.Parameters) -> Parameters:
58
75
 
59
76
  def parameters_from_proto(msg: Parameters) -> typing.Parameters:
60
77
  """Deserialize `Parameters` from ProtoBuf."""
61
- tensors: List[bytes] = list(msg.tensors)
78
+ tensors: list[bytes] = list(msg.tensors)
62
79
  return typing.Parameters(tensors=tensors, tensor_type=msg.tensor_type)
63
80
 
64
81
 
@@ -324,6 +341,7 @@ def metrics_from_proto(proto: Any) -> typing.Metrics:
324
341
 
325
342
 
326
343
  # === Scalar messages ===
344
+ INT64_MAX_VALUE = 9223372036854775807 # (1 << 63) - 1
327
345
 
328
346
 
329
347
  def scalar_to_proto(scalar: typing.Scalar) -> Scalar:
@@ -338,6 +356,9 @@ def scalar_to_proto(scalar: typing.Scalar) -> Scalar:
338
356
  return Scalar(double=scalar)
339
357
 
340
358
  if isinstance(scalar, int):
359
+ # Use uint64 for integers larger than the maximum value of sint64
360
+ if scalar > INT64_MAX_VALUE:
361
+ return Scalar(uint64=scalar)
341
362
  return Scalar(sint64=scalar)
342
363
 
343
364
  if isinstance(scalar, str):
@@ -358,16 +379,16 @@ def scalar_from_proto(scalar_msg: Scalar) -> typing.Scalar:
358
379
  # === Record messages ===
359
380
 
360
381
 
361
- _type_to_field = {
382
+ _type_to_field: dict[type, str] = {
362
383
  float: "double",
363
384
  int: "sint64",
364
385
  bool: "bool",
365
386
  str: "string",
366
387
  bytes: "bytes",
367
388
  }
368
- _list_type_to_class_and_field = {
389
+ _list_type_to_class_and_field: dict[type, tuple[type[GrpcMessage], str]] = {
369
390
  float: (DoubleList, "double_list"),
370
- int: (Sint64List, "sint64_list"),
391
+ int: (SintList, "sint_list"),
371
392
  bool: (BoolList, "bool_list"),
372
393
  str: (StringList, "string_list"),
373
394
  bytes: (BytesList, "bytes_list"),
@@ -375,8 +396,13 @@ _list_type_to_class_and_field = {
375
396
  T = TypeVar("T")
376
397
 
377
398
 
399
+ def _is_uint64(value: Any) -> bool:
400
+ """Check if a value is uint64."""
401
+ return isinstance(value, int) and value > INT64_MAX_VALUE
402
+
403
+
378
404
  def _record_value_to_proto(
379
- value: Any, allowed_types: List[type], proto_class: Type[T]
405
+ value: Any, allowed_types: list[type], proto_class: type[T]
380
406
  ) -> T:
381
407
  """Serialize `*RecordValue` to ProtoBuf.
382
408
 
@@ -387,12 +413,18 @@ def _record_value_to_proto(
387
413
  # Single element
388
414
  # Note: `isinstance(False, int) == True`.
389
415
  if isinstance(value, t):
390
- arg[_type_to_field[t]] = value
416
+ fld = _type_to_field[t]
417
+ if t is int and _is_uint64(value):
418
+ fld = "uint64"
419
+ arg[fld] = value
391
420
  return proto_class(**arg)
392
421
  # List
393
422
  if isinstance(value, list) and all(isinstance(item, t) for item in value):
394
- list_class, field_name = _list_type_to_class_and_field[t]
395
- arg[field_name] = list_class(vals=value)
423
+ list_class, fld = _list_type_to_class_and_field[t]
424
+ # Use UintList if any element is of type `uint64`.
425
+ if t is int and any(_is_uint64(v) for v in value):
426
+ list_class, fld = UintList, "uint_list"
427
+ arg[fld] = list_class(vals=value)
396
428
  return proto_class(**arg)
397
429
  # Invalid types
398
430
  raise TypeError(
@@ -413,9 +445,9 @@ def _record_value_from_proto(value_proto: GrpcMessage) -> Any:
413
445
 
414
446
  def _record_value_dict_to_proto(
415
447
  value_dict: TypedDict[str, Any],
416
- allowed_types: List[type],
417
- value_proto_class: Type[T],
418
- ) -> Dict[str, T]:
448
+ allowed_types: list[type],
449
+ value_proto_class: type[T],
450
+ ) -> dict[str, T]:
419
451
  """Serialize the record value dict to ProtoBuf.
420
452
 
421
453
  Note: `bool` MUST be put in the front of allowd_types if it exists.
@@ -433,7 +465,7 @@ def _record_value_dict_to_proto(
433
465
 
434
466
  def _record_value_dict_from_proto(
435
467
  value_dict_proto: MutableMapping[str, Any]
436
- ) -> Dict[str, Any]:
468
+ ) -> dict[str, Any]:
437
469
  """Deserialize the record value dict from ProtoBuf."""
438
470
  return {k: _record_value_from_proto(v) for k, v in value_dict_proto.items()}
439
471
 
@@ -484,7 +516,7 @@ def metrics_record_from_proto(record_proto: ProtoMetricsRecord) -> MetricsRecord
484
516
  """Deserialize MetricsRecord from ProtoBuf."""
485
517
  return MetricsRecord(
486
518
  metrics_dict=cast(
487
- Dict[str, typing.MetricsRecordValues],
519
+ dict[str, typing.MetricsRecordValues],
488
520
  _record_value_dict_from_proto(record_proto.data),
489
521
  ),
490
522
  keep_input=False,
@@ -506,7 +538,7 @@ def configs_record_from_proto(record_proto: ProtoConfigsRecord) -> ConfigsRecord
506
538
  """Deserialize ConfigsRecord from ProtoBuf."""
507
539
  return ConfigsRecord(
508
540
  configs_dict=cast(
509
- Dict[str, typing.ConfigsRecordValues],
541
+ dict[str, typing.ConfigsRecordValues],
510
542
  _record_value_dict_from_proto(record_proto.data),
511
543
  ),
512
544
  keep_input=False,
@@ -575,6 +607,7 @@ def message_to_taskins(message: Message) -> TaskIns:
575
607
  task=Task(
576
608
  producer=Node(node_id=0, anonymous=True), # Assume driver node
577
609
  consumer=Node(node_id=md.dst_node_id, anonymous=False),
610
+ created_at=md.created_at,
578
611
  ttl=md.ttl,
579
612
  ancestry=[md.reply_to_message] if md.reply_to_message != "" else [],
580
613
  task_type=md.message_type,
@@ -601,7 +634,7 @@ def message_from_taskins(taskins: TaskIns) -> Message:
601
634
  )
602
635
 
603
636
  # Construct Message
604
- return Message(
637
+ message = Message(
605
638
  metadata=metadata,
606
639
  content=(
607
640
  recordset_from_proto(taskins.task.recordset)
@@ -614,6 +647,8 @@ def message_from_taskins(taskins: TaskIns) -> Message:
614
647
  else None
615
648
  ),
616
649
  )
650
+ message.metadata.created_at = taskins.task.created_at
651
+ return message
617
652
 
618
653
 
619
654
  def message_to_taskres(message: Message) -> TaskRes:
@@ -626,6 +661,7 @@ def message_to_taskres(message: Message) -> TaskRes:
626
661
  task=Task(
627
662
  producer=Node(node_id=md.src_node_id, anonymous=False),
628
663
  consumer=Node(node_id=0, anonymous=True), # Assume driver node
664
+ created_at=md.created_at,
629
665
  ttl=md.ttl,
630
666
  ancestry=[md.reply_to_message] if md.reply_to_message != "" else [],
631
667
  task_type=md.message_type,
@@ -652,7 +688,7 @@ def message_from_taskres(taskres: TaskRes) -> Message:
652
688
  )
653
689
 
654
690
  # Construct the Message
655
- return Message(
691
+ message = Message(
656
692
  metadata=metadata,
657
693
  content=(
658
694
  recordset_from_proto(taskres.task.recordset)
@@ -665,3 +701,246 @@ def message_from_taskres(taskres: TaskRes) -> Message:
665
701
  else None
666
702
  ),
667
703
  )
704
+ message.metadata.created_at = taskres.task.created_at
705
+ return message
706
+
707
+
708
+ # === FAB ===
709
+
710
+
711
+ def fab_to_proto(fab: typing.Fab) -> ProtoFab:
712
+ """Create a proto Fab object from a Python Fab."""
713
+ return ProtoFab(hash_str=fab.hash_str, content=fab.content)
714
+
715
+
716
+ def fab_from_proto(fab: ProtoFab) -> typing.Fab:
717
+ """Create a Python Fab object from a proto Fab."""
718
+ return typing.Fab(fab.hash_str, fab.content)
719
+
720
+
721
+ # === User configs ===
722
+
723
+
724
+ def user_config_to_proto(user_config: typing.UserConfig) -> Any:
725
+ """Serialize `UserConfig` to ProtoBuf."""
726
+ proto = {}
727
+ for key, value in user_config.items():
728
+ proto[key] = user_config_value_to_proto(value)
729
+ return proto
730
+
731
+
732
+ def user_config_from_proto(proto: Any) -> typing.UserConfig:
733
+ """Deserialize `UserConfig` from ProtoBuf."""
734
+ metrics = {}
735
+ for key, value in proto.items():
736
+ metrics[key] = user_config_value_from_proto(value)
737
+ return metrics
738
+
739
+
740
+ def user_config_value_to_proto(user_config_value: typing.UserConfigValue) -> Scalar:
741
+ """Serialize `UserConfigValue` to ProtoBuf."""
742
+ if isinstance(user_config_value, bool):
743
+ return Scalar(bool=user_config_value)
744
+
745
+ if isinstance(user_config_value, float):
746
+ return Scalar(double=user_config_value)
747
+
748
+ if isinstance(user_config_value, int):
749
+ return Scalar(sint64=user_config_value)
750
+
751
+ if isinstance(user_config_value, str):
752
+ return Scalar(string=user_config_value)
753
+
754
+ raise ValueError(
755
+ f"Accepted types: {bool, float, int, str} (but not {type(user_config_value)})"
756
+ )
757
+
758
+
759
+ def user_config_value_from_proto(scalar_msg: Scalar) -> typing.UserConfigValue:
760
+ """Deserialize `UserConfigValue` from ProtoBuf."""
761
+ scalar_field = scalar_msg.WhichOneof("scalar")
762
+ scalar = getattr(scalar_msg, cast(str, scalar_field))
763
+ return cast(typing.UserConfigValue, scalar)
764
+
765
+
766
+ # === Metadata messages ===
767
+
768
+
769
+ def metadata_to_proto(metadata: Metadata) -> ProtoMetadata:
770
+ """Serialize `Metadata` to ProtoBuf."""
771
+ proto = ProtoMetadata( # pylint: disable=E1101
772
+ run_id=metadata.run_id,
773
+ message_id=metadata.message_id,
774
+ src_node_id=metadata.src_node_id,
775
+ dst_node_id=metadata.dst_node_id,
776
+ reply_to_message=metadata.reply_to_message,
777
+ group_id=metadata.group_id,
778
+ ttl=metadata.ttl,
779
+ message_type=metadata.message_type,
780
+ created_at=metadata.created_at,
781
+ )
782
+ return proto
783
+
784
+
785
+ def metadata_from_proto(metadata_proto: ProtoMetadata) -> Metadata:
786
+ """Deserialize `Metadata` from ProtoBuf."""
787
+ metadata = Metadata(
788
+ run_id=metadata_proto.run_id,
789
+ message_id=metadata_proto.message_id,
790
+ src_node_id=metadata_proto.src_node_id,
791
+ dst_node_id=metadata_proto.dst_node_id,
792
+ reply_to_message=metadata_proto.reply_to_message,
793
+ group_id=metadata_proto.group_id,
794
+ ttl=metadata_proto.ttl,
795
+ message_type=metadata_proto.message_type,
796
+ )
797
+ return metadata
798
+
799
+
800
+ # === Message messages ===
801
+
802
+
803
+ def message_to_proto(message: Message) -> ProtoMessage:
804
+ """Serialize `Message` to ProtoBuf."""
805
+ proto = ProtoMessage(
806
+ metadata=metadata_to_proto(message.metadata),
807
+ content=(
808
+ recordset_to_proto(message.content) if message.has_content() else None
809
+ ),
810
+ error=error_to_proto(message.error) if message.has_error() else None,
811
+ )
812
+ return proto
813
+
814
+
815
+ def message_from_proto(message_proto: ProtoMessage) -> Message:
816
+ """Deserialize `Message` from ProtoBuf."""
817
+ created_at = message_proto.metadata.created_at
818
+ message = Message(
819
+ metadata=metadata_from_proto(message_proto.metadata),
820
+ content=(
821
+ recordset_from_proto(message_proto.content)
822
+ if message_proto.HasField("content")
823
+ else None
824
+ ),
825
+ error=(
826
+ error_from_proto(message_proto.error)
827
+ if message_proto.HasField("error")
828
+ else None
829
+ ),
830
+ )
831
+ # `.created_at` is set upon Message object construction
832
+ # we need to manually set it to the original value
833
+ message.metadata.created_at = created_at
834
+ return message
835
+
836
+
837
+ # === Context messages ===
838
+
839
+
840
+ def context_to_proto(context: Context) -> ProtoContext:
841
+ """Serialize `Context` to ProtoBuf."""
842
+ proto = ProtoContext(
843
+ run_id=context.run_id,
844
+ node_id=context.node_id,
845
+ node_config=user_config_to_proto(context.node_config),
846
+ state=recordset_to_proto(context.state),
847
+ run_config=user_config_to_proto(context.run_config),
848
+ )
849
+ return proto
850
+
851
+
852
+ def context_from_proto(context_proto: ProtoContext) -> Context:
853
+ """Deserialize `Context` from ProtoBuf."""
854
+ context = Context(
855
+ run_id=context_proto.run_id,
856
+ node_id=context_proto.node_id,
857
+ node_config=user_config_from_proto(context_proto.node_config),
858
+ state=recordset_from_proto(context_proto.state),
859
+ run_config=user_config_from_proto(context_proto.run_config),
860
+ )
861
+ return context
862
+
863
+
864
+ # === Run messages ===
865
+
866
+
867
+ def run_to_proto(run: typing.Run) -> ProtoRun:
868
+ """Serialize `Run` to ProtoBuf."""
869
+ proto = ProtoRun(
870
+ run_id=run.run_id,
871
+ fab_id=run.fab_id,
872
+ fab_version=run.fab_version,
873
+ fab_hash=run.fab_hash,
874
+ override_config=user_config_to_proto(run.override_config),
875
+ pending_at=run.pending_at,
876
+ starting_at=run.starting_at,
877
+ running_at=run.running_at,
878
+ finished_at=run.finished_at,
879
+ status=run_status_to_proto(run.status),
880
+ )
881
+ return proto
882
+
883
+
884
+ def run_from_proto(run_proto: ProtoRun) -> typing.Run:
885
+ """Deserialize `Run` from ProtoBuf."""
886
+ run = typing.Run(
887
+ run_id=run_proto.run_id,
888
+ fab_id=run_proto.fab_id,
889
+ fab_version=run_proto.fab_version,
890
+ fab_hash=run_proto.fab_hash,
891
+ override_config=user_config_from_proto(run_proto.override_config),
892
+ pending_at=run_proto.pending_at,
893
+ starting_at=run_proto.starting_at,
894
+ running_at=run_proto.running_at,
895
+ finished_at=run_proto.finished_at,
896
+ status=run_status_from_proto(run_proto.status),
897
+ )
898
+ return run
899
+
900
+
901
+ # === ClientApp status messages ===
902
+
903
+
904
+ def clientappstatus_to_proto(
905
+ status: typing.ClientAppOutputStatus,
906
+ ) -> ClientAppOutputStatus:
907
+ """Serialize `ClientAppOutputStatus` to ProtoBuf."""
908
+ code = ClientAppOutputCode.SUCCESS
909
+ if status.code == typing.ClientAppOutputCode.DEADLINE_EXCEEDED:
910
+ code = ClientAppOutputCode.DEADLINE_EXCEEDED
911
+ if status.code == typing.ClientAppOutputCode.UNKNOWN_ERROR:
912
+ code = ClientAppOutputCode.UNKNOWN_ERROR
913
+ return ClientAppOutputStatus(code=code, message=status.message)
914
+
915
+
916
+ def clientappstatus_from_proto(
917
+ msg: ClientAppOutputStatus,
918
+ ) -> typing.ClientAppOutputStatus:
919
+ """Deserialize `ClientAppOutputStatus` from ProtoBuf."""
920
+ code = typing.ClientAppOutputCode.SUCCESS
921
+ if msg.code == ClientAppOutputCode.DEADLINE_EXCEEDED:
922
+ code = typing.ClientAppOutputCode.DEADLINE_EXCEEDED
923
+ if msg.code == ClientAppOutputCode.UNKNOWN_ERROR:
924
+ code = typing.ClientAppOutputCode.UNKNOWN_ERROR
925
+ return typing.ClientAppOutputStatus(code=code, message=msg.message)
926
+
927
+
928
+ # === Run status ===
929
+
930
+
931
+ def run_status_to_proto(run_status: typing.RunStatus) -> ProtoRunStatus:
932
+ """Serialize `RunStatus` to ProtoBuf."""
933
+ return ProtoRunStatus(
934
+ status=run_status.status,
935
+ sub_status=run_status.sub_status,
936
+ details=run_status.details,
937
+ )
938
+
939
+
940
+ def run_status_from_proto(run_status_proto: ProtoRunStatus) -> typing.RunStatus:
941
+ """Deserialize `RunStatus` from ProtoBuf."""
942
+ return typing.RunStatus(
943
+ status=run_status_proto.status,
944
+ sub_status=run_status_proto.sub_status,
945
+ details=run_status_proto.details,
946
+ )
flwr/common/telemetry.py CHANGED
@@ -25,8 +25,9 @@ import uuid
25
25
  from concurrent.futures import Future, ThreadPoolExecutor
26
26
  from enum import Enum, auto
27
27
  from pathlib import Path
28
- from typing import Any, Dict, List, Optional, Union, cast
28
+ from typing import Any, Optional, Union, cast
29
29
 
30
+ from flwr.common.constant import FLWR_DIR
30
31
  from flwr.common.version import package_name, package_version
31
32
 
32
33
  FLWR_TELEMETRY_ENABLED = os.getenv("FLWR_TELEMETRY_ENABLED", "1")
@@ -64,6 +65,18 @@ def _get_home() -> Path:
64
65
  return Path().home()
65
66
 
66
67
 
68
+ def _get_partner_id() -> str:
69
+ """Get partner ID."""
70
+ partner_id = os.getenv("FLWR_TELEMETRY_PARTNER_ID")
71
+ if not partner_id:
72
+ return "unavailable"
73
+ try:
74
+ uuid.UUID(partner_id)
75
+ except ValueError:
76
+ partner_id = "invalid"
77
+ return partner_id
78
+
79
+
67
80
  def _get_source_id() -> str:
68
81
  """Get existing or new source ID."""
69
82
  source_id = "unavailable"
@@ -74,7 +87,7 @@ def _get_source_id() -> str:
74
87
  # If the home directory can’t be resolved, RuntimeError is raised.
75
88
  return source_id
76
89
 
77
- flwr_dir = home.joinpath(".flwr")
90
+ flwr_dir = home.joinpath(FLWR_DIR)
78
91
  # Create .flwr directory if it does not exist yet.
79
92
  try:
80
93
  flwr_dir.mkdir(parents=True, exist_ok=True)
@@ -114,67 +127,86 @@ class EventType(str, Enum):
114
127
  # The type signature is not compatible with mypy, pylint and flake8
115
128
  # so each of those needs to be disabled for this line.
116
129
  # pylint: disable-next=no-self-argument,arguments-differ,line-too-long
117
- def _generate_next_value_(name: str, start: int, count: int, last_values: List[Any]) -> Any: # type: ignore # noqa: E501
130
+ def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> Any: # type: ignore # noqa: E501
118
131
  return name
119
132
 
120
133
  # Ping
121
134
  PING = auto()
122
135
 
123
- # Client: start_client
136
+ # --- LEGACY FUNCTIONS -------------------------------------------------------------
137
+
138
+ # Legacy: `start_client` function
124
139
  START_CLIENT_ENTER = auto()
125
140
  START_CLIENT_LEAVE = auto()
126
141
 
127
- # Server: start_server
142
+ # Legacy: `start_server` function
128
143
  START_SERVER_ENTER = auto()
129
144
  START_SERVER_LEAVE = auto()
130
145
 
131
- # Driver API
132
- RUN_DRIVER_API_ENTER = auto()
133
- RUN_DRIVER_API_LEAVE = auto()
146
+ # Legacy: `start_simulation` function
147
+ START_SIMULATION_ENTER = auto()
148
+ START_SIMULATION_LEAVE = auto()
149
+
150
+ # --- `flwr` CLI -------------------------------------------------------------------
151
+
152
+ # Not yet implemented
153
+
154
+ # --- `flwr-*` commands ------------------------------------------------------------
155
+
156
+ # CLI: flwr-simulation
157
+ FLWR_SIMULATION_RUN_ENTER = auto()
158
+ FLWR_SIMULATION_RUN_LEAVE = auto()
159
+
160
+ # CLI: flwr-serverapp
161
+ FLWR_SERVERAPP_RUN_ENTER = auto()
162
+ FLWR_SERVERAPP_RUN_LEAVE = auto()
134
163
 
135
- # Fleet API
136
- RUN_FLEET_API_ENTER = auto()
137
- RUN_FLEET_API_LEAVE = auto()
164
+ # --- Simulation Engine ------------------------------------------------------------
138
165
 
139
- # Driver API and Fleet API
166
+ # CLI: flower-simulation
167
+ CLI_FLOWER_SIMULATION_ENTER = auto()
168
+ CLI_FLOWER_SIMULATION_LEAVE = auto()
169
+
170
+ # Python API: `run_simulation`
171
+ PYTHON_API_RUN_SIMULATION_ENTER = auto()
172
+ PYTHON_API_RUN_SIMULATION_LEAVE = auto()
173
+
174
+ # --- Deployment Engine ------------------------------------------------------------
175
+
176
+ # CLI: `flower-superlink`
140
177
  RUN_SUPERLINK_ENTER = auto()
141
178
  RUN_SUPERLINK_LEAVE = auto()
142
179
 
143
- # Simulation
144
- START_SIMULATION_ENTER = auto()
145
- START_SIMULATION_LEAVE = auto()
180
+ # CLI: `flower-supernode`
181
+ RUN_SUPERNODE_ENTER = auto()
182
+ RUN_SUPERNODE_LEAVE = auto()
146
183
 
147
- # Driver: Driver
148
- DRIVER_CONNECT = auto()
149
- DRIVER_DISCONNECT = auto()
184
+ # --- DEPRECATED -------------------------------------------------------------------
150
185
 
151
- # Driver: start_driver
152
- START_DRIVER_ENTER = auto()
153
- START_DRIVER_LEAVE = auto()
186
+ # [DEPRECATED] CLI: `flower-server-app`
187
+ RUN_SERVER_APP_ENTER = auto()
188
+ RUN_SERVER_APP_LEAVE = auto()
154
189
 
155
- # flower-client-app
190
+ # [DEPRECATED] CLI: `flower-client-app`
156
191
  RUN_CLIENT_APP_ENTER = auto()
157
192
  RUN_CLIENT_APP_LEAVE = auto()
158
193
 
159
- # flower-server-app
160
- RUN_SERVER_APP_ENTER = auto()
161
- RUN_SERVER_APP_LEAVE = auto()
162
-
163
194
 
164
195
  # Use the ThreadPoolExecutor with max_workers=1 to have a queue
165
196
  # and also ensure that telemetry calls are not blocking.
166
- state: Dict[str, Union[Optional[str], Optional[ThreadPoolExecutor]]] = {
197
+ state: dict[str, Union[Optional[str], Optional[ThreadPoolExecutor]]] = {
167
198
  # Will be assigned ThreadPoolExecutor(max_workers=1)
168
199
  # in event() the first time it's required
169
200
  "executor": None,
170
201
  "source": None,
171
202
  "cluster": None,
203
+ "partner": None,
172
204
  }
173
205
 
174
206
 
175
207
  def event(
176
208
  event_type: EventType,
177
- event_details: Optional[Dict[str, Any]] = None,
209
+ event_details: Optional[dict[str, Any]] = None,
178
210
  ) -> Future: # type: ignore
179
211
  """Submit create_event to ThreadPoolExecutor to avoid blocking."""
180
212
  if state["executor"] is None:
@@ -186,7 +218,7 @@ def event(
186
218
  return result
187
219
 
188
220
 
189
- def create_event(event_type: EventType, event_details: Optional[Dict[str, Any]]) -> str:
221
+ def create_event(event_type: EventType, event_details: Optional[dict[str, Any]]) -> str:
190
222
  """Create telemetry event."""
191
223
  if state["source"] is None:
192
224
  state["source"] = _get_source_id()
@@ -194,11 +226,15 @@ def create_event(event_type: EventType, event_details: Optional[Dict[str, Any]])
194
226
  if state["cluster"] is None:
195
227
  state["cluster"] = str(uuid.uuid4())
196
228
 
229
+ if state["partner"] is None:
230
+ state["partner"] = _get_partner_id()
231
+
197
232
  if event_details is None:
198
233
  event_details = {}
199
234
 
200
235
  date = datetime.datetime.now(tz=datetime.timezone.utc).isoformat()
201
236
  context = {
237
+ "partner": state["partner"],
202
238
  "source": state["source"],
203
239
  "cluster": state["cluster"],
204
240
  "date": date,