flwr-nightly 1.21.0.dev20250801__py3-none-any.whl → 1.21.0.dev20250804__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/auth_plugin/oidc_cli_plugin.py +4 -4
- flwr/cli/cli_user_auth_interceptor.py +1 -1
- flwr/cli/config_utils.py +2 -2
- flwr/cli/log.py +9 -9
- flwr/cli/login/login.py +3 -3
- flwr/cli/ls.py +5 -5
- flwr/cli/run/run.py +7 -7
- flwr/cli/stop.py +7 -4
- flwr/cli/utils.py +1 -1
- flwr/common/auth_plugin/__init__.py +4 -4
- flwr/common/auth_plugin/auth_plugin.py +7 -7
- flwr/common/constant.py +4 -4
- flwr/common/event_log_plugin/event_log_plugin.py +1 -1
- flwr/proto/control_pb2.py +62 -0
- flwr/proto/{exec_pb2_grpc.py → control_pb2_grpc.py} +54 -54
- flwr/proto/{exec_pb2_grpc.pyi → control_pb2_grpc.pyi} +28 -28
- flwr/server/app.py +36 -36
- flwr/superlink/executor/__init__.py +1 -1
- flwr/superlink/servicer/{exec → control}/__init__.py +3 -3
- flwr/superlink/servicer/{exec/exec_event_log_interceptor.py → control/control_event_log_interceptor.py} +7 -7
- flwr/superlink/servicer/{exec/exec_grpc.py → control/control_grpc.py} +22 -22
- flwr/superlink/servicer/{exec/exec_license_interceptor.py → control/control_license_interceptor.py} +6 -6
- flwr/superlink/servicer/{exec/exec_servicer.py → control/control_servicer.py} +16 -16
- flwr/superlink/servicer/{exec/exec_user_auth_interceptor.py → control/control_user_auth_interceptor.py} +10 -10
- {flwr_nightly-1.21.0.dev20250801.dist-info → flwr_nightly-1.21.0.dev20250804.dist-info}/METADATA +1 -1
- {flwr_nightly-1.21.0.dev20250801.dist-info → flwr_nightly-1.21.0.dev20250804.dist-info}/RECORD +29 -29
- flwr/proto/exec_pb2.py +0 -62
- /flwr/proto/{exec_pb2.pyi → control_pb2.pyi} +0 -0
- {flwr_nightly-1.21.0.dev20250801.dist-info → flwr_nightly-1.21.0.dev20250804.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.21.0.dev20250801.dist-info → flwr_nightly-1.21.0.dev20250804.dist-info}/entry_points.txt +0 -0
@@ -2,10 +2,10 @@
|
|
2
2
|
"""Client and server classes corresponding to protobuf-defined services."""
|
3
3
|
import grpc
|
4
4
|
|
5
|
-
from flwr.proto import
|
5
|
+
from flwr.proto import control_pb2 as flwr_dot_proto_dot_control__pb2
|
6
6
|
|
7
7
|
|
8
|
-
class
|
8
|
+
class ControlStub(object):
|
9
9
|
"""Missing associated documentation comment in .proto file."""
|
10
10
|
|
11
11
|
def __init__(self, channel):
|
@@ -15,38 +15,38 @@ class ExecStub(object):
|
|
15
15
|
channel: A grpc.Channel.
|
16
16
|
"""
|
17
17
|
self.StartRun = channel.unary_unary(
|
18
|
-
'/flwr.proto.
|
19
|
-
request_serializer=
|
20
|
-
response_deserializer=
|
18
|
+
'/flwr.proto.Control/StartRun',
|
19
|
+
request_serializer=flwr_dot_proto_dot_control__pb2.StartRunRequest.SerializeToString,
|
20
|
+
response_deserializer=flwr_dot_proto_dot_control__pb2.StartRunResponse.FromString,
|
21
21
|
)
|
22
22
|
self.StopRun = channel.unary_unary(
|
23
|
-
'/flwr.proto.
|
24
|
-
request_serializer=
|
25
|
-
response_deserializer=
|
23
|
+
'/flwr.proto.Control/StopRun',
|
24
|
+
request_serializer=flwr_dot_proto_dot_control__pb2.StopRunRequest.SerializeToString,
|
25
|
+
response_deserializer=flwr_dot_proto_dot_control__pb2.StopRunResponse.FromString,
|
26
26
|
)
|
27
27
|
self.StreamLogs = channel.unary_stream(
|
28
|
-
'/flwr.proto.
|
29
|
-
request_serializer=
|
30
|
-
response_deserializer=
|
28
|
+
'/flwr.proto.Control/StreamLogs',
|
29
|
+
request_serializer=flwr_dot_proto_dot_control__pb2.StreamLogsRequest.SerializeToString,
|
30
|
+
response_deserializer=flwr_dot_proto_dot_control__pb2.StreamLogsResponse.FromString,
|
31
31
|
)
|
32
32
|
self.ListRuns = channel.unary_unary(
|
33
|
-
'/flwr.proto.
|
34
|
-
request_serializer=
|
35
|
-
response_deserializer=
|
33
|
+
'/flwr.proto.Control/ListRuns',
|
34
|
+
request_serializer=flwr_dot_proto_dot_control__pb2.ListRunsRequest.SerializeToString,
|
35
|
+
response_deserializer=flwr_dot_proto_dot_control__pb2.ListRunsResponse.FromString,
|
36
36
|
)
|
37
37
|
self.GetLoginDetails = channel.unary_unary(
|
38
|
-
'/flwr.proto.
|
39
|
-
request_serializer=
|
40
|
-
response_deserializer=
|
38
|
+
'/flwr.proto.Control/GetLoginDetails',
|
39
|
+
request_serializer=flwr_dot_proto_dot_control__pb2.GetLoginDetailsRequest.SerializeToString,
|
40
|
+
response_deserializer=flwr_dot_proto_dot_control__pb2.GetLoginDetailsResponse.FromString,
|
41
41
|
)
|
42
42
|
self.GetAuthTokens = channel.unary_unary(
|
43
|
-
'/flwr.proto.
|
44
|
-
request_serializer=
|
45
|
-
response_deserializer=
|
43
|
+
'/flwr.proto.Control/GetAuthTokens',
|
44
|
+
request_serializer=flwr_dot_proto_dot_control__pb2.GetAuthTokensRequest.SerializeToString,
|
45
|
+
response_deserializer=flwr_dot_proto_dot_control__pb2.GetAuthTokensResponse.FromString,
|
46
46
|
)
|
47
47
|
|
48
48
|
|
49
|
-
class
|
49
|
+
class ControlServicer(object):
|
50
50
|
"""Missing associated documentation comment in .proto file."""
|
51
51
|
|
52
52
|
def StartRun(self, request, context):
|
@@ -92,46 +92,46 @@ class ExecServicer(object):
|
|
92
92
|
raise NotImplementedError('Method not implemented!')
|
93
93
|
|
94
94
|
|
95
|
-
def
|
95
|
+
def add_ControlServicer_to_server(servicer, server):
|
96
96
|
rpc_method_handlers = {
|
97
97
|
'StartRun': grpc.unary_unary_rpc_method_handler(
|
98
98
|
servicer.StartRun,
|
99
|
-
request_deserializer=
|
100
|
-
response_serializer=
|
99
|
+
request_deserializer=flwr_dot_proto_dot_control__pb2.StartRunRequest.FromString,
|
100
|
+
response_serializer=flwr_dot_proto_dot_control__pb2.StartRunResponse.SerializeToString,
|
101
101
|
),
|
102
102
|
'StopRun': grpc.unary_unary_rpc_method_handler(
|
103
103
|
servicer.StopRun,
|
104
|
-
request_deserializer=
|
105
|
-
response_serializer=
|
104
|
+
request_deserializer=flwr_dot_proto_dot_control__pb2.StopRunRequest.FromString,
|
105
|
+
response_serializer=flwr_dot_proto_dot_control__pb2.StopRunResponse.SerializeToString,
|
106
106
|
),
|
107
107
|
'StreamLogs': grpc.unary_stream_rpc_method_handler(
|
108
108
|
servicer.StreamLogs,
|
109
|
-
request_deserializer=
|
110
|
-
response_serializer=
|
109
|
+
request_deserializer=flwr_dot_proto_dot_control__pb2.StreamLogsRequest.FromString,
|
110
|
+
response_serializer=flwr_dot_proto_dot_control__pb2.StreamLogsResponse.SerializeToString,
|
111
111
|
),
|
112
112
|
'ListRuns': grpc.unary_unary_rpc_method_handler(
|
113
113
|
servicer.ListRuns,
|
114
|
-
request_deserializer=
|
115
|
-
response_serializer=
|
114
|
+
request_deserializer=flwr_dot_proto_dot_control__pb2.ListRunsRequest.FromString,
|
115
|
+
response_serializer=flwr_dot_proto_dot_control__pb2.ListRunsResponse.SerializeToString,
|
116
116
|
),
|
117
117
|
'GetLoginDetails': grpc.unary_unary_rpc_method_handler(
|
118
118
|
servicer.GetLoginDetails,
|
119
|
-
request_deserializer=
|
120
|
-
response_serializer=
|
119
|
+
request_deserializer=flwr_dot_proto_dot_control__pb2.GetLoginDetailsRequest.FromString,
|
120
|
+
response_serializer=flwr_dot_proto_dot_control__pb2.GetLoginDetailsResponse.SerializeToString,
|
121
121
|
),
|
122
122
|
'GetAuthTokens': grpc.unary_unary_rpc_method_handler(
|
123
123
|
servicer.GetAuthTokens,
|
124
|
-
request_deserializer=
|
125
|
-
response_serializer=
|
124
|
+
request_deserializer=flwr_dot_proto_dot_control__pb2.GetAuthTokensRequest.FromString,
|
125
|
+
response_serializer=flwr_dot_proto_dot_control__pb2.GetAuthTokensResponse.SerializeToString,
|
126
126
|
),
|
127
127
|
}
|
128
128
|
generic_handler = grpc.method_handlers_generic_handler(
|
129
|
-
'flwr.proto.
|
129
|
+
'flwr.proto.Control', rpc_method_handlers)
|
130
130
|
server.add_generic_rpc_handlers((generic_handler,))
|
131
131
|
|
132
132
|
|
133
133
|
# This class is part of an EXPERIMENTAL API.
|
134
|
-
class
|
134
|
+
class Control(object):
|
135
135
|
"""Missing associated documentation comment in .proto file."""
|
136
136
|
|
137
137
|
@staticmethod
|
@@ -145,9 +145,9 @@ class Exec(object):
|
|
145
145
|
wait_for_ready=None,
|
146
146
|
timeout=None,
|
147
147
|
metadata=None):
|
148
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.
|
149
|
-
|
150
|
-
|
148
|
+
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Control/StartRun',
|
149
|
+
flwr_dot_proto_dot_control__pb2.StartRunRequest.SerializeToString,
|
150
|
+
flwr_dot_proto_dot_control__pb2.StartRunResponse.FromString,
|
151
151
|
options, channel_credentials,
|
152
152
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
153
153
|
|
@@ -162,9 +162,9 @@ class Exec(object):
|
|
162
162
|
wait_for_ready=None,
|
163
163
|
timeout=None,
|
164
164
|
metadata=None):
|
165
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.
|
166
|
-
|
167
|
-
|
165
|
+
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Control/StopRun',
|
166
|
+
flwr_dot_proto_dot_control__pb2.StopRunRequest.SerializeToString,
|
167
|
+
flwr_dot_proto_dot_control__pb2.StopRunResponse.FromString,
|
168
168
|
options, channel_credentials,
|
169
169
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
170
170
|
|
@@ -179,9 +179,9 @@ class Exec(object):
|
|
179
179
|
wait_for_ready=None,
|
180
180
|
timeout=None,
|
181
181
|
metadata=None):
|
182
|
-
return grpc.experimental.unary_stream(request, target, '/flwr.proto.
|
183
|
-
|
184
|
-
|
182
|
+
return grpc.experimental.unary_stream(request, target, '/flwr.proto.Control/StreamLogs',
|
183
|
+
flwr_dot_proto_dot_control__pb2.StreamLogsRequest.SerializeToString,
|
184
|
+
flwr_dot_proto_dot_control__pb2.StreamLogsResponse.FromString,
|
185
185
|
options, channel_credentials,
|
186
186
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
187
187
|
|
@@ -196,9 +196,9 @@ class Exec(object):
|
|
196
196
|
wait_for_ready=None,
|
197
197
|
timeout=None,
|
198
198
|
metadata=None):
|
199
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.
|
200
|
-
|
201
|
-
|
199
|
+
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Control/ListRuns',
|
200
|
+
flwr_dot_proto_dot_control__pb2.ListRunsRequest.SerializeToString,
|
201
|
+
flwr_dot_proto_dot_control__pb2.ListRunsResponse.FromString,
|
202
202
|
options, channel_credentials,
|
203
203
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
204
204
|
|
@@ -213,9 +213,9 @@ class Exec(object):
|
|
213
213
|
wait_for_ready=None,
|
214
214
|
timeout=None,
|
215
215
|
metadata=None):
|
216
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.
|
217
|
-
|
218
|
-
|
216
|
+
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Control/GetLoginDetails',
|
217
|
+
flwr_dot_proto_dot_control__pb2.GetLoginDetailsRequest.SerializeToString,
|
218
|
+
flwr_dot_proto_dot_control__pb2.GetLoginDetailsResponse.FromString,
|
219
219
|
options, channel_credentials,
|
220
220
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
221
221
|
|
@@ -230,8 +230,8 @@ class Exec(object):
|
|
230
230
|
wait_for_ready=None,
|
231
231
|
timeout=None,
|
232
232
|
metadata=None):
|
233
|
-
return grpc.experimental.unary_unary(request, target, '/flwr.proto.
|
234
|
-
|
235
|
-
|
233
|
+
return grpc.experimental.unary_unary(request, target, '/flwr.proto.Control/GetAuthTokens',
|
234
|
+
flwr_dot_proto_dot_control__pb2.GetAuthTokensRequest.SerializeToString,
|
235
|
+
flwr_dot_proto_dot_control__pb2.GetAuthTokensResponse.FromString,
|
236
236
|
options, channel_credentials,
|
237
237
|
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
@@ -3,91 +3,91 @@
|
|
3
3
|
isort:skip_file
|
4
4
|
"""
|
5
5
|
import abc
|
6
|
-
import flwr.proto.
|
6
|
+
import flwr.proto.control_pb2
|
7
7
|
import grpc
|
8
8
|
import typing
|
9
9
|
|
10
|
-
class
|
10
|
+
class ControlStub:
|
11
11
|
def __init__(self, channel: grpc.Channel) -> None: ...
|
12
12
|
StartRun: grpc.UnaryUnaryMultiCallable[
|
13
|
-
flwr.proto.
|
14
|
-
flwr.proto.
|
13
|
+
flwr.proto.control_pb2.StartRunRequest,
|
14
|
+
flwr.proto.control_pb2.StartRunResponse]
|
15
15
|
"""Start run upon request"""
|
16
16
|
|
17
17
|
StopRun: grpc.UnaryUnaryMultiCallable[
|
18
|
-
flwr.proto.
|
19
|
-
flwr.proto.
|
18
|
+
flwr.proto.control_pb2.StopRunRequest,
|
19
|
+
flwr.proto.control_pb2.StopRunResponse]
|
20
20
|
"""Stop run upon request"""
|
21
21
|
|
22
22
|
StreamLogs: grpc.UnaryStreamMultiCallable[
|
23
|
-
flwr.proto.
|
24
|
-
flwr.proto.
|
23
|
+
flwr.proto.control_pb2.StreamLogsRequest,
|
24
|
+
flwr.proto.control_pb2.StreamLogsResponse]
|
25
25
|
"""Start log stream upon request"""
|
26
26
|
|
27
27
|
ListRuns: grpc.UnaryUnaryMultiCallable[
|
28
|
-
flwr.proto.
|
29
|
-
flwr.proto.
|
28
|
+
flwr.proto.control_pb2.ListRunsRequest,
|
29
|
+
flwr.proto.control_pb2.ListRunsResponse]
|
30
30
|
"""flwr ls command"""
|
31
31
|
|
32
32
|
GetLoginDetails: grpc.UnaryUnaryMultiCallable[
|
33
|
-
flwr.proto.
|
34
|
-
flwr.proto.
|
33
|
+
flwr.proto.control_pb2.GetLoginDetailsRequest,
|
34
|
+
flwr.proto.control_pb2.GetLoginDetailsResponse]
|
35
35
|
"""Get login details upon request"""
|
36
36
|
|
37
37
|
GetAuthTokens: grpc.UnaryUnaryMultiCallable[
|
38
|
-
flwr.proto.
|
39
|
-
flwr.proto.
|
38
|
+
flwr.proto.control_pb2.GetAuthTokensRequest,
|
39
|
+
flwr.proto.control_pb2.GetAuthTokensResponse]
|
40
40
|
"""Get auth tokens upon request"""
|
41
41
|
|
42
42
|
|
43
|
-
class
|
43
|
+
class ControlServicer(metaclass=abc.ABCMeta):
|
44
44
|
@abc.abstractmethod
|
45
45
|
def StartRun(self,
|
46
|
-
request: flwr.proto.
|
46
|
+
request: flwr.proto.control_pb2.StartRunRequest,
|
47
47
|
context: grpc.ServicerContext,
|
48
|
-
) -> flwr.proto.
|
48
|
+
) -> flwr.proto.control_pb2.StartRunResponse:
|
49
49
|
"""Start run upon request"""
|
50
50
|
pass
|
51
51
|
|
52
52
|
@abc.abstractmethod
|
53
53
|
def StopRun(self,
|
54
|
-
request: flwr.proto.
|
54
|
+
request: flwr.proto.control_pb2.StopRunRequest,
|
55
55
|
context: grpc.ServicerContext,
|
56
|
-
) -> flwr.proto.
|
56
|
+
) -> flwr.proto.control_pb2.StopRunResponse:
|
57
57
|
"""Stop run upon request"""
|
58
58
|
pass
|
59
59
|
|
60
60
|
@abc.abstractmethod
|
61
61
|
def StreamLogs(self,
|
62
|
-
request: flwr.proto.
|
62
|
+
request: flwr.proto.control_pb2.StreamLogsRequest,
|
63
63
|
context: grpc.ServicerContext,
|
64
|
-
) -> typing.Iterator[flwr.proto.
|
64
|
+
) -> typing.Iterator[flwr.proto.control_pb2.StreamLogsResponse]:
|
65
65
|
"""Start log stream upon request"""
|
66
66
|
pass
|
67
67
|
|
68
68
|
@abc.abstractmethod
|
69
69
|
def ListRuns(self,
|
70
|
-
request: flwr.proto.
|
70
|
+
request: flwr.proto.control_pb2.ListRunsRequest,
|
71
71
|
context: grpc.ServicerContext,
|
72
|
-
) -> flwr.proto.
|
72
|
+
) -> flwr.proto.control_pb2.ListRunsResponse:
|
73
73
|
"""flwr ls command"""
|
74
74
|
pass
|
75
75
|
|
76
76
|
@abc.abstractmethod
|
77
77
|
def GetLoginDetails(self,
|
78
|
-
request: flwr.proto.
|
78
|
+
request: flwr.proto.control_pb2.GetLoginDetailsRequest,
|
79
79
|
context: grpc.ServicerContext,
|
80
|
-
) -> flwr.proto.
|
80
|
+
) -> flwr.proto.control_pb2.GetLoginDetailsResponse:
|
81
81
|
"""Get login details upon request"""
|
82
82
|
pass
|
83
83
|
|
84
84
|
@abc.abstractmethod
|
85
85
|
def GetAuthTokens(self,
|
86
|
-
request: flwr.proto.
|
86
|
+
request: flwr.proto.control_pb2.GetAuthTokensRequest,
|
87
87
|
context: grpc.ServicerContext,
|
88
|
-
) -> flwr.proto.
|
88
|
+
) -> flwr.proto.control_pb2.GetAuthTokensResponse:
|
89
89
|
"""Get auth tokens upon request"""
|
90
90
|
pass
|
91
91
|
|
92
92
|
|
93
|
-
def
|
93
|
+
def add_ControlServicer_to_server(servicer: ControlServicer, server: grpc.Server) -> None: ...
|
flwr/server/app.py
CHANGED
@@ -37,13 +37,13 @@ from cryptography.hazmat.primitives.serialization import load_ssh_public_key
|
|
37
37
|
from flwr.common import GRPC_MAX_MESSAGE_LENGTH, EventType, event
|
38
38
|
from flwr.common.address import parse_address
|
39
39
|
from flwr.common.args import try_obtain_server_certificates
|
40
|
-
from flwr.common.auth_plugin import
|
40
|
+
from flwr.common.auth_plugin import ControlAuthPlugin, ControlAuthzPlugin
|
41
41
|
from flwr.common.config import get_flwr_dir, parse_config_args
|
42
42
|
from flwr.common.constant import (
|
43
43
|
AUTH_TYPE_YAML_KEY,
|
44
44
|
AUTHZ_TYPE_YAML_KEY,
|
45
45
|
CLIENT_OCTET,
|
46
|
-
|
46
|
+
CONTROL_API_DEFAULT_SERVER_ADDRESS,
|
47
47
|
FLEET_API_GRPC_RERE_DEFAULT_ADDRESS,
|
48
48
|
FLEET_API_REST_DEFAULT_ADDRESS,
|
49
49
|
ISOLATION_MODE_PROCESS,
|
@@ -74,7 +74,7 @@ from flwr.simulation.app import flwr_simulation
|
|
74
74
|
from flwr.supercore.ffs import FfsFactory
|
75
75
|
from flwr.supercore.object_store import ObjectStoreFactory
|
76
76
|
from flwr.superlink.executor import load_executor
|
77
|
-
from flwr.superlink.servicer.
|
77
|
+
from flwr.superlink.servicer.control import run_control_api_grpc
|
78
78
|
|
79
79
|
from .superlink.fleet.grpc_adapter.grpc_adapter_servicer import GrpcAdapterServicer
|
80
80
|
from .superlink.fleet.grpc_rere.fleet_servicer import FleetServicer
|
@@ -85,15 +85,15 @@ from .superlink.simulation.simulationio_grpc import run_simulationio_api_grpc
|
|
85
85
|
|
86
86
|
DATABASE = ":flwr-in-memory-state:"
|
87
87
|
BASE_DIR = get_flwr_dir() / "superlink" / "ffs"
|
88
|
-
P = TypeVar("P",
|
88
|
+
P = TypeVar("P", ControlAuthPlugin, ControlAuthzPlugin)
|
89
89
|
|
90
90
|
|
91
91
|
try:
|
92
92
|
from flwr.ee import (
|
93
93
|
add_ee_args_superlink,
|
94
|
-
|
95
|
-
|
96
|
-
|
94
|
+
get_control_auth_plugins,
|
95
|
+
get_control_authz_plugins,
|
96
|
+
get_control_event_log_writer_plugins,
|
97
97
|
get_fleet_event_log_writer_plugins,
|
98
98
|
)
|
99
99
|
except ImportError:
|
@@ -102,16 +102,16 @@ except ImportError:
|
|
102
102
|
def add_ee_args_superlink(parser: argparse.ArgumentParser) -> None:
|
103
103
|
"""Add EE-specific arguments to the parser."""
|
104
104
|
|
105
|
-
def
|
106
|
-
"""Return all
|
105
|
+
def get_control_auth_plugins() -> dict[str, type[ControlAuthPlugin]]:
|
106
|
+
"""Return all Control API authentication plugins."""
|
107
107
|
raise NotImplementedError("No authentication plugins are currently supported.")
|
108
108
|
|
109
|
-
def
|
110
|
-
"""Return all
|
109
|
+
def get_control_authz_plugins() -> dict[str, type[ControlAuthzPlugin]]:
|
110
|
+
"""Return all Control API authorization plugins."""
|
111
111
|
raise NotImplementedError("No authorization plugins are currently supported.")
|
112
112
|
|
113
|
-
def
|
114
|
-
"""Return all
|
113
|
+
def get_control_event_log_writer_plugins() -> dict[str, type[EventLogWriterPlugin]]:
|
114
|
+
"""Return all Control API event log writer plugins."""
|
115
115
|
raise NotImplementedError(
|
116
116
|
"No event log writer plugins are currently supported."
|
117
117
|
)
|
@@ -140,7 +140,7 @@ def run_superlink() -> None:
|
|
140
140
|
|
141
141
|
# Parse IP addresses
|
142
142
|
serverappio_address, _, _ = _format_address(args.serverappio_api_address)
|
143
|
-
|
143
|
+
control_address, _, _ = _format_address(args.control_api_address)
|
144
144
|
simulationio_address, _, _ = _format_address(args.simulationio_api_address)
|
145
145
|
|
146
146
|
# Obtain certificates
|
@@ -150,17 +150,17 @@ def run_superlink() -> None:
|
|
150
150
|
# provided
|
151
151
|
verify_tls_cert = not getattr(args, "disable_oidc_tls_cert_verification", None)
|
152
152
|
|
153
|
-
auth_plugin: Optional[
|
154
|
-
authz_plugin: Optional[
|
153
|
+
auth_plugin: Optional[ControlAuthPlugin] = None
|
154
|
+
authz_plugin: Optional[ControlAuthzPlugin] = None
|
155
155
|
event_log_plugin: Optional[EventLogWriterPlugin] = None
|
156
156
|
# Load the auth plugin if the args.user_auth_config is provided
|
157
157
|
if cfg_path := getattr(args, "user_auth_config", None):
|
158
|
-
auth_plugin, authz_plugin =
|
158
|
+
auth_plugin, authz_plugin = _try_obtain_control_auth_plugins(
|
159
159
|
Path(cfg_path), verify_tls_cert
|
160
160
|
)
|
161
161
|
# Enable event logging if the args.enable_event_log is True
|
162
162
|
if args.enable_event_log:
|
163
|
-
event_log_plugin =
|
163
|
+
event_log_plugin = _try_obtain_control_event_log_writer_plugin()
|
164
164
|
|
165
165
|
# Initialize StateFactory
|
166
166
|
state_factory = LinkStateFactory(args.database)
|
@@ -171,10 +171,10 @@ def run_superlink() -> None:
|
|
171
171
|
# Initialize ObjectStoreFactory
|
172
172
|
objectstore_factory = ObjectStoreFactory()
|
173
173
|
|
174
|
-
# Start
|
174
|
+
# Start Control API
|
175
175
|
executor = load_executor(args)
|
176
|
-
|
177
|
-
address=
|
176
|
+
control_server: grpc.Server = run_control_api_grpc(
|
177
|
+
address=control_address,
|
178
178
|
state_factory=state_factory,
|
179
179
|
ffs_factory=ffs_factory,
|
180
180
|
objectstore_factory=objectstore_factory,
|
@@ -187,7 +187,7 @@ def run_superlink() -> None:
|
|
187
187
|
authz_plugin=authz_plugin,
|
188
188
|
event_log_plugin=event_log_plugin,
|
189
189
|
)
|
190
|
-
grpc_servers = [
|
190
|
+
grpc_servers = [control_server]
|
191
191
|
|
192
192
|
# Determine Exec plugin
|
193
193
|
# If simulation is used, don't start ServerAppIo and Fleet APIs
|
@@ -470,10 +470,10 @@ def _try_load_public_keys_node_authentication(
|
|
470
470
|
return node_public_keys
|
471
471
|
|
472
472
|
|
473
|
-
def
|
473
|
+
def _try_obtain_control_auth_plugins(
|
474
474
|
config_path: Path, verify_tls_cert: bool
|
475
|
-
) -> tuple[
|
476
|
-
"""Obtain
|
475
|
+
) -> tuple[ControlAuthPlugin, ControlAuthzPlugin]:
|
476
|
+
"""Obtain Control API authentication and authorization plugins."""
|
477
477
|
# Load YAML file
|
478
478
|
with config_path.open("r", encoding="utf-8") as file:
|
479
479
|
config: dict[str, Any] = yaml.safe_load(file)
|
@@ -503,24 +503,24 @@ def _try_obtain_exec_auth_plugins(
|
|
503
503
|
auth_plugin = _load_plugin(
|
504
504
|
section="authentication",
|
505
505
|
yaml_key=AUTH_TYPE_YAML_KEY,
|
506
|
-
loader=
|
506
|
+
loader=get_control_auth_plugins,
|
507
507
|
)
|
508
508
|
|
509
509
|
# Load authorization plugin
|
510
510
|
authz_plugin = _load_plugin(
|
511
511
|
section="authorization",
|
512
512
|
yaml_key=AUTHZ_TYPE_YAML_KEY,
|
513
|
-
loader=
|
513
|
+
loader=get_control_authz_plugins,
|
514
514
|
)
|
515
515
|
|
516
516
|
return auth_plugin, authz_plugin
|
517
517
|
|
518
518
|
|
519
|
-
def
|
519
|
+
def _try_obtain_control_event_log_writer_plugin() -> Optional[EventLogWriterPlugin]:
|
520
520
|
"""Return an instance of the event log writer plugin."""
|
521
521
|
try:
|
522
522
|
all_plugins: dict[str, type[EventLogWriterPlugin]] = (
|
523
|
-
|
523
|
+
get_control_event_log_writer_plugins()
|
524
524
|
)
|
525
525
|
plugin_class = all_plugins[EventLogWriterType.STDOUT]
|
526
526
|
return plugin_class()
|
@@ -651,7 +651,7 @@ def _parse_args_run_superlink() -> argparse.ArgumentParser:
|
|
651
651
|
add_ee_args_superlink(parser=parser)
|
652
652
|
_add_args_serverappio_api(parser=parser)
|
653
653
|
_add_args_fleet_api(parser=parser)
|
654
|
-
|
654
|
+
_add_args_control_api(parser=parser)
|
655
655
|
_add_args_simulationio_api(parser=parser)
|
656
656
|
|
657
657
|
return parser
|
@@ -775,13 +775,13 @@ def _add_args_fleet_api(parser: argparse.ArgumentParser) -> None:
|
|
775
775
|
)
|
776
776
|
|
777
777
|
|
778
|
-
def
|
779
|
-
"""Add command line arguments for
|
778
|
+
def _add_args_control_api(parser: argparse.ArgumentParser) -> None:
|
779
|
+
"""Add command line arguments for Control API."""
|
780
780
|
parser.add_argument(
|
781
|
-
"--
|
782
|
-
help="
|
783
|
-
f"By default, it is set to {
|
784
|
-
default=
|
781
|
+
"--control-api-address",
|
782
|
+
help="Control API server address (IPv4, IPv6, or a domain name) "
|
783
|
+
f"By default, it is set to {CONTROL_API_DEFAULT_SERVER_ADDRESS}.",
|
784
|
+
default=CONTROL_API_DEFAULT_SERVER_ADDRESS,
|
785
785
|
)
|
786
786
|
parser.add_argument(
|
787
787
|
"--executor",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
# ==============================================================================
|
15
|
-
"""Executor for
|
15
|
+
"""Executor for Control API."""
|
16
16
|
|
17
17
|
|
18
18
|
from .app import load_executor
|
@@ -12,11 +12,11 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
# ==============================================================================
|
15
|
-
"""
|
15
|
+
"""Control API Servicer."""
|
16
16
|
|
17
17
|
|
18
|
-
from .
|
18
|
+
from .control_grpc import run_control_api_grpc
|
19
19
|
|
20
20
|
__all__ = [
|
21
|
-
"
|
21
|
+
"run_control_api_grpc",
|
22
22
|
]
|
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
# ==============================================================================
|
15
|
-
"""Flower
|
15
|
+
"""Flower Control API event log interceptor."""
|
16
16
|
|
17
17
|
|
18
18
|
from collections.abc import Iterator
|
@@ -24,11 +24,11 @@ from google.protobuf.message import Message as GrpcMessage
|
|
24
24
|
from flwr.common.event_log_plugin.event_log_plugin import EventLogWriterPlugin
|
25
25
|
from flwr.common.typing import LogEntry
|
26
26
|
|
27
|
-
from .
|
27
|
+
from .control_user_auth_interceptor import shared_account_info
|
28
28
|
|
29
29
|
|
30
|
-
class
|
31
|
-
"""
|
30
|
+
class ControlEventLogInterceptor(grpc.ServerInterceptor): # type: ignore
|
31
|
+
"""Control API interceptor for logging events."""
|
32
32
|
|
33
33
|
def __init__(self, log_plugin: EventLogWriterPlugin) -> None:
|
34
34
|
self.log_plugin = log_plugin
|
@@ -44,12 +44,12 @@ class ExecEventLogInterceptor(grpc.ServerInterceptor): # type: ignore
|
|
44
44
|
Continue RPC call if event logger is enabled on the SuperLink, else, terminate
|
45
45
|
RPC call by setting context to abort.
|
46
46
|
"""
|
47
|
-
# Only apply to
|
48
|
-
if not handler_call_details.method.startswith("/flwr.proto.
|
47
|
+
# Only apply to Control service
|
48
|
+
if not handler_call_details.method.startswith("/flwr.proto.Control/"):
|
49
49
|
return continuation(handler_call_details)
|
50
50
|
|
51
51
|
# One of the method handlers in
|
52
|
-
# `flwr.superlink.servicer.
|
52
|
+
# `flwr.superlink.servicer.control.ControlServicer`
|
53
53
|
method_handler: grpc.RpcMethodHandler = continuation(handler_call_details)
|
54
54
|
method_name: str = handler_call_details.method
|
55
55
|
return self._generic_event_log_unary_method_handler(method_handler, method_name)
|