flwr 1.12.0__py3-none-any.whl → 1.13.1__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.
- flwr/cli/app.py +2 -0
- flwr/cli/build.py +2 -2
- flwr/cli/config_utils.py +97 -0
- flwr/cli/install.py +0 -16
- flwr/cli/log.py +63 -97
- flwr/cli/ls.py +228 -0
- flwr/cli/new/new.py +23 -13
- flwr/cli/new/templates/app/README.md.tpl +11 -0
- flwr/cli/new/templates/app/code/flwr_tune/dataset.py.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.baseline.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.flowertune.toml.tpl +2 -1
- flwr/cli/new/templates/app/pyproject.huggingface.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.jax.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +1 -1
- flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +2 -2
- flwr/cli/run/run.py +37 -89
- flwr/client/app.py +73 -34
- flwr/client/clientapp/app.py +58 -37
- flwr/client/grpc_rere_client/connection.py +7 -12
- flwr/client/nodestate/__init__.py +25 -0
- flwr/client/nodestate/in_memory_nodestate.py +38 -0
- flwr/client/nodestate/nodestate.py +30 -0
- flwr/client/nodestate/nodestate_factory.py +37 -0
- flwr/client/rest_client/connection.py +4 -14
- flwr/client/{node_state.py → run_info_store.py} +4 -3
- flwr/client/supernode/app.py +34 -58
- flwr/common/args.py +152 -0
- flwr/common/config.py +10 -0
- flwr/common/constant.py +59 -7
- flwr/common/context.py +9 -4
- flwr/common/date.py +21 -3
- flwr/common/grpc.py +4 -1
- flwr/common/logger.py +108 -1
- flwr/common/object_ref.py +47 -16
- flwr/common/serde.py +34 -0
- flwr/common/telemetry.py +0 -6
- flwr/common/typing.py +32 -2
- flwr/proto/exec_pb2.py +23 -17
- flwr/proto/exec_pb2.pyi +58 -22
- flwr/proto/exec_pb2_grpc.py +34 -0
- flwr/proto/exec_pb2_grpc.pyi +13 -0
- flwr/proto/log_pb2.py +29 -0
- flwr/proto/log_pb2.pyi +39 -0
- flwr/proto/log_pb2_grpc.py +4 -0
- flwr/proto/log_pb2_grpc.pyi +4 -0
- flwr/proto/message_pb2.py +8 -8
- flwr/proto/message_pb2.pyi +4 -1
- flwr/proto/run_pb2.py +32 -27
- flwr/proto/run_pb2.pyi +44 -1
- flwr/proto/serverappio_pb2.py +52 -0
- flwr/proto/{driver_pb2.pyi → serverappio_pb2.pyi} +54 -0
- flwr/proto/serverappio_pb2_grpc.py +376 -0
- flwr/proto/serverappio_pb2_grpc.pyi +147 -0
- flwr/proto/simulationio_pb2.py +38 -0
- flwr/proto/simulationio_pb2.pyi +65 -0
- flwr/proto/simulationio_pb2_grpc.py +205 -0
- flwr/proto/simulationio_pb2_grpc.pyi +81 -0
- flwr/server/app.py +297 -162
- flwr/server/driver/driver.py +15 -1
- flwr/server/driver/grpc_driver.py +89 -50
- flwr/server/driver/inmemory_driver.py +6 -16
- flwr/server/run_serverapp.py +11 -235
- flwr/server/{superlink/state → serverapp}/__init__.py +3 -9
- flwr/server/serverapp/app.py +234 -0
- flwr/server/strategy/aggregate.py +4 -4
- flwr/server/strategy/fedadam.py +11 -1
- flwr/server/superlink/driver/__init__.py +1 -1
- flwr/server/superlink/driver/{driver_grpc.py → serverappio_grpc.py} +19 -16
- flwr/server/superlink/driver/{driver_servicer.py → serverappio_servicer.py} +125 -39
- flwr/server/superlink/fleet/grpc_adapter/grpc_adapter_servicer.py +4 -2
- flwr/server/superlink/fleet/grpc_bidi/grpc_server.py +2 -2
- flwr/server/superlink/fleet/grpc_rere/fleet_servicer.py +4 -2
- flwr/server/superlink/fleet/grpc_rere/server_interceptor.py +2 -2
- flwr/server/superlink/fleet/message_handler/message_handler.py +7 -7
- flwr/server/superlink/fleet/rest_rere/rest_api.py +10 -9
- flwr/server/superlink/fleet/vce/vce_api.py +23 -23
- flwr/server/superlink/linkstate/__init__.py +28 -0
- flwr/server/superlink/{state/in_memory_state.py → linkstate/in_memory_linkstate.py} +237 -64
- flwr/server/superlink/{state/state.py → linkstate/linkstate.py} +166 -22
- flwr/server/superlink/{state/state_factory.py → linkstate/linkstate_factory.py} +9 -9
- flwr/server/superlink/{state/sqlite_state.py → linkstate/sqlite_linkstate.py} +383 -174
- flwr/server/superlink/linkstate/utils.py +389 -0
- flwr/server/superlink/simulation/__init__.py +15 -0
- flwr/server/superlink/simulation/simulationio_grpc.py +65 -0
- flwr/server/superlink/simulation/simulationio_servicer.py +153 -0
- flwr/simulation/__init__.py +5 -1
- flwr/simulation/app.py +236 -347
- flwr/simulation/legacy_app.py +402 -0
- flwr/simulation/ray_transport/ray_client_proxy.py +2 -2
- flwr/simulation/run_simulation.py +56 -141
- flwr/simulation/simulationio_connection.py +86 -0
- flwr/superexec/app.py +6 -134
- flwr/superexec/deployment.py +70 -69
- flwr/superexec/exec_grpc.py +15 -8
- flwr/superexec/exec_servicer.py +65 -65
- flwr/superexec/executor.py +26 -7
- flwr/superexec/simulation.py +62 -150
- {flwr-1.12.0.dist-info → flwr-1.13.1.dist-info}/METADATA +9 -7
- {flwr-1.12.0.dist-info → flwr-1.13.1.dist-info}/RECORD +105 -85
- {flwr-1.12.0.dist-info → flwr-1.13.1.dist-info}/entry_points.txt +2 -0
- flwr/client/node_state_tests.py +0 -66
- flwr/proto/driver_pb2.py +0 -42
- flwr/proto/driver_pb2_grpc.py +0 -239
- flwr/proto/driver_pb2_grpc.pyi +0 -94
- flwr/server/superlink/state/utils.py +0 -148
- {flwr-1.12.0.dist-info → flwr-1.13.1.dist-info}/LICENSE +0 -0
- {flwr-1.12.0.dist-info → flwr-1.13.1.dist-info}/WHEEL +0 -0
flwr/proto/driver_pb2_grpc.py
DELETED
|
@@ -1,239 +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
|
-
from flwr.proto import fab_pb2 as flwr_dot_proto_dot_fab__pb2
|
|
7
|
-
from flwr.proto import run_pb2 as flwr_dot_proto_dot_run__pb2
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class DriverStub(object):
|
|
11
|
-
"""Missing associated documentation comment in .proto file."""
|
|
12
|
-
|
|
13
|
-
def __init__(self, channel):
|
|
14
|
-
"""Constructor.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
channel: A grpc.Channel.
|
|
18
|
-
"""
|
|
19
|
-
self.CreateRun = channel.unary_unary(
|
|
20
|
-
'/flwr.proto.Driver/CreateRun',
|
|
21
|
-
request_serializer=flwr_dot_proto_dot_run__pb2.CreateRunRequest.SerializeToString,
|
|
22
|
-
response_deserializer=flwr_dot_proto_dot_run__pb2.CreateRunResponse.FromString,
|
|
23
|
-
)
|
|
24
|
-
self.GetNodes = channel.unary_unary(
|
|
25
|
-
'/flwr.proto.Driver/GetNodes',
|
|
26
|
-
request_serializer=flwr_dot_proto_dot_driver__pb2.GetNodesRequest.SerializeToString,
|
|
27
|
-
response_deserializer=flwr_dot_proto_dot_driver__pb2.GetNodesResponse.FromString,
|
|
28
|
-
)
|
|
29
|
-
self.PushTaskIns = channel.unary_unary(
|
|
30
|
-
'/flwr.proto.Driver/PushTaskIns',
|
|
31
|
-
request_serializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsRequest.SerializeToString,
|
|
32
|
-
response_deserializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsResponse.FromString,
|
|
33
|
-
)
|
|
34
|
-
self.PullTaskRes = channel.unary_unary(
|
|
35
|
-
'/flwr.proto.Driver/PullTaskRes',
|
|
36
|
-
request_serializer=flwr_dot_proto_dot_driver__pb2.PullTaskResRequest.SerializeToString,
|
|
37
|
-
response_deserializer=flwr_dot_proto_dot_driver__pb2.PullTaskResResponse.FromString,
|
|
38
|
-
)
|
|
39
|
-
self.GetRun = channel.unary_unary(
|
|
40
|
-
'/flwr.proto.Driver/GetRun',
|
|
41
|
-
request_serializer=flwr_dot_proto_dot_run__pb2.GetRunRequest.SerializeToString,
|
|
42
|
-
response_deserializer=flwr_dot_proto_dot_run__pb2.GetRunResponse.FromString,
|
|
43
|
-
)
|
|
44
|
-
self.GetFab = channel.unary_unary(
|
|
45
|
-
'/flwr.proto.Driver/GetFab',
|
|
46
|
-
request_serializer=flwr_dot_proto_dot_fab__pb2.GetFabRequest.SerializeToString,
|
|
47
|
-
response_deserializer=flwr_dot_proto_dot_fab__pb2.GetFabResponse.FromString,
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class DriverServicer(object):
|
|
52
|
-
"""Missing associated documentation comment in .proto file."""
|
|
53
|
-
|
|
54
|
-
def CreateRun(self, request, context):
|
|
55
|
-
"""Request run_id
|
|
56
|
-
"""
|
|
57
|
-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
58
|
-
context.set_details('Method not implemented!')
|
|
59
|
-
raise NotImplementedError('Method not implemented!')
|
|
60
|
-
|
|
61
|
-
def GetNodes(self, request, context):
|
|
62
|
-
"""Return a set of nodes
|
|
63
|
-
"""
|
|
64
|
-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
65
|
-
context.set_details('Method not implemented!')
|
|
66
|
-
raise NotImplementedError('Method not implemented!')
|
|
67
|
-
|
|
68
|
-
def PushTaskIns(self, request, context):
|
|
69
|
-
"""Create one or more tasks
|
|
70
|
-
"""
|
|
71
|
-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
72
|
-
context.set_details('Method not implemented!')
|
|
73
|
-
raise NotImplementedError('Method not implemented!')
|
|
74
|
-
|
|
75
|
-
def PullTaskRes(self, request, context):
|
|
76
|
-
"""Get task results
|
|
77
|
-
"""
|
|
78
|
-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
79
|
-
context.set_details('Method not implemented!')
|
|
80
|
-
raise NotImplementedError('Method not implemented!')
|
|
81
|
-
|
|
82
|
-
def GetRun(self, request, context):
|
|
83
|
-
"""Get run details
|
|
84
|
-
"""
|
|
85
|
-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
86
|
-
context.set_details('Method not implemented!')
|
|
87
|
-
raise NotImplementedError('Method not implemented!')
|
|
88
|
-
|
|
89
|
-
def GetFab(self, request, context):
|
|
90
|
-
"""Get FAB
|
|
91
|
-
"""
|
|
92
|
-
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
93
|
-
context.set_details('Method not implemented!')
|
|
94
|
-
raise NotImplementedError('Method not implemented!')
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def add_DriverServicer_to_server(servicer, server):
|
|
98
|
-
rpc_method_handlers = {
|
|
99
|
-
'CreateRun': grpc.unary_unary_rpc_method_handler(
|
|
100
|
-
servicer.CreateRun,
|
|
101
|
-
request_deserializer=flwr_dot_proto_dot_run__pb2.CreateRunRequest.FromString,
|
|
102
|
-
response_serializer=flwr_dot_proto_dot_run__pb2.CreateRunResponse.SerializeToString,
|
|
103
|
-
),
|
|
104
|
-
'GetNodes': grpc.unary_unary_rpc_method_handler(
|
|
105
|
-
servicer.GetNodes,
|
|
106
|
-
request_deserializer=flwr_dot_proto_dot_driver__pb2.GetNodesRequest.FromString,
|
|
107
|
-
response_serializer=flwr_dot_proto_dot_driver__pb2.GetNodesResponse.SerializeToString,
|
|
108
|
-
),
|
|
109
|
-
'PushTaskIns': grpc.unary_unary_rpc_method_handler(
|
|
110
|
-
servicer.PushTaskIns,
|
|
111
|
-
request_deserializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsRequest.FromString,
|
|
112
|
-
response_serializer=flwr_dot_proto_dot_driver__pb2.PushTaskInsResponse.SerializeToString,
|
|
113
|
-
),
|
|
114
|
-
'PullTaskRes': grpc.unary_unary_rpc_method_handler(
|
|
115
|
-
servicer.PullTaskRes,
|
|
116
|
-
request_deserializer=flwr_dot_proto_dot_driver__pb2.PullTaskResRequest.FromString,
|
|
117
|
-
response_serializer=flwr_dot_proto_dot_driver__pb2.PullTaskResResponse.SerializeToString,
|
|
118
|
-
),
|
|
119
|
-
'GetRun': grpc.unary_unary_rpc_method_handler(
|
|
120
|
-
servicer.GetRun,
|
|
121
|
-
request_deserializer=flwr_dot_proto_dot_run__pb2.GetRunRequest.FromString,
|
|
122
|
-
response_serializer=flwr_dot_proto_dot_run__pb2.GetRunResponse.SerializeToString,
|
|
123
|
-
),
|
|
124
|
-
'GetFab': grpc.unary_unary_rpc_method_handler(
|
|
125
|
-
servicer.GetFab,
|
|
126
|
-
request_deserializer=flwr_dot_proto_dot_fab__pb2.GetFabRequest.FromString,
|
|
127
|
-
response_serializer=flwr_dot_proto_dot_fab__pb2.GetFabResponse.SerializeToString,
|
|
128
|
-
),
|
|
129
|
-
}
|
|
130
|
-
generic_handler = grpc.method_handlers_generic_handler(
|
|
131
|
-
'flwr.proto.Driver', rpc_method_handlers)
|
|
132
|
-
server.add_generic_rpc_handlers((generic_handler,))
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# This class is part of an EXPERIMENTAL API.
|
|
136
|
-
class Driver(object):
|
|
137
|
-
"""Missing associated documentation comment in .proto file."""
|
|
138
|
-
|
|
139
|
-
@staticmethod
|
|
140
|
-
def CreateRun(request,
|
|
141
|
-
target,
|
|
142
|
-
options=(),
|
|
143
|
-
channel_credentials=None,
|
|
144
|
-
call_credentials=None,
|
|
145
|
-
insecure=False,
|
|
146
|
-
compression=None,
|
|
147
|
-
wait_for_ready=None,
|
|
148
|
-
timeout=None,
|
|
149
|
-
metadata=None):
|
|
150
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/CreateRun',
|
|
151
|
-
flwr_dot_proto_dot_run__pb2.CreateRunRequest.SerializeToString,
|
|
152
|
-
flwr_dot_proto_dot_run__pb2.CreateRunResponse.FromString,
|
|
153
|
-
options, channel_credentials,
|
|
154
|
-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
155
|
-
|
|
156
|
-
@staticmethod
|
|
157
|
-
def GetNodes(request,
|
|
158
|
-
target,
|
|
159
|
-
options=(),
|
|
160
|
-
channel_credentials=None,
|
|
161
|
-
call_credentials=None,
|
|
162
|
-
insecure=False,
|
|
163
|
-
compression=None,
|
|
164
|
-
wait_for_ready=None,
|
|
165
|
-
timeout=None,
|
|
166
|
-
metadata=None):
|
|
167
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/GetNodes',
|
|
168
|
-
flwr_dot_proto_dot_driver__pb2.GetNodesRequest.SerializeToString,
|
|
169
|
-
flwr_dot_proto_dot_driver__pb2.GetNodesResponse.FromString,
|
|
170
|
-
options, channel_credentials,
|
|
171
|
-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
172
|
-
|
|
173
|
-
@staticmethod
|
|
174
|
-
def PushTaskIns(request,
|
|
175
|
-
target,
|
|
176
|
-
options=(),
|
|
177
|
-
channel_credentials=None,
|
|
178
|
-
call_credentials=None,
|
|
179
|
-
insecure=False,
|
|
180
|
-
compression=None,
|
|
181
|
-
wait_for_ready=None,
|
|
182
|
-
timeout=None,
|
|
183
|
-
metadata=None):
|
|
184
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/PushTaskIns',
|
|
185
|
-
flwr_dot_proto_dot_driver__pb2.PushTaskInsRequest.SerializeToString,
|
|
186
|
-
flwr_dot_proto_dot_driver__pb2.PushTaskInsResponse.FromString,
|
|
187
|
-
options, channel_credentials,
|
|
188
|
-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
189
|
-
|
|
190
|
-
@staticmethod
|
|
191
|
-
def PullTaskRes(request,
|
|
192
|
-
target,
|
|
193
|
-
options=(),
|
|
194
|
-
channel_credentials=None,
|
|
195
|
-
call_credentials=None,
|
|
196
|
-
insecure=False,
|
|
197
|
-
compression=None,
|
|
198
|
-
wait_for_ready=None,
|
|
199
|
-
timeout=None,
|
|
200
|
-
metadata=None):
|
|
201
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/PullTaskRes',
|
|
202
|
-
flwr_dot_proto_dot_driver__pb2.PullTaskResRequest.SerializeToString,
|
|
203
|
-
flwr_dot_proto_dot_driver__pb2.PullTaskResResponse.FromString,
|
|
204
|
-
options, channel_credentials,
|
|
205
|
-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
206
|
-
|
|
207
|
-
@staticmethod
|
|
208
|
-
def GetRun(request,
|
|
209
|
-
target,
|
|
210
|
-
options=(),
|
|
211
|
-
channel_credentials=None,
|
|
212
|
-
call_credentials=None,
|
|
213
|
-
insecure=False,
|
|
214
|
-
compression=None,
|
|
215
|
-
wait_for_ready=None,
|
|
216
|
-
timeout=None,
|
|
217
|
-
metadata=None):
|
|
218
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/GetRun',
|
|
219
|
-
flwr_dot_proto_dot_run__pb2.GetRunRequest.SerializeToString,
|
|
220
|
-
flwr_dot_proto_dot_run__pb2.GetRunResponse.FromString,
|
|
221
|
-
options, channel_credentials,
|
|
222
|
-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
223
|
-
|
|
224
|
-
@staticmethod
|
|
225
|
-
def GetFab(request,
|
|
226
|
-
target,
|
|
227
|
-
options=(),
|
|
228
|
-
channel_credentials=None,
|
|
229
|
-
call_credentials=None,
|
|
230
|
-
insecure=False,
|
|
231
|
-
compression=None,
|
|
232
|
-
wait_for_ready=None,
|
|
233
|
-
timeout=None,
|
|
234
|
-
metadata=None):
|
|
235
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Driver/GetFab',
|
|
236
|
-
flwr_dot_proto_dot_fab__pb2.GetFabRequest.SerializeToString,
|
|
237
|
-
flwr_dot_proto_dot_fab__pb2.GetFabResponse.FromString,
|
|
238
|
-
options, channel_credentials,
|
|
239
|
-
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
flwr/proto/driver_pb2_grpc.pyi
DELETED
|
@@ -1,94 +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 flwr.proto.fab_pb2
|
|
8
|
-
import flwr.proto.run_pb2
|
|
9
|
-
import grpc
|
|
10
|
-
|
|
11
|
-
class DriverStub:
|
|
12
|
-
def __init__(self, channel: grpc.Channel) -> None: ...
|
|
13
|
-
CreateRun: grpc.UnaryUnaryMultiCallable[
|
|
14
|
-
flwr.proto.run_pb2.CreateRunRequest,
|
|
15
|
-
flwr.proto.run_pb2.CreateRunResponse]
|
|
16
|
-
"""Request run_id"""
|
|
17
|
-
|
|
18
|
-
GetNodes: grpc.UnaryUnaryMultiCallable[
|
|
19
|
-
flwr.proto.driver_pb2.GetNodesRequest,
|
|
20
|
-
flwr.proto.driver_pb2.GetNodesResponse]
|
|
21
|
-
"""Return a set of nodes"""
|
|
22
|
-
|
|
23
|
-
PushTaskIns: grpc.UnaryUnaryMultiCallable[
|
|
24
|
-
flwr.proto.driver_pb2.PushTaskInsRequest,
|
|
25
|
-
flwr.proto.driver_pb2.PushTaskInsResponse]
|
|
26
|
-
"""Create one or more tasks"""
|
|
27
|
-
|
|
28
|
-
PullTaskRes: grpc.UnaryUnaryMultiCallable[
|
|
29
|
-
flwr.proto.driver_pb2.PullTaskResRequest,
|
|
30
|
-
flwr.proto.driver_pb2.PullTaskResResponse]
|
|
31
|
-
"""Get task results"""
|
|
32
|
-
|
|
33
|
-
GetRun: grpc.UnaryUnaryMultiCallable[
|
|
34
|
-
flwr.proto.run_pb2.GetRunRequest,
|
|
35
|
-
flwr.proto.run_pb2.GetRunResponse]
|
|
36
|
-
"""Get run details"""
|
|
37
|
-
|
|
38
|
-
GetFab: grpc.UnaryUnaryMultiCallable[
|
|
39
|
-
flwr.proto.fab_pb2.GetFabRequest,
|
|
40
|
-
flwr.proto.fab_pb2.GetFabResponse]
|
|
41
|
-
"""Get FAB"""
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class DriverServicer(metaclass=abc.ABCMeta):
|
|
45
|
-
@abc.abstractmethod
|
|
46
|
-
def CreateRun(self,
|
|
47
|
-
request: flwr.proto.run_pb2.CreateRunRequest,
|
|
48
|
-
context: grpc.ServicerContext,
|
|
49
|
-
) -> flwr.proto.run_pb2.CreateRunResponse:
|
|
50
|
-
"""Request run_id"""
|
|
51
|
-
pass
|
|
52
|
-
|
|
53
|
-
@abc.abstractmethod
|
|
54
|
-
def GetNodes(self,
|
|
55
|
-
request: flwr.proto.driver_pb2.GetNodesRequest,
|
|
56
|
-
context: grpc.ServicerContext,
|
|
57
|
-
) -> flwr.proto.driver_pb2.GetNodesResponse:
|
|
58
|
-
"""Return a set of nodes"""
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
@abc.abstractmethod
|
|
62
|
-
def PushTaskIns(self,
|
|
63
|
-
request: flwr.proto.driver_pb2.PushTaskInsRequest,
|
|
64
|
-
context: grpc.ServicerContext,
|
|
65
|
-
) -> flwr.proto.driver_pb2.PushTaskInsResponse:
|
|
66
|
-
"""Create one or more tasks"""
|
|
67
|
-
pass
|
|
68
|
-
|
|
69
|
-
@abc.abstractmethod
|
|
70
|
-
def PullTaskRes(self,
|
|
71
|
-
request: flwr.proto.driver_pb2.PullTaskResRequest,
|
|
72
|
-
context: grpc.ServicerContext,
|
|
73
|
-
) -> flwr.proto.driver_pb2.PullTaskResResponse:
|
|
74
|
-
"""Get task results"""
|
|
75
|
-
pass
|
|
76
|
-
|
|
77
|
-
@abc.abstractmethod
|
|
78
|
-
def GetRun(self,
|
|
79
|
-
request: flwr.proto.run_pb2.GetRunRequest,
|
|
80
|
-
context: grpc.ServicerContext,
|
|
81
|
-
) -> flwr.proto.run_pb2.GetRunResponse:
|
|
82
|
-
"""Get run details"""
|
|
83
|
-
pass
|
|
84
|
-
|
|
85
|
-
@abc.abstractmethod
|
|
86
|
-
def GetFab(self,
|
|
87
|
-
request: flwr.proto.fab_pb2.GetFabRequest,
|
|
88
|
-
context: grpc.ServicerContext,
|
|
89
|
-
) -> flwr.proto.fab_pb2.GetFabResponse:
|
|
90
|
-
"""Get FAB"""
|
|
91
|
-
pass
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def add_DriverServicer_to_server(servicer: DriverServicer, server: grpc.Server) -> None: ...
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
# Copyright 2024 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
|
-
"""Utility functions for State."""
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import time
|
|
19
|
-
from logging import ERROR
|
|
20
|
-
from os import urandom
|
|
21
|
-
from uuid import uuid4
|
|
22
|
-
|
|
23
|
-
from flwr.common import log
|
|
24
|
-
from flwr.common.constant import ErrorCode
|
|
25
|
-
from flwr.proto.error_pb2 import Error # pylint: disable=E0611
|
|
26
|
-
from flwr.proto.node_pb2 import Node # pylint: disable=E0611
|
|
27
|
-
from flwr.proto.task_pb2 import Task, TaskIns, TaskRes # pylint: disable=E0611
|
|
28
|
-
|
|
29
|
-
NODE_UNAVAILABLE_ERROR_REASON = (
|
|
30
|
-
"Error: Node Unavailable - The destination node is currently unavailable. "
|
|
31
|
-
"It exceeds the time limit specified in its last ping."
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def generate_rand_int_from_bytes(num_bytes: int) -> int:
|
|
36
|
-
"""Generate a random unsigned integer from `num_bytes` bytes."""
|
|
37
|
-
return int.from_bytes(urandom(num_bytes), "little", signed=False)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def convert_uint64_to_sint64(u: int) -> int:
|
|
41
|
-
"""Convert a uint64 value to a sint64 value with the same bit sequence.
|
|
42
|
-
|
|
43
|
-
Parameters
|
|
44
|
-
----------
|
|
45
|
-
u : int
|
|
46
|
-
The unsigned 64-bit integer to convert.
|
|
47
|
-
|
|
48
|
-
Returns
|
|
49
|
-
-------
|
|
50
|
-
int
|
|
51
|
-
The signed 64-bit integer equivalent.
|
|
52
|
-
|
|
53
|
-
The signed 64-bit integer will have the same bit pattern as the
|
|
54
|
-
unsigned 64-bit integer but may have a different decimal value.
|
|
55
|
-
|
|
56
|
-
For numbers within the range [0, `sint64` max value], the decimal
|
|
57
|
-
value remains the same. However, for numbers greater than the `sint64`
|
|
58
|
-
max value, the decimal value will differ due to the wraparound caused
|
|
59
|
-
by the sign bit.
|
|
60
|
-
"""
|
|
61
|
-
if u >= (1 << 63):
|
|
62
|
-
return u - (1 << 64)
|
|
63
|
-
return u
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def convert_sint64_to_uint64(s: int) -> int:
|
|
67
|
-
"""Convert a sint64 value to a uint64 value with the same bit sequence.
|
|
68
|
-
|
|
69
|
-
Parameters
|
|
70
|
-
----------
|
|
71
|
-
s : int
|
|
72
|
-
The signed 64-bit integer to convert.
|
|
73
|
-
|
|
74
|
-
Returns
|
|
75
|
-
-------
|
|
76
|
-
int
|
|
77
|
-
The unsigned 64-bit integer equivalent.
|
|
78
|
-
|
|
79
|
-
The unsigned 64-bit integer will have the same bit pattern as the
|
|
80
|
-
signed 64-bit integer but may have a different decimal value.
|
|
81
|
-
|
|
82
|
-
For negative `sint64` values, the conversion adds 2^64 to the
|
|
83
|
-
signed value to obtain the equivalent `uint64` value. For non-negative
|
|
84
|
-
`sint64` values, the decimal value remains unchanged in the `uint64`
|
|
85
|
-
representation.
|
|
86
|
-
"""
|
|
87
|
-
if s < 0:
|
|
88
|
-
return s + (1 << 64)
|
|
89
|
-
return s
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def convert_uint64_values_in_dict_to_sint64(
|
|
93
|
-
data_dict: dict[str, int], keys: list[str]
|
|
94
|
-
) -> None:
|
|
95
|
-
"""Convert uint64 values to sint64 in the given dictionary.
|
|
96
|
-
|
|
97
|
-
Parameters
|
|
98
|
-
----------
|
|
99
|
-
data_dict : dict[str, int]
|
|
100
|
-
A dictionary where the values are integers to be converted.
|
|
101
|
-
keys : list[str]
|
|
102
|
-
A list of keys in the dictionary whose values need to be converted.
|
|
103
|
-
"""
|
|
104
|
-
for key in keys:
|
|
105
|
-
if key in data_dict:
|
|
106
|
-
data_dict[key] = convert_uint64_to_sint64(data_dict[key])
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def convert_sint64_values_in_dict_to_uint64(
|
|
110
|
-
data_dict: dict[str, int], keys: list[str]
|
|
111
|
-
) -> None:
|
|
112
|
-
"""Convert sint64 values to uint64 in the given dictionary.
|
|
113
|
-
|
|
114
|
-
Parameters
|
|
115
|
-
----------
|
|
116
|
-
data_dict : dict[str, int]
|
|
117
|
-
A dictionary where the values are integers to be converted.
|
|
118
|
-
keys : list[str]
|
|
119
|
-
A list of keys in the dictionary whose values need to be converted.
|
|
120
|
-
"""
|
|
121
|
-
for key in keys:
|
|
122
|
-
if key in data_dict:
|
|
123
|
-
data_dict[key] = convert_sint64_to_uint64(data_dict[key])
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def make_node_unavailable_taskres(ref_taskins: TaskIns) -> TaskRes:
|
|
127
|
-
"""Generate a TaskRes with a node unavailable error from a TaskIns."""
|
|
128
|
-
current_time = time.time()
|
|
129
|
-
ttl = ref_taskins.task.ttl - (current_time - ref_taskins.task.created_at)
|
|
130
|
-
if ttl < 0:
|
|
131
|
-
log(ERROR, "Creating TaskRes for TaskIns that exceeds its TTL.")
|
|
132
|
-
ttl = 0
|
|
133
|
-
return TaskRes(
|
|
134
|
-
task_id=str(uuid4()),
|
|
135
|
-
group_id=ref_taskins.group_id,
|
|
136
|
-
run_id=ref_taskins.run_id,
|
|
137
|
-
task=Task(
|
|
138
|
-
producer=Node(node_id=ref_taskins.task.consumer.node_id, anonymous=False),
|
|
139
|
-
consumer=Node(node_id=ref_taskins.task.producer.node_id, anonymous=False),
|
|
140
|
-
created_at=current_time,
|
|
141
|
-
ttl=ttl,
|
|
142
|
-
ancestry=[ref_taskins.task_id],
|
|
143
|
-
task_type=ref_taskins.task.task_type,
|
|
144
|
-
error=Error(
|
|
145
|
-
code=ErrorCode.NODE_UNAVAILABLE, reason=NODE_UNAVAILABLE_ERROR_REASON
|
|
146
|
-
),
|
|
147
|
-
),
|
|
148
|
-
)
|
|
File without changes
|
|
File without changes
|