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
flwr/proto/driver_pb2.py DELETED
@@ -1,44 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Generated by the protocol buffer compiler. DO NOT EDIT!
3
- # source: flwr/proto/driver.proto
4
- # Protobuf Python Version: 4.25.0
5
- """Generated protocol buffer code."""
6
- from google.protobuf import descriptor as _descriptor
7
- from google.protobuf import descriptor_pool as _descriptor_pool
8
- from google.protobuf import symbol_database as _symbol_database
9
- from google.protobuf.internal import builder as _builder
10
- # @@protoc_insertion_point(imports)
11
-
12
- _sym_db = _symbol_database.Default()
13
-
14
-
15
- from flwr.proto import node_pb2 as flwr_dot_proto_dot_node__pb2
16
- from flwr.proto import task_pb2 as flwr_dot_proto_dot_task__pb2
17
-
18
-
19
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x17\x66lwr/proto/driver.proto\x12\nflwr.proto\x1a\x15\x66lwr/proto/node.proto\x1a\x15\x66lwr/proto/task.proto\"\x12\n\x10\x43reateRunRequest\"#\n\x11\x43reateRunResponse\x12\x0e\n\x06run_id\x18\x01 \x01(\x12\"!\n\x0fGetNodesRequest\x12\x0e\n\x06run_id\x18\x01 \x01(\x12\"3\n\x10GetNodesResponse\x12\x1f\n\x05nodes\x18\x01 \x03(\x0b\x32\x10.flwr.proto.Node\"@\n\x12PushTaskInsRequest\x12*\n\rtask_ins_list\x18\x01 \x03(\x0b\x32\x13.flwr.proto.TaskIns\"\'\n\x13PushTaskInsResponse\x12\x10\n\x08task_ids\x18\x02 \x03(\t\"F\n\x12PullTaskResRequest\x12\x1e\n\x04node\x18\x01 \x01(\x0b\x32\x10.flwr.proto.Node\x12\x10\n\x08task_ids\x18\x02 \x03(\t\"A\n\x13PullTaskResResponse\x12*\n\rtask_res_list\x18\x01 \x03(\x0b\x32\x13.flwr.proto.TaskRes2\xc1\x02\n\x06\x44river\x12J\n\tCreateRun\x12\x1c.flwr.proto.CreateRunRequest\x1a\x1d.flwr.proto.CreateRunResponse\"\x00\x12G\n\x08GetNodes\x12\x1b.flwr.proto.GetNodesRequest\x1a\x1c.flwr.proto.GetNodesResponse\"\x00\x12P\n\x0bPushTaskIns\x12\x1e.flwr.proto.PushTaskInsRequest\x1a\x1f.flwr.proto.PushTaskInsResponse\"\x00\x12P\n\x0bPullTaskRes\x12\x1e.flwr.proto.PullTaskResRequest\x1a\x1f.flwr.proto.PullTaskResResponse\"\x00\x62\x06proto3')
20
-
21
- _globals = globals()
22
- _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
23
- _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'flwr.proto.driver_pb2', _globals)
24
- if _descriptor._USE_C_DESCRIPTORS == False:
25
- DESCRIPTOR._options = None
26
- _globals['_CREATERUNREQUEST']._serialized_start=85
27
- _globals['_CREATERUNREQUEST']._serialized_end=103
28
- _globals['_CREATERUNRESPONSE']._serialized_start=105
29
- _globals['_CREATERUNRESPONSE']._serialized_end=140
30
- _globals['_GETNODESREQUEST']._serialized_start=142
31
- _globals['_GETNODESREQUEST']._serialized_end=175
32
- _globals['_GETNODESRESPONSE']._serialized_start=177
33
- _globals['_GETNODESRESPONSE']._serialized_end=228
34
- _globals['_PUSHTASKINSREQUEST']._serialized_start=230
35
- _globals['_PUSHTASKINSREQUEST']._serialized_end=294
36
- _globals['_PUSHTASKINSRESPONSE']._serialized_start=296
37
- _globals['_PUSHTASKINSRESPONSE']._serialized_end=335
38
- _globals['_PULLTASKRESREQUEST']._serialized_start=337
39
- _globals['_PULLTASKRESREQUEST']._serialized_end=407
40
- _globals['_PULLTASKRESRESPONSE']._serialized_start=409
41
- _globals['_PULLTASKRESRESPONSE']._serialized_end=474
42
- _globals['_DRIVER']._serialized_start=477
43
- _globals['_DRIVER']._serialized_end=798
44
- # @@protoc_insertion_point(module_scope)
@@ -1,169 +0,0 @@
1
- # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
- """Client and server classes corresponding to protobuf-defined services."""
3
- import grpc
4
-
5
- from flwr.proto import driver_pb2 as flwr_dot_proto_dot_driver__pb2
6
-
7
-
8
- class DriverStub(object):
9
- """Missing associated documentation comment in .proto file."""
10
-
11
- def __init__(self, channel):
12
- """Constructor.
13
-
14
- Args:
15
- channel: A grpc.Channel.
16
- """
17
- self.CreateRun = channel.unary_unary(
18
- '/flwr.proto.Driver/CreateRun',
19
- request_serializer=flwr_dot_proto_dot_driver__pb2.CreateRunRequest.SerializeToString,
20
- response_deserializer=flwr_dot_proto_dot_driver__pb2.CreateRunResponse.FromString,
21
- )
22
- self.GetNodes = channel.unary_unary(
23
- '/flwr.proto.Driver/GetNodes',
24
- request_serializer=flwr_dot_proto_dot_driver__pb2.GetNodesRequest.SerializeToString,
25
- response_deserializer=flwr_dot_proto_dot_driver__pb2.GetNodesResponse.FromString,
26
- )
27
- self.PushTaskIns = channel.unary_unary(
28
- '/flwr.proto.Driver/PushTaskIns',
29
- request_serializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsRequest.SerializeToString,
30
- response_deserializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsResponse.FromString,
31
- )
32
- self.PullTaskRes = channel.unary_unary(
33
- '/flwr.proto.Driver/PullTaskRes',
34
- request_serializer=flwr_dot_proto_dot_driver__pb2.PullTaskResRequest.SerializeToString,
35
- response_deserializer=flwr_dot_proto_dot_driver__pb2.PullTaskResResponse.FromString,
36
- )
37
-
38
-
39
- class DriverServicer(object):
40
- """Missing associated documentation comment in .proto file."""
41
-
42
- def CreateRun(self, request, context):
43
- """Request run_id
44
- """
45
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
46
- context.set_details('Method not implemented!')
47
- raise NotImplementedError('Method not implemented!')
48
-
49
- def GetNodes(self, request, context):
50
- """Return a set of nodes
51
- """
52
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
53
- context.set_details('Method not implemented!')
54
- raise NotImplementedError('Method not implemented!')
55
-
56
- def PushTaskIns(self, request, context):
57
- """Create one or more tasks
58
- """
59
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
60
- context.set_details('Method not implemented!')
61
- raise NotImplementedError('Method not implemented!')
62
-
63
- def PullTaskRes(self, request, context):
64
- """Get task results
65
- """
66
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
67
- context.set_details('Method not implemented!')
68
- raise NotImplementedError('Method not implemented!')
69
-
70
-
71
- def add_DriverServicer_to_server(servicer, server):
72
- rpc_method_handlers = {
73
- 'CreateRun': grpc.unary_unary_rpc_method_handler(
74
- servicer.CreateRun,
75
- request_deserializer=flwr_dot_proto_dot_driver__pb2.CreateRunRequest.FromString,
76
- response_serializer=flwr_dot_proto_dot_driver__pb2.CreateRunResponse.SerializeToString,
77
- ),
78
- 'GetNodes': grpc.unary_unary_rpc_method_handler(
79
- servicer.GetNodes,
80
- request_deserializer=flwr_dot_proto_dot_driver__pb2.GetNodesRequest.FromString,
81
- response_serializer=flwr_dot_proto_dot_driver__pb2.GetNodesResponse.SerializeToString,
82
- ),
83
- 'PushTaskIns': grpc.unary_unary_rpc_method_handler(
84
- servicer.PushTaskIns,
85
- request_deserializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsRequest.FromString,
86
- response_serializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsResponse.SerializeToString,
87
- ),
88
- 'PullTaskRes': grpc.unary_unary_rpc_method_handler(
89
- servicer.PullTaskRes,
90
- request_deserializer=flwr_dot_proto_dot_driver__pb2.PullTaskResRequest.FromString,
91
- response_serializer=flwr_dot_proto_dot_driver__pb2.PullTaskResResponse.SerializeToString,
92
- ),
93
- }
94
- generic_handler = grpc.method_handlers_generic_handler(
95
- 'flwr.proto.Driver', rpc_method_handlers)
96
- server.add_generic_rpc_handlers((generic_handler,))
97
-
98
-
99
- # This class is part of an EXPERIMENTAL API.
100
- class Driver(object):
101
- """Missing associated documentation comment in .proto file."""
102
-
103
- @staticmethod
104
- def CreateRun(request,
105
- target,
106
- options=(),
107
- channel_credentials=None,
108
- call_credentials=None,
109
- insecure=False,
110
- compression=None,
111
- wait_for_ready=None,
112
- timeout=None,
113
- metadata=None):
114
- return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/CreateRun',
115
- flwr_dot_proto_dot_driver__pb2.CreateRunRequest.SerializeToString,
116
- flwr_dot_proto_dot_driver__pb2.CreateRunResponse.FromString,
117
- options, channel_credentials,
118
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
119
-
120
- @staticmethod
121
- def GetNodes(request,
122
- target,
123
- options=(),
124
- channel_credentials=None,
125
- call_credentials=None,
126
- insecure=False,
127
- compression=None,
128
- wait_for_ready=None,
129
- timeout=None,
130
- metadata=None):
131
- return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/GetNodes',
132
- flwr_dot_proto_dot_driver__pb2.GetNodesRequest.SerializeToString,
133
- flwr_dot_proto_dot_driver__pb2.GetNodesResponse.FromString,
134
- options, channel_credentials,
135
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
136
-
137
- @staticmethod
138
- def PushTaskIns(request,
139
- target,
140
- options=(),
141
- channel_credentials=None,
142
- call_credentials=None,
143
- insecure=False,
144
- compression=None,
145
- wait_for_ready=None,
146
- timeout=None,
147
- metadata=None):
148
- return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/PushTaskIns',
149
- flwr_dot_proto_dot_driver__pb2.PushTaskInsRequest.SerializeToString,
150
- flwr_dot_proto_dot_driver__pb2.PushTaskInsResponse.FromString,
151
- options, channel_credentials,
152
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
153
-
154
- @staticmethod
155
- def PullTaskRes(request,
156
- target,
157
- options=(),
158
- channel_credentials=None,
159
- call_credentials=None,
160
- insecure=False,
161
- compression=None,
162
- wait_for_ready=None,
163
- timeout=None,
164
- metadata=None):
165
- return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/PullTaskRes',
166
- flwr_dot_proto_dot_driver__pb2.PullTaskResRequest.SerializeToString,
167
- flwr_dot_proto_dot_driver__pb2.PullTaskResResponse.FromString,
168
- options, channel_credentials,
169
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@@ -1,66 +0,0 @@
1
- """
2
- @generated by mypy-protobuf. Do not edit manually!
3
- isort:skip_file
4
- """
5
- import abc
6
- import flwr.proto.driver_pb2
7
- import grpc
8
-
9
- class DriverStub:
10
- def __init__(self, channel: grpc.Channel) -> None: ...
11
- CreateRun: grpc.UnaryUnaryMultiCallable[
12
- flwr.proto.driver_pb2.CreateRunRequest,
13
- flwr.proto.driver_pb2.CreateRunResponse]
14
- """Request run_id"""
15
-
16
- GetNodes: grpc.UnaryUnaryMultiCallable[
17
- flwr.proto.driver_pb2.GetNodesRequest,
18
- flwr.proto.driver_pb2.GetNodesResponse]
19
- """Return a set of nodes"""
20
-
21
- PushTaskIns: grpc.UnaryUnaryMultiCallable[
22
- flwr.proto.driver_pb2.PushTaskInsRequest,
23
- flwr.proto.driver_pb2.PushTaskInsResponse]
24
- """Create one or more tasks"""
25
-
26
- PullTaskRes: grpc.UnaryUnaryMultiCallable[
27
- flwr.proto.driver_pb2.PullTaskResRequest,
28
- flwr.proto.driver_pb2.PullTaskResResponse]
29
- """Get task results"""
30
-
31
-
32
- class DriverServicer(metaclass=abc.ABCMeta):
33
- @abc.abstractmethod
34
- def CreateRun(self,
35
- request: flwr.proto.driver_pb2.CreateRunRequest,
36
- context: grpc.ServicerContext,
37
- ) -> flwr.proto.driver_pb2.CreateRunResponse:
38
- """Request run_id"""
39
- pass
40
-
41
- @abc.abstractmethod
42
- def GetNodes(self,
43
- request: flwr.proto.driver_pb2.GetNodesRequest,
44
- context: grpc.ServicerContext,
45
- ) -> flwr.proto.driver_pb2.GetNodesResponse:
46
- """Return a set of nodes"""
47
- pass
48
-
49
- @abc.abstractmethod
50
- def PushTaskIns(self,
51
- request: flwr.proto.driver_pb2.PushTaskInsRequest,
52
- context: grpc.ServicerContext,
53
- ) -> flwr.proto.driver_pb2.PushTaskInsResponse:
54
- """Create one or more tasks"""
55
- pass
56
-
57
- @abc.abstractmethod
58
- def PullTaskRes(self,
59
- request: flwr.proto.driver_pb2.PullTaskResRequest,
60
- context: grpc.ServicerContext,
61
- ) -> flwr.proto.driver_pb2.PullTaskResResponse:
62
- """Get task results"""
63
- pass
64
-
65
-
66
- def add_DriverServicer_to_server(servicer: DriverServicer, server: grpc.Server) -> None: ...
@@ -1,54 +0,0 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ==============================================================================
15
- """Driver gRPC API."""
16
-
17
- from logging import INFO
18
- from typing import Optional, Tuple
19
-
20
- import grpc
21
-
22
- from flwr.common import GRPC_MAX_MESSAGE_LENGTH
23
- from flwr.common.logger import log
24
- from flwr.proto.driver_pb2_grpc import ( # pylint: disable=E0611
25
- add_DriverServicer_to_server,
26
- )
27
- from flwr.server.superlink.state import StateFactory
28
-
29
- from ..fleet.grpc_bidi.grpc_server import generic_create_grpc_server
30
- from .driver_servicer import DriverServicer
31
-
32
-
33
- def run_driver_api_grpc(
34
- address: str,
35
- state_factory: StateFactory,
36
- certificates: Optional[Tuple[bytes, bytes, bytes]],
37
- ) -> grpc.Server:
38
- """Run Driver API (gRPC, request-response)."""
39
- # Create Driver API gRPC server
40
- driver_servicer: grpc.Server = DriverServicer(
41
- state_factory=state_factory,
42
- )
43
- driver_add_servicer_to_server_fn = add_DriverServicer_to_server
44
- driver_grpc_server = generic_create_grpc_server(
45
- servicer_and_add_fn=(driver_servicer, driver_add_servicer_to_server_fn),
46
- server_address=address,
47
- max_message_length=GRPC_MAX_MESSAGE_LENGTH,
48
- certificates=certificates,
49
- )
50
-
51
- log(INFO, "Flower ECE: Starting Driver API (gRPC-rere) on %s", address)
52
- driver_grpc_server.start()
53
-
54
- return driver_grpc_server
@@ -1,129 +0,0 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ==============================================================================
15
- """Driver API servicer."""
16
-
17
-
18
- from logging import DEBUG, INFO
19
- from typing import List, Optional, Set
20
- from uuid import UUID
21
-
22
- import grpc
23
-
24
- from flwr.common.logger import log
25
- from flwr.proto import driver_pb2_grpc # pylint: disable=E0611
26
- from flwr.proto.driver_pb2 import ( # pylint: disable=E0611
27
- CreateRunRequest,
28
- CreateRunResponse,
29
- GetNodesRequest,
30
- GetNodesResponse,
31
- PullTaskResRequest,
32
- PullTaskResResponse,
33
- PushTaskInsRequest,
34
- PushTaskInsResponse,
35
- )
36
- from flwr.proto.node_pb2 import Node # pylint: disable=E0611
37
- from flwr.proto.task_pb2 import TaskRes # pylint: disable=E0611
38
- from flwr.server.superlink.state import State, StateFactory
39
- from flwr.server.utils.validator import validate_task_ins_or_res
40
-
41
-
42
- class DriverServicer(driver_pb2_grpc.DriverServicer):
43
- """Driver API servicer."""
44
-
45
- def __init__(self, state_factory: StateFactory) -> None:
46
- self.state_factory = state_factory
47
-
48
- def GetNodes(
49
- self, request: GetNodesRequest, context: grpc.ServicerContext
50
- ) -> GetNodesResponse:
51
- """Get available nodes."""
52
- log(DEBUG, "DriverServicer.GetNodes")
53
- state: State = self.state_factory.state()
54
- all_ids: Set[int] = state.get_nodes(request.run_id)
55
- nodes: List[Node] = [
56
- Node(node_id=node_id, anonymous=False) for node_id in all_ids
57
- ]
58
- return GetNodesResponse(nodes=nodes)
59
-
60
- def CreateRun(
61
- self, request: CreateRunRequest, context: grpc.ServicerContext
62
- ) -> CreateRunResponse:
63
- """Create run ID."""
64
- log(INFO, "DriverServicer.CreateRun")
65
- state: State = self.state_factory.state()
66
- run_id = state.create_run()
67
- return CreateRunResponse(run_id=run_id)
68
-
69
- def PushTaskIns(
70
- self, request: PushTaskInsRequest, context: grpc.ServicerContext
71
- ) -> PushTaskInsResponse:
72
- """Push a set of TaskIns."""
73
- log(DEBUG, "DriverServicer.PushTaskIns")
74
-
75
- # Validate request
76
- _raise_if(len(request.task_ins_list) == 0, "`task_ins_list` must not be empty")
77
- for task_ins in request.task_ins_list:
78
- validation_errors = validate_task_ins_or_res(task_ins)
79
- _raise_if(bool(validation_errors), ", ".join(validation_errors))
80
-
81
- # Init state
82
- state: State = self.state_factory.state()
83
-
84
- # Store each TaskIns
85
- task_ids: List[Optional[UUID]] = []
86
- for task_ins in request.task_ins_list:
87
- task_id: Optional[UUID] = state.store_task_ins(task_ins=task_ins)
88
- task_ids.append(task_id)
89
-
90
- return PushTaskInsResponse(
91
- task_ids=[str(task_id) if task_id else "" for task_id in task_ids]
92
- )
93
-
94
- def PullTaskRes(
95
- self, request: PullTaskResRequest, context: grpc.ServicerContext
96
- ) -> PullTaskResResponse:
97
- """Pull a set of TaskRes."""
98
- log(DEBUG, "DriverServicer.PullTaskRes")
99
-
100
- # Convert each task_id str to UUID
101
- task_ids: Set[UUID] = {UUID(task_id) for task_id in request.task_ids}
102
-
103
- # Init state
104
- state: State = self.state_factory.state()
105
-
106
- # Register callback
107
- def on_rpc_done() -> None:
108
- log(DEBUG, "DriverServicer.PullTaskRes callback: delete TaskIns/TaskRes")
109
-
110
- if context.is_active():
111
- return
112
- if context.code() != grpc.StatusCode.OK:
113
- return
114
-
115
- # Delete delivered TaskIns and TaskRes
116
- state.delete_tasks(task_ids=task_ids)
117
-
118
- context.add_callback(on_rpc_done)
119
-
120
- # Read from state
121
- task_res_list: List[TaskRes] = state.get_task_res(task_ids=task_ids, limit=None)
122
-
123
- context.set_code(grpc.StatusCode.OK)
124
- return PullTaskResResponse(task_res_list=task_res_list)
125
-
126
-
127
- def _raise_if(validation_error: bool, detail: str) -> None:
128
- if validation_error:
129
- raise ValueError(f"Malformed PushTaskInsRequest: {detail}")