flwr 1.15.2__py3-none-any.whl → 1.17.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 (120) hide show
  1. flwr/cli/build.py +2 -0
  2. flwr/cli/log.py +20 -21
  3. flwr/cli/new/templates/app/code/flwr_tune/client_app.py.tpl +1 -1
  4. flwr/cli/new/templates/app/pyproject.baseline.toml.tpl +1 -1
  5. flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +1 -1
  6. flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl +1 -1
  7. flwr/cli/new/templates/app/pyproject.jax.toml.tpl +1 -1
  8. flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +1 -1
  9. flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +1 -1
  10. flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +1 -1
  11. flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +1 -1
  12. flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +1 -1
  13. flwr/cli/run/run.py +5 -9
  14. flwr/client/app.py +6 -4
  15. flwr/client/client_app.py +260 -86
  16. flwr/client/clientapp/app.py +6 -2
  17. flwr/client/grpc_client/connection.py +24 -21
  18. flwr/client/message_handler/message_handler.py +28 -28
  19. flwr/client/mod/__init__.py +2 -2
  20. flwr/client/mod/centraldp_mods.py +7 -7
  21. flwr/client/mod/comms_mods.py +16 -22
  22. flwr/client/mod/localdp_mod.py +4 -4
  23. flwr/client/mod/secure_aggregation/secaggplus_mod.py +31 -31
  24. flwr/client/rest_client/connection.py +4 -6
  25. flwr/client/run_info_store.py +2 -2
  26. flwr/client/supernode/__init__.py +0 -2
  27. flwr/client/supernode/app.py +1 -11
  28. flwr/common/__init__.py +12 -4
  29. flwr/common/address.py +35 -0
  30. flwr/common/args.py +8 -2
  31. flwr/common/auth_plugin/auth_plugin.py +2 -1
  32. flwr/common/config.py +4 -4
  33. flwr/common/constant.py +16 -0
  34. flwr/common/context.py +4 -4
  35. flwr/common/event_log_plugin/__init__.py +22 -0
  36. flwr/common/event_log_plugin/event_log_plugin.py +60 -0
  37. flwr/common/grpc.py +1 -1
  38. flwr/common/logger.py +2 -2
  39. flwr/common/message.py +338 -102
  40. flwr/common/object_ref.py +0 -10
  41. flwr/common/record/__init__.py +8 -4
  42. flwr/common/record/arrayrecord.py +626 -0
  43. flwr/common/record/{configsrecord.py → configrecord.py} +75 -29
  44. flwr/common/record/conversion_utils.py +9 -18
  45. flwr/common/record/{metricsrecord.py → metricrecord.py} +78 -32
  46. flwr/common/record/recorddict.py +288 -0
  47. flwr/common/recorddict_compat.py +410 -0
  48. flwr/common/secure_aggregation/quantization.py +5 -1
  49. flwr/common/secure_aggregation/secaggplus_constants.py +1 -1
  50. flwr/common/serde.py +67 -190
  51. flwr/common/telemetry.py +0 -10
  52. flwr/common/typing.py +44 -8
  53. flwr/proto/exec_pb2.py +3 -3
  54. flwr/proto/exec_pb2.pyi +3 -3
  55. flwr/proto/message_pb2.py +12 -12
  56. flwr/proto/message_pb2.pyi +9 -9
  57. flwr/proto/recorddict_pb2.py +70 -0
  58. flwr/proto/{recordset_pb2.pyi → recorddict_pb2.pyi} +35 -35
  59. flwr/proto/run_pb2.py +31 -31
  60. flwr/proto/run_pb2.pyi +3 -3
  61. flwr/server/__init__.py +3 -1
  62. flwr/server/app.py +74 -3
  63. flwr/server/compat/__init__.py +2 -2
  64. flwr/server/compat/app.py +15 -12
  65. flwr/server/compat/app_utils.py +26 -18
  66. flwr/server/compat/{driver_client_proxy.py → grid_client_proxy.py} +41 -41
  67. flwr/server/fleet_event_log_interceptor.py +94 -0
  68. flwr/server/{driver → grid}/__init__.py +8 -7
  69. flwr/server/{driver/driver.py → grid/grid.py} +48 -19
  70. flwr/server/{driver/grpc_driver.py → grid/grpc_grid.py} +88 -56
  71. flwr/server/{driver/inmemory_driver.py → grid/inmemory_grid.py} +41 -54
  72. flwr/server/run_serverapp.py +6 -17
  73. flwr/server/server_app.py +126 -33
  74. flwr/server/serverapp/app.py +10 -10
  75. flwr/server/superlink/fleet/grpc_rere/fleet_servicer.py +2 -2
  76. flwr/server/superlink/fleet/message_handler/message_handler.py +8 -12
  77. flwr/server/superlink/fleet/vce/backend/backend.py +3 -3
  78. flwr/server/superlink/fleet/vce/backend/raybackend.py +2 -2
  79. flwr/server/superlink/fleet/vce/vce_api.py +33 -38
  80. flwr/server/superlink/linkstate/in_memory_linkstate.py +171 -132
  81. flwr/server/superlink/linkstate/linkstate.py +51 -64
  82. flwr/server/superlink/linkstate/sqlite_linkstate.py +253 -285
  83. flwr/server/superlink/linkstate/utils.py +171 -133
  84. flwr/server/superlink/{driver → serverappio}/__init__.py +1 -1
  85. flwr/server/superlink/{driver → serverappio}/serverappio_grpc.py +1 -1
  86. flwr/server/superlink/{driver → serverappio}/serverappio_servicer.py +27 -29
  87. flwr/server/superlink/simulation/simulationio_servicer.py +2 -2
  88. flwr/server/typing.py +3 -3
  89. flwr/server/utils/__init__.py +2 -2
  90. flwr/server/utils/validator.py +53 -68
  91. flwr/server/workflow/default_workflows.py +52 -58
  92. flwr/server/workflow/secure_aggregation/secaggplus_workflow.py +48 -50
  93. flwr/simulation/app.py +2 -2
  94. flwr/simulation/ray_transport/ray_actor.py +4 -2
  95. flwr/simulation/ray_transport/ray_client_proxy.py +34 -32
  96. flwr/simulation/run_simulation.py +15 -15
  97. flwr/superexec/app.py +0 -14
  98. flwr/superexec/deployment.py +4 -4
  99. flwr/superexec/exec_event_log_interceptor.py +135 -0
  100. flwr/superexec/exec_grpc.py +10 -4
  101. flwr/superexec/exec_servicer.py +6 -6
  102. flwr/superexec/exec_user_auth_interceptor.py +22 -4
  103. flwr/superexec/executor.py +3 -3
  104. flwr/superexec/simulation.py +3 -3
  105. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/METADATA +5 -5
  106. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/RECORD +111 -112
  107. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/entry_points.txt +0 -3
  108. flwr/client/message_handler/task_handler.py +0 -37
  109. flwr/common/record/parametersrecord.py +0 -204
  110. flwr/common/record/recordset.py +0 -202
  111. flwr/common/recordset_compat.py +0 -418
  112. flwr/proto/recordset_pb2.py +0 -70
  113. flwr/proto/task_pb2.py +0 -33
  114. flwr/proto/task_pb2.pyi +0 -100
  115. flwr/proto/task_pb2_grpc.py +0 -4
  116. flwr/proto/task_pb2_grpc.pyi +0 -4
  117. /flwr/proto/{recordset_pb2_grpc.py → recorddict_pb2_grpc.py} +0 -0
  118. /flwr/proto/{recordset_pb2_grpc.pyi → recorddict_pb2_grpc.pyi} +0 -0
  119. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/LICENSE +0 -0
  120. {flwr-1.15.2.dist-info → flwr-1.17.0.dist-info}/WHEEL +0 -0
@@ -19,126 +19,113 @@ import abc
19
19
  from typing import Optional
20
20
  from uuid import UUID
21
21
 
22
- from flwr.common import Context
23
- from flwr.common.record import ConfigsRecord
22
+ from flwr.common import Context, Message
23
+ from flwr.common.record import ConfigRecord
24
24
  from flwr.common.typing import Run, RunStatus, UserConfig
25
- from flwr.proto.task_pb2 import TaskIns, TaskRes # pylint: disable=E0611
26
25
 
27
26
 
28
27
  class LinkState(abc.ABC): # pylint: disable=R0904
29
28
  """Abstract LinkState."""
30
29
 
31
30
  @abc.abstractmethod
32
- def store_task_ins(self, task_ins: TaskIns) -> Optional[UUID]:
33
- """Store one TaskIns.
31
+ def store_message_ins(self, message: Message) -> Optional[UUID]:
32
+ """Store one Message.
34
33
 
35
34
  Usually, the ServerAppIo API calls this to schedule instructions.
36
35
 
37
- Stores the value of the `task_ins` in the link state and, if successful,
38
- returns the `task_id` (UUID) of the `task_ins`. If, for any reason,
39
- storing the `task_ins` fails, `None` is returned.
36
+ Stores the value of the `message` in the link state and, if successful,
37
+ returns the `message_id` (UUID) of the `message`. If, for any reason,
38
+ storing the `message` fails, `None` is returned.
40
39
 
41
40
  Constraints
42
41
  -----------
43
- `task_ins.task.consumer.node_id` MUST be set (not constant.DRIVER_NODE_ID)
42
+ `message.metadata.dst_node_id` MUST be set (not constant.SUPERLINK_NODE_ID)
44
43
 
45
- If `task_ins.run_id` is invalid, then
46
- storing the `task_ins` MUST fail.
44
+ If `message.metadata.run_id` is invalid, then
45
+ storing the `message` MUST fail.
47
46
  """
48
47
 
49
48
  @abc.abstractmethod
50
- def get_task_ins(self, node_id: int, limit: Optional[int]) -> list[TaskIns]:
51
- """Get TaskIns optionally filtered by node_id.
49
+ def get_message_ins(self, node_id: int, limit: Optional[int]) -> list[Message]:
50
+ """Get zero or more `Message` objects for the provided `node_id`.
52
51
 
53
52
  Usually, the Fleet API calls this for Nodes planning to work on one or more
54
- TaskIns.
53
+ Message.
55
54
 
56
55
  Constraints
57
56
  -----------
58
- Retrieve all TaskIns where
57
+ Retrieve all Message where the `message.metadata.dst_node_id` equals `node_id`.
59
58
 
60
- 1. the `task_ins.task.consumer.node_id` equals `node_id` AND
61
- 2. the `task_ins.task.delivered_at` equals `""`.
62
-
63
-
64
- If `delivered_at` MUST BE set (not `""`) otherwise the TaskIns MUST not be in
65
- the result.
66
-
67
- If `limit` is not `None`, return, at most, `limit` number of `task_ins`. If
59
+ If `limit` is not `None`, return, at most, `limit` number of `message`. If
68
60
  `limit` is set, it has to be greater zero.
69
61
  """
70
62
 
71
63
  @abc.abstractmethod
72
- def store_task_res(self, task_res: TaskRes) -> Optional[UUID]:
73
- """Store one TaskRes.
64
+ def store_message_res(self, message: Message) -> Optional[UUID]:
65
+ """Store one Message.
74
66
 
75
67
  Usually, the Fleet API calls this for Nodes returning results.
76
68
 
77
- Stores the TaskRes and, if successful, returns the `task_id` (UUID) of
78
- the `task_res`. If storing the `task_res` fails, `None` is returned.
69
+ Stores the Message and, if successful, returns the `message_id` (UUID) of
70
+ the `message`. If storing the `message` fails, `None` is returned.
79
71
 
80
72
  Constraints
81
73
  -----------
74
+ `message.metadata.dst_node_id` MUST be set (not constant.SUPERLINK_NODE_ID)
82
75
 
83
- `task_res.task.consumer.node_id` MUST be set (not constant.DRIVER_NODE_ID)
84
-
85
- If `task_res.run_id` is invalid, then
86
- storing the `task_res` MUST fail.
76
+ If `message.metadata.run_id` is invalid, then
77
+ storing the `message` MUST fail.
87
78
  """
88
79
 
89
80
  @abc.abstractmethod
90
- def get_task_res(self, task_ids: set[UUID]) -> list[TaskRes]:
91
- """Get TaskRes for the given TaskIns IDs.
81
+ def get_message_res(self, message_ids: set[UUID]) -> list[Message]:
82
+ """Get reply Messages for the given Message IDs.
92
83
 
93
84
  This method is typically called by the ServerAppIo API to obtain
94
- results (TaskRes) for previously scheduled instructions (TaskIns).
95
- For each task_id provided, this method returns one of the following responses:
85
+ results (type Message) for previously scheduled instructions (type Message).
86
+ For each message_id passed, this method returns one of the following responses:
96
87
 
97
- - An error TaskRes if the corresponding TaskIns does not exist or has expired.
98
- - An error TaskRes if the corresponding TaskRes exists but has expired.
99
- - The valid TaskRes if the TaskIns has a corresponding valid TaskRes.
100
- - Nothing if the TaskIns is still valid and waiting for a TaskRes.
88
+ - An error Message if there was no message registered with such message IDs
89
+ or has expired.
90
+ - An error Message if the reply Message exists but has expired.
91
+ - The reply Message.
92
+ - Nothing if the Message with the passed message_id is still valid and waiting
93
+ for a reply Message.
101
94
 
102
95
  Parameters
103
96
  ----------
104
- task_ids : set[UUID]
105
- A set of TaskIns IDs for which to retrieve results (TaskRes).
97
+ message_ids : set[UUID]
98
+ A set of Message IDs used to retrieve reply Messages responding to them.
106
99
 
107
100
  Returns
108
101
  -------
109
- list[TaskRes]
110
- A list of TaskRes corresponding to the given task IDs. If no
111
- TaskRes could be found for any of the task IDs, an empty list is returned.
102
+ list[Message]
103
+ A list of reply Message responding to the given message IDs or Messages
104
+ carrying an Error.
112
105
  """
113
106
 
114
107
  @abc.abstractmethod
115
- def num_task_ins(self) -> int:
116
- """Calculate the number of task_ins in store.
117
-
118
- This includes delivered but not yet deleted task_ins.
119
- """
108
+ def num_message_ins(self) -> int:
109
+ """Calculate the number of Messages awaiting a reply."""
120
110
 
121
111
  @abc.abstractmethod
122
- def num_task_res(self) -> int:
123
- """Calculate the number of task_res in store.
124
-
125
- This includes delivered but not yet deleted task_res.
126
- """
112
+ def num_message_res(self) -> int:
113
+ """Calculate the number of reply Messages in store."""
127
114
 
128
115
  @abc.abstractmethod
129
- def delete_tasks(self, task_ins_ids: set[UUID]) -> None:
130
- """Delete TaskIns/TaskRes pairs based on provided TaskIns IDs.
116
+ def delete_messages(self, message_ins_ids: set[UUID]) -> None:
117
+ """Delete a Message and its reply based on provided Message IDs.
131
118
 
132
119
  Parameters
133
120
  ----------
134
- task_ins_ids : set[UUID]
135
- A set of TaskIns IDs. For each ID in the set, the corresponding
136
- TaskIns and its associated TaskRes will be deleted.
121
+ message_ins_ids : set[UUID]
122
+ A set of Message IDs. For each ID in the set, the corresponding
123
+ Message and its associated reply Message will be deleted.
137
124
  """
138
125
 
139
126
  @abc.abstractmethod
140
- def get_task_ids_from_run_id(self, run_id: int) -> set[UUID]:
141
- """Get all TaskIns IDs for the given run_id."""
127
+ def get_message_ids_from_run_id(self, run_id: int) -> set[UUID]:
128
+ """Get all instruction Message IDs for the given run_id."""
142
129
 
143
130
  @abc.abstractmethod
144
131
  def create_node(self, ping_interval: float) -> int:
@@ -177,7 +164,7 @@ class LinkState(abc.ABC): # pylint: disable=R0904
177
164
  fab_version: Optional[str],
178
165
  fab_hash: Optional[str],
179
166
  override_config: UserConfig,
180
- federation_options: ConfigsRecord,
167
+ federation_options: ConfigRecord,
181
168
  ) -> int:
182
169
  """Create a new run for the specified `fab_hash`."""
183
170
 
@@ -249,7 +236,7 @@ class LinkState(abc.ABC): # pylint: disable=R0904
249
236
  """
250
237
 
251
238
  @abc.abstractmethod
252
- def get_federation_options(self, run_id: int) -> Optional[ConfigsRecord]:
239
+ def get_federation_options(self, run_id: int) -> Optional[ConfigRecord]:
253
240
  """Retrieve the federation options for the specified `run_id`.
254
241
 
255
242
  Parameters
@@ -259,7 +246,7 @@ class LinkState(abc.ABC): # pylint: disable=R0904
259
246
 
260
247
  Returns
261
248
  -------
262
- Optional[ConfigsRecord]
249
+ Optional[ConfigRecord]
263
250
  The federation options for the run if it exists; None otherwise.
264
251
  """
265
252