flwr-nightly 1.9.0.dev20240509__py3-none-any.whl → 1.9.0.dev20240531__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.
Potentially problematic release.
This version of flwr-nightly might be problematic. Click here for more details.
- flwr/cli/build.py +2 -4
- flwr/cli/config_utils.py +1 -23
- flwr/cli/new/new.py +2 -0
- flwr/cli/new/templates/app/code/client.jax.py.tpl +55 -0
- flwr/cli/new/templates/app/code/server.jax.py.tpl +12 -0
- flwr/cli/new/templates/app/code/task.jax.py.tpl +57 -0
- flwr/cli/new/templates/app/pyproject.hf.toml.tpl +6 -0
- flwr/cli/new/templates/app/pyproject.jax.toml.tpl +28 -0
- flwr/cli/new/templates/app/pyproject.mlx.toml.tpl +6 -0
- flwr/cli/new/templates/app/pyproject.numpy.toml.tpl +6 -0
- flwr/cli/new/templates/app/pyproject.pytorch.toml.tpl +6 -0
- flwr/cli/new/templates/app/pyproject.sklearn.toml.tpl +6 -0
- flwr/cli/new/templates/app/pyproject.tensorflow.toml.tpl +6 -0
- flwr/cli/run/run.py +20 -4
- flwr/client/grpc_rere_client/connection.py +5 -2
- flwr/client/mod/comms_mods.py +4 -4
- flwr/client/mod/localdp_mod.py +1 -2
- flwr/client/supernode/app.py +41 -23
- flwr/common/recordset_compat.py +8 -1
- flwr/common/secure_aggregation/crypto/symmetric_encryption.py +0 -15
- flwr/proto/grpcadapter_pb2.py +32 -0
- flwr/proto/grpcadapter_pb2.pyi +43 -0
- flwr/proto/grpcadapter_pb2_grpc.py +66 -0
- flwr/proto/grpcadapter_pb2_grpc.pyi +24 -0
- flwr/server/app.py +134 -182
- flwr/server/driver/__init__.py +3 -2
- flwr/server/driver/inmemory_driver.py +181 -0
- flwr/server/server.py +9 -2
- flwr/server/strategy/dp_adaptive_clipping.py +2 -4
- flwr/server/strategy/dp_fixed_clipping.py +2 -4
- flwr/server/superlink/driver/driver_servicer.py +2 -2
- flwr/server/superlink/fleet/vce/backend/raybackend.py +8 -3
- flwr/server/superlink/fleet/vce/vce_api.py +1 -1
- flwr/server/workflow/default_workflows.py +67 -22
- flwr/simulation/run_simulation.py +2 -31
- {flwr_nightly-1.9.0.dev20240509.dist-info → flwr_nightly-1.9.0.dev20240531.dist-info}/METADATA +5 -3
- {flwr_nightly-1.9.0.dev20240509.dist-info → flwr_nightly-1.9.0.dev20240531.dist-info}/RECORD +40 -31
- {flwr_nightly-1.9.0.dev20240509.dist-info → flwr_nightly-1.9.0.dev20240531.dist-info}/LICENSE +0 -0
- {flwr_nightly-1.9.0.dev20240509.dist-info → flwr_nightly-1.9.0.dev20240531.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.9.0.dev20240509.dist-info → flwr_nightly-1.9.0.dev20240531.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
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 grpcadapter_pb2 as flwr_dot_proto_dot_grpcadapter__pb2
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class GrpcAdapterStub(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.SendReceive = channel.unary_unary(
|
|
18
|
+
'/flwr.proto.GrpcAdapter/SendReceive',
|
|
19
|
+
request_serializer=flwr_dot_proto_dot_grpcadapter__pb2.MessageContainer.SerializeToString,
|
|
20
|
+
response_deserializer=flwr_dot_proto_dot_grpcadapter__pb2.MessageContainer.FromString,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class GrpcAdapterServicer(object):
|
|
25
|
+
"""Missing associated documentation comment in .proto file."""
|
|
26
|
+
|
|
27
|
+
def SendReceive(self, request, context):
|
|
28
|
+
"""Missing associated documentation comment in .proto file."""
|
|
29
|
+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
|
30
|
+
context.set_details('Method not implemented!')
|
|
31
|
+
raise NotImplementedError('Method not implemented!')
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def add_GrpcAdapterServicer_to_server(servicer, server):
|
|
35
|
+
rpc_method_handlers = {
|
|
36
|
+
'SendReceive': grpc.unary_unary_rpc_method_handler(
|
|
37
|
+
servicer.SendReceive,
|
|
38
|
+
request_deserializer=flwr_dot_proto_dot_grpcadapter__pb2.MessageContainer.FromString,
|
|
39
|
+
response_serializer=flwr_dot_proto_dot_grpcadapter__pb2.MessageContainer.SerializeToString,
|
|
40
|
+
),
|
|
41
|
+
}
|
|
42
|
+
generic_handler = grpc.method_handlers_generic_handler(
|
|
43
|
+
'flwr.proto.GrpcAdapter', rpc_method_handlers)
|
|
44
|
+
server.add_generic_rpc_handlers((generic_handler,))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# This class is part of an EXPERIMENTAL API.
|
|
48
|
+
class GrpcAdapter(object):
|
|
49
|
+
"""Missing associated documentation comment in .proto file."""
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def SendReceive(request,
|
|
53
|
+
target,
|
|
54
|
+
options=(),
|
|
55
|
+
channel_credentials=None,
|
|
56
|
+
call_credentials=None,
|
|
57
|
+
insecure=False,
|
|
58
|
+
compression=None,
|
|
59
|
+
wait_for_ready=None,
|
|
60
|
+
timeout=None,
|
|
61
|
+
metadata=None):
|
|
62
|
+
return grpc.experimental.unary_unary(request, target, '/flwr.proto.GrpcAdapter/SendReceive',
|
|
63
|
+
flwr_dot_proto_dot_grpcadapter__pb2.MessageContainer.SerializeToString,
|
|
64
|
+
flwr_dot_proto_dot_grpcadapter__pb2.MessageContainer.FromString,
|
|
65
|
+
options, channel_credentials,
|
|
66
|
+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@generated by mypy-protobuf. Do not edit manually!
|
|
3
|
+
isort:skip_file
|
|
4
|
+
"""
|
|
5
|
+
import abc
|
|
6
|
+
import flwr.proto.grpcadapter_pb2
|
|
7
|
+
import grpc
|
|
8
|
+
|
|
9
|
+
class GrpcAdapterStub:
|
|
10
|
+
def __init__(self, channel: grpc.Channel) -> None: ...
|
|
11
|
+
SendReceive: grpc.UnaryUnaryMultiCallable[
|
|
12
|
+
flwr.proto.grpcadapter_pb2.MessageContainer,
|
|
13
|
+
flwr.proto.grpcadapter_pb2.MessageContainer]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GrpcAdapterServicer(metaclass=abc.ABCMeta):
|
|
17
|
+
@abc.abstractmethod
|
|
18
|
+
def SendReceive(self,
|
|
19
|
+
request: flwr.proto.grpcadapter_pb2.MessageContainer,
|
|
20
|
+
context: grpc.ServicerContext,
|
|
21
|
+
) -> flwr.proto.grpcadapter_pb2.MessageContainer: ...
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def add_GrpcAdapterServicer_to_server(servicer: GrpcAdapterServicer, server: grpc.Server) -> None: ...
|
flwr/server/app.py
CHANGED
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"""Flower server app."""
|
|
16
16
|
|
|
17
17
|
import argparse
|
|
18
|
-
import asyncio
|
|
19
18
|
import csv
|
|
20
19
|
import importlib.util
|
|
21
20
|
import sys
|
|
22
21
|
import threading
|
|
23
|
-
from logging import
|
|
22
|
+
from logging import INFO, WARN
|
|
24
23
|
from os.path import isfile
|
|
25
24
|
from pathlib import Path
|
|
26
|
-
from typing import
|
|
25
|
+
from typing import Optional, Sequence, Set, Tuple
|
|
27
26
|
|
|
28
27
|
import grpc
|
|
28
|
+
from cryptography.exceptions import UnsupportedAlgorithm
|
|
29
29
|
from cryptography.hazmat.primitives.asymmetric import ec
|
|
30
30
|
from cryptography.hazmat.primitives.serialization import (
|
|
31
31
|
load_ssh_private_key,
|
|
@@ -38,14 +38,12 @@ from flwr.common.constant import (
|
|
|
38
38
|
MISSING_EXTRA_REST,
|
|
39
39
|
TRANSPORT_TYPE_GRPC_RERE,
|
|
40
40
|
TRANSPORT_TYPE_REST,
|
|
41
|
-
TRANSPORT_TYPE_VCE,
|
|
42
41
|
)
|
|
43
42
|
from flwr.common.exit_handlers import register_exit_handlers
|
|
44
43
|
from flwr.common.logger import log, warn_deprecated_feature
|
|
45
44
|
from flwr.common.secure_aggregation.crypto.symmetric_encryption import (
|
|
46
45
|
private_key_to_bytes,
|
|
47
46
|
public_key_to_bytes,
|
|
48
|
-
ssh_types_to_elliptic_curve,
|
|
49
47
|
)
|
|
50
48
|
from flwr.proto.fleet_pb2_grpc import ( # pylint: disable=E0611
|
|
51
49
|
add_FleetServicer_to_server,
|
|
@@ -63,7 +61,6 @@ from .superlink.fleet.grpc_bidi.grpc_server import (
|
|
|
63
61
|
)
|
|
64
62
|
from .superlink.fleet.grpc_rere.fleet_servicer import FleetServicer
|
|
65
63
|
from .superlink.fleet.grpc_rere.server_interceptor import AuthenticateServerInterceptor
|
|
66
|
-
from .superlink.fleet.vce import start_vce
|
|
67
64
|
from .superlink.state import StateFactory
|
|
68
65
|
|
|
69
66
|
ADDRESS_DRIVER_API = "0.0.0.0:9091"
|
|
@@ -349,6 +346,9 @@ def run_superlink() -> None:
|
|
|
349
346
|
sys.exit(MISSING_EXTRA_REST)
|
|
350
347
|
address_arg = args.rest_fleet_api_address
|
|
351
348
|
parsed_address = parse_address(address_arg)
|
|
349
|
+
_, ssl_certfile, ssl_keyfile = (
|
|
350
|
+
certificates if certificates is not None else (None, None, None)
|
|
351
|
+
)
|
|
352
352
|
if not parsed_address:
|
|
353
353
|
sys.exit(f"Fleet IP address ({address_arg}) cannot be parsed.")
|
|
354
354
|
host, port, _ = parsed_address
|
|
@@ -357,8 +357,8 @@ def run_superlink() -> None:
|
|
|
357
357
|
args=(
|
|
358
358
|
host,
|
|
359
359
|
port,
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
ssl_keyfile,
|
|
361
|
+
ssl_certfile,
|
|
362
362
|
state_factory,
|
|
363
363
|
args.rest_fleet_api_workers,
|
|
364
364
|
),
|
|
@@ -401,17 +401,6 @@ def run_superlink() -> None:
|
|
|
401
401
|
interceptors=interceptors,
|
|
402
402
|
)
|
|
403
403
|
grpc_servers.append(fleet_server)
|
|
404
|
-
elif args.fleet_api_type == TRANSPORT_TYPE_VCE:
|
|
405
|
-
f_stop = asyncio.Event() # Does nothing
|
|
406
|
-
_run_fleet_api_vce(
|
|
407
|
-
num_supernodes=args.num_supernodes,
|
|
408
|
-
client_app_attr=args.client_app,
|
|
409
|
-
backend_name=args.backend,
|
|
410
|
-
backend_config_json_stream=args.backend_config,
|
|
411
|
-
app_dir=args.app_dir,
|
|
412
|
-
state_factory=state_factory,
|
|
413
|
-
f_stop=f_stop,
|
|
414
|
-
)
|
|
415
404
|
else:
|
|
416
405
|
raise ValueError(f"Unknown fleet_api_type: {args.fleet_api_type}")
|
|
417
406
|
|
|
@@ -435,44 +424,69 @@ def _try_setup_client_authentication(
|
|
|
435
424
|
args: argparse.Namespace,
|
|
436
425
|
certificates: Optional[Tuple[bytes, bytes, bytes]],
|
|
437
426
|
) -> Optional[Tuple[Set[bytes], ec.EllipticCurvePrivateKey, ec.EllipticCurvePublicKey]]:
|
|
438
|
-
if
|
|
427
|
+
if (
|
|
428
|
+
not args.auth_list_public_keys
|
|
429
|
+
and not args.auth_superlink_private_key
|
|
430
|
+
and not args.auth_superlink_public_key
|
|
431
|
+
):
|
|
439
432
|
return None
|
|
440
433
|
|
|
434
|
+
if (
|
|
435
|
+
not args.auth_list_public_keys
|
|
436
|
+
or not args.auth_superlink_private_key
|
|
437
|
+
or not args.auth_superlink_public_key
|
|
438
|
+
):
|
|
439
|
+
sys.exit(
|
|
440
|
+
"Authentication requires providing file paths for "
|
|
441
|
+
"'--auth-list-public-keys', '--auth-superlink-private-key' and "
|
|
442
|
+
"'--auth-superlink-public-key'. Provide all three to enable authentication."
|
|
443
|
+
)
|
|
444
|
+
|
|
441
445
|
if certificates is None:
|
|
442
446
|
sys.exit(
|
|
443
|
-
"
|
|
444
|
-
"Please provide certificate paths
|
|
445
|
-
"
|
|
447
|
+
"Authentication requires secure connections. "
|
|
448
|
+
"Please provide certificate paths to `--ssl-certfile`, "
|
|
449
|
+
"`--ssl-keyfile`, and `—-ssl-ca-certfile` and try again."
|
|
446
450
|
)
|
|
447
451
|
|
|
448
|
-
client_keys_file_path = Path(args.
|
|
452
|
+
client_keys_file_path = Path(args.auth_list_public_keys)
|
|
449
453
|
if not client_keys_file_path.exists():
|
|
450
454
|
sys.exit(
|
|
451
|
-
"The provided path to the
|
|
455
|
+
"The provided path to the known public keys CSV file does not exist: "
|
|
452
456
|
f"{client_keys_file_path}. "
|
|
453
|
-
"Please provide the CSV file path containing known
|
|
454
|
-
"to '--
|
|
457
|
+
"Please provide the CSV file path containing known public keys "
|
|
458
|
+
"to '--auth-list-public-keys'."
|
|
455
459
|
)
|
|
456
460
|
|
|
457
461
|
client_public_keys: Set[bytes] = set()
|
|
458
|
-
ssh_private_key = load_ssh_private_key(
|
|
459
|
-
Path(args.require_client_authentication[1]).read_bytes(),
|
|
460
|
-
None,
|
|
461
|
-
)
|
|
462
|
-
ssh_public_key = load_ssh_public_key(
|
|
463
|
-
Path(args.require_client_authentication[2]).read_bytes()
|
|
464
|
-
)
|
|
465
462
|
|
|
466
463
|
try:
|
|
467
|
-
|
|
468
|
-
|
|
464
|
+
ssh_private_key = load_ssh_private_key(
|
|
465
|
+
Path(args.auth_superlink_private_key).read_bytes(),
|
|
466
|
+
None,
|
|
469
467
|
)
|
|
470
|
-
|
|
468
|
+
if not isinstance(ssh_private_key, ec.EllipticCurvePrivateKey):
|
|
469
|
+
raise ValueError()
|
|
470
|
+
except (ValueError, UnsupportedAlgorithm):
|
|
471
471
|
sys.exit(
|
|
472
|
-
"
|
|
473
|
-
"key
|
|
474
|
-
"private key pair. Please
|
|
475
|
-
"
|
|
472
|
+
"Error: Unable to parse the private key file in "
|
|
473
|
+
"'--auth-superlink-private-key'. Authentication requires elliptic "
|
|
474
|
+
"curve private and public key pair. Please ensure that the file "
|
|
475
|
+
"path points to a valid private key file and try again."
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
try:
|
|
479
|
+
ssh_public_key = load_ssh_public_key(
|
|
480
|
+
Path(args.auth_superlink_public_key).read_bytes()
|
|
481
|
+
)
|
|
482
|
+
if not isinstance(ssh_public_key, ec.EllipticCurvePublicKey):
|
|
483
|
+
raise ValueError()
|
|
484
|
+
except (ValueError, UnsupportedAlgorithm):
|
|
485
|
+
sys.exit(
|
|
486
|
+
"Error: Unable to parse the public key file in "
|
|
487
|
+
"'--auth-superlink-public-key'. Authentication requires elliptic "
|
|
488
|
+
"curve private and public key pair. Please ensure that the file "
|
|
489
|
+
"path points to a valid public key file and try again."
|
|
476
490
|
)
|
|
477
491
|
|
|
478
492
|
with open(client_keys_file_path, newline="", encoding="utf-8") as csvfile:
|
|
@@ -484,14 +498,14 @@ def _try_setup_client_authentication(
|
|
|
484
498
|
client_public_keys.add(public_key_to_bytes(public_key))
|
|
485
499
|
else:
|
|
486
500
|
sys.exit(
|
|
487
|
-
"Error: Unable to parse the public keys in the
|
|
488
|
-
"file. Please ensure that the
|
|
489
|
-
"SSH public keys and try again."
|
|
501
|
+
"Error: Unable to parse the public keys in the CSV "
|
|
502
|
+
"file. Please ensure that the CSV file path points to a valid "
|
|
503
|
+
"known SSH public keys files and try again."
|
|
490
504
|
)
|
|
491
505
|
return (
|
|
492
506
|
client_public_keys,
|
|
493
|
-
|
|
494
|
-
|
|
507
|
+
ssh_private_key,
|
|
508
|
+
ssh_public_key,
|
|
495
509
|
)
|
|
496
510
|
|
|
497
511
|
|
|
@@ -501,21 +515,52 @@ def _try_obtain_certificates(
|
|
|
501
515
|
# Obtain certificates
|
|
502
516
|
if args.insecure:
|
|
503
517
|
log(WARN, "Option `--insecure` was set. Starting insecure HTTP server.")
|
|
504
|
-
|
|
518
|
+
return None
|
|
505
519
|
# Check if certificates are provided
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
520
|
+
if args.fleet_api_type == TRANSPORT_TYPE_GRPC_RERE:
|
|
521
|
+
if args.ssl_certfile and args.ssl_keyfile and args.ssl_ca_certfile:
|
|
522
|
+
if not isfile(args.ssl_ca_certfile):
|
|
523
|
+
sys.exit("Path argument `--ssl-ca-certfile` does not point to a file.")
|
|
524
|
+
if not isfile(args.ssl_certfile):
|
|
525
|
+
sys.exit("Path argument `--ssl-certfile` does not point to a file.")
|
|
526
|
+
if not isfile(args.ssl_keyfile):
|
|
527
|
+
sys.exit("Path argument `--ssl-keyfile` does not point to a file.")
|
|
528
|
+
certificates = (
|
|
529
|
+
Path(args.ssl_ca_certfile).read_bytes(), # CA certificate
|
|
530
|
+
Path(args.ssl_certfile).read_bytes(), # server certificate
|
|
531
|
+
Path(args.ssl_keyfile).read_bytes(), # server private key
|
|
532
|
+
)
|
|
533
|
+
return certificates
|
|
534
|
+
if args.ssl_certfile or args.ssl_keyfile or args.ssl_ca_certfile:
|
|
535
|
+
sys.exit(
|
|
536
|
+
"You need to provide valid file paths to `--ssl-certfile`, "
|
|
537
|
+
"`--ssl-keyfile`, and `—-ssl-ca-certfile` to create a secure "
|
|
538
|
+
"connection in Fleet API server (gRPC-rere)."
|
|
539
|
+
)
|
|
540
|
+
if args.fleet_api_type == TRANSPORT_TYPE_REST:
|
|
541
|
+
if args.ssl_certfile and args.ssl_keyfile:
|
|
542
|
+
if not isfile(args.ssl_certfile):
|
|
543
|
+
sys.exit("Path argument `--ssl-certfile` does not point to a file.")
|
|
544
|
+
if not isfile(args.ssl_keyfile):
|
|
545
|
+
sys.exit("Path argument `--ssl-keyfile` does not point to a file.")
|
|
546
|
+
certificates = (
|
|
547
|
+
b"",
|
|
548
|
+
Path(args.ssl_certfile).read_bytes(), # server certificate
|
|
549
|
+
Path(args.ssl_keyfile).read_bytes(), # server private key
|
|
550
|
+
)
|
|
551
|
+
return certificates
|
|
552
|
+
if args.ssl_certfile or args.ssl_keyfile:
|
|
553
|
+
sys.exit(
|
|
554
|
+
"You need to provide valid file paths to `--ssl-certfile` "
|
|
555
|
+
"and `--ssl-keyfile` to create a secure connection "
|
|
556
|
+
"in Fleet API server (REST, experimental)."
|
|
557
|
+
)
|
|
558
|
+
sys.exit(
|
|
559
|
+
"Certificates are required unless running in insecure mode. "
|
|
560
|
+
"Please provide certificate paths to `--ssl-certfile`, "
|
|
561
|
+
"`--ssl-keyfile`, and `—-ssl-ca-certfile` or run the server "
|
|
562
|
+
"in insecure mode using '--insecure' if you understand the risks."
|
|
563
|
+
)
|
|
519
564
|
|
|
520
565
|
|
|
521
566
|
def _run_fleet_api_grpc_rere(
|
|
@@ -544,29 +589,6 @@ def _run_fleet_api_grpc_rere(
|
|
|
544
589
|
return fleet_grpc_server
|
|
545
590
|
|
|
546
591
|
|
|
547
|
-
# pylint: disable=too-many-arguments
|
|
548
|
-
def _run_fleet_api_vce(
|
|
549
|
-
num_supernodes: int,
|
|
550
|
-
client_app_attr: str,
|
|
551
|
-
backend_name: str,
|
|
552
|
-
backend_config_json_stream: str,
|
|
553
|
-
app_dir: str,
|
|
554
|
-
state_factory: StateFactory,
|
|
555
|
-
f_stop: asyncio.Event,
|
|
556
|
-
) -> None:
|
|
557
|
-
log(INFO, "Flower VCE: Starting Fleet API (VirtualClientEngine)")
|
|
558
|
-
|
|
559
|
-
start_vce(
|
|
560
|
-
num_supernodes=num_supernodes,
|
|
561
|
-
client_app_attr=client_app_attr,
|
|
562
|
-
backend_name=backend_name,
|
|
563
|
-
backend_config_json_stream=backend_config_json_stream,
|
|
564
|
-
state_factory=state_factory,
|
|
565
|
-
app_dir=app_dir,
|
|
566
|
-
f_stop=f_stop,
|
|
567
|
-
)
|
|
568
|
-
|
|
569
|
-
|
|
570
592
|
# pylint: disable=import-outside-toplevel,too-many-arguments
|
|
571
593
|
def _run_fleet_api_rest(
|
|
572
594
|
host: str,
|
|
@@ -594,14 +616,6 @@ def _run_fleet_api_rest(
|
|
|
594
616
|
# See: https://www.starlette.io/applications/#accessing-the-app-instance
|
|
595
617
|
fast_api_app.state.STATE_FACTORY = state_factory
|
|
596
618
|
|
|
597
|
-
validation_exceptions = _validate_ssl_files(
|
|
598
|
-
ssl_certfile=ssl_certfile, ssl_keyfile=ssl_keyfile
|
|
599
|
-
)
|
|
600
|
-
if any(validation_exceptions):
|
|
601
|
-
# Starting with 3.11 we can use ExceptionGroup but for now
|
|
602
|
-
# this seems to be the reasonable approach.
|
|
603
|
-
raise ValueError(validation_exceptions)
|
|
604
|
-
|
|
605
619
|
uvicorn.run(
|
|
606
620
|
app="flwr.server.superlink.fleet.rest_rere.rest_api:app",
|
|
607
621
|
port=port,
|
|
@@ -614,32 +628,6 @@ def _run_fleet_api_rest(
|
|
|
614
628
|
)
|
|
615
629
|
|
|
616
630
|
|
|
617
|
-
def _validate_ssl_files(
|
|
618
|
-
ssl_keyfile: Optional[str], ssl_certfile: Optional[str]
|
|
619
|
-
) -> List[ValueError]:
|
|
620
|
-
validation_exceptions = []
|
|
621
|
-
|
|
622
|
-
if ssl_keyfile is not None and not isfile(ssl_keyfile):
|
|
623
|
-
msg = "Path argument `--ssl-keyfile` does not point to a file."
|
|
624
|
-
log(ERROR, msg)
|
|
625
|
-
validation_exceptions.append(ValueError(msg))
|
|
626
|
-
|
|
627
|
-
if ssl_certfile is not None and not isfile(ssl_certfile):
|
|
628
|
-
msg = "Path argument `--ssl-certfile` does not point to a file."
|
|
629
|
-
log(ERROR, msg)
|
|
630
|
-
validation_exceptions.append(ValueError(msg))
|
|
631
|
-
|
|
632
|
-
if not bool(ssl_keyfile) == bool(ssl_certfile):
|
|
633
|
-
msg = (
|
|
634
|
-
"When setting one of `--ssl-keyfile` and "
|
|
635
|
-
"`--ssl-certfile`, both have to be used."
|
|
636
|
-
)
|
|
637
|
-
log(ERROR, msg)
|
|
638
|
-
validation_exceptions.append(ValueError(msg))
|
|
639
|
-
|
|
640
|
-
return validation_exceptions
|
|
641
|
-
|
|
642
|
-
|
|
643
631
|
def _parse_args_run_driver_api() -> argparse.ArgumentParser:
|
|
644
632
|
"""Parse command line arguments for Driver API."""
|
|
645
633
|
parser = argparse.ArgumentParser(
|
|
@@ -696,13 +684,23 @@ def _add_args_common(parser: argparse.ArgumentParser) -> None:
|
|
|
696
684
|
"Use this flag only if you understand the risks.",
|
|
697
685
|
)
|
|
698
686
|
parser.add_argument(
|
|
699
|
-
"--
|
|
700
|
-
|
|
701
|
-
|
|
687
|
+
"--ssl-certfile",
|
|
688
|
+
help="Fleet API server SSL certificate file (as a path str) "
|
|
689
|
+
"to create a secure connection.",
|
|
690
|
+
type=str,
|
|
691
|
+
default=None,
|
|
692
|
+
)
|
|
693
|
+
parser.add_argument(
|
|
694
|
+
"--ssl-keyfile",
|
|
695
|
+
help="Fleet API server SSL private key file (as a path str) "
|
|
696
|
+
"to create a secure connection.",
|
|
697
|
+
type=str,
|
|
698
|
+
)
|
|
699
|
+
parser.add_argument(
|
|
700
|
+
"--ssl-ca-certfile",
|
|
701
|
+
help="Fleet API server SSL CA certificate file (as a path str) "
|
|
702
|
+
"to create a secure connection.",
|
|
702
703
|
type=str,
|
|
703
|
-
help="Paths to the CA certificate, server certificate, and server private "
|
|
704
|
-
"key, in that order. Note: The server can only be started without "
|
|
705
|
-
"certificates by enabling the `--insecure` flag.",
|
|
706
704
|
)
|
|
707
705
|
parser.add_argument(
|
|
708
706
|
"--database",
|
|
@@ -714,13 +712,20 @@ def _add_args_common(parser: argparse.ArgumentParser) -> None:
|
|
|
714
712
|
default=DATABASE,
|
|
715
713
|
)
|
|
716
714
|
parser.add_argument(
|
|
717
|
-
"--
|
|
718
|
-
|
|
719
|
-
|
|
715
|
+
"--auth-list-public-keys",
|
|
716
|
+
type=str,
|
|
717
|
+
help="A CSV file (as a path str) containing a list of known public "
|
|
718
|
+
"keys to enable authentication.",
|
|
719
|
+
)
|
|
720
|
+
parser.add_argument(
|
|
721
|
+
"--auth-superlink-private-key",
|
|
722
|
+
type=str,
|
|
723
|
+
help="The SuperLink's private key (as a path str) to enable authentication.",
|
|
724
|
+
)
|
|
725
|
+
parser.add_argument(
|
|
726
|
+
"--auth-superlink-public-key",
|
|
720
727
|
type=str,
|
|
721
|
-
help="
|
|
722
|
-
"known client public keys for authentication, (2) the server's private "
|
|
723
|
-
"key file, and (3) the server's public key file.",
|
|
728
|
+
help="The SuperLink's public key (as a path str) to enable authentication.",
|
|
724
729
|
)
|
|
725
730
|
|
|
726
731
|
|
|
@@ -751,14 +756,6 @@ def _add_args_fleet_api(parser: argparse.ArgumentParser) -> None:
|
|
|
751
756
|
help="Start a Fleet API server (REST, experimental)",
|
|
752
757
|
)
|
|
753
758
|
|
|
754
|
-
ex_group.add_argument(
|
|
755
|
-
"--vce",
|
|
756
|
-
action="store_const",
|
|
757
|
-
dest="fleet_api_type",
|
|
758
|
-
const=TRANSPORT_TYPE_VCE,
|
|
759
|
-
help="Start a Fleet API server (VirtualClientEngine)",
|
|
760
|
-
)
|
|
761
|
-
|
|
762
759
|
# Fleet API gRPC-rere options
|
|
763
760
|
grpc_rere_group = parser.add_argument_group(
|
|
764
761
|
"Fleet API (gRPC-rere) server options", ""
|
|
@@ -776,54 +773,9 @@ def _add_args_fleet_api(parser: argparse.ArgumentParser) -> None:
|
|
|
776
773
|
help="Fleet API (REST) server address (IPv4, IPv6, or a domain name)",
|
|
777
774
|
default=ADDRESS_FLEET_API_REST,
|
|
778
775
|
)
|
|
779
|
-
rest_group.add_argument(
|
|
780
|
-
"--ssl-certfile",
|
|
781
|
-
help="Fleet API (REST) server SSL certificate file (as a path str), "
|
|
782
|
-
"needed for using 'https'.",
|
|
783
|
-
default=None,
|
|
784
|
-
)
|
|
785
|
-
rest_group.add_argument(
|
|
786
|
-
"--ssl-keyfile",
|
|
787
|
-
help="Fleet API (REST) server SSL private key file (as a path str), "
|
|
788
|
-
"needed for using 'https'.",
|
|
789
|
-
default=None,
|
|
790
|
-
)
|
|
791
776
|
rest_group.add_argument(
|
|
792
777
|
"--rest-fleet-api-workers",
|
|
793
778
|
help="Set the number of concurrent workers for the Fleet API REST server.",
|
|
794
779
|
type=int,
|
|
795
780
|
default=1,
|
|
796
781
|
)
|
|
797
|
-
|
|
798
|
-
# Fleet API VCE options
|
|
799
|
-
vce_group = parser.add_argument_group("Fleet API (VCE) server options", "")
|
|
800
|
-
vce_group.add_argument(
|
|
801
|
-
"--client-app",
|
|
802
|
-
help="For example: `client:app` or `project.package.module:wrapper.app`.",
|
|
803
|
-
)
|
|
804
|
-
vce_group.add_argument(
|
|
805
|
-
"--num-supernodes",
|
|
806
|
-
type=int,
|
|
807
|
-
help="Number of simulated SuperNodes.",
|
|
808
|
-
)
|
|
809
|
-
vce_group.add_argument(
|
|
810
|
-
"--backend",
|
|
811
|
-
default="ray",
|
|
812
|
-
type=str,
|
|
813
|
-
help="Simulation backend that executes the ClientApp.",
|
|
814
|
-
)
|
|
815
|
-
vce_group.add_argument(
|
|
816
|
-
"--backend-config",
|
|
817
|
-
type=str,
|
|
818
|
-
default='{"client_resources": {"num_cpus":1, "num_gpus":0.0}, "tensorflow": 0}',
|
|
819
|
-
help='A JSON formatted stream, e.g \'{"<keyA>":<value>, "<keyB>":<value>}\' to '
|
|
820
|
-
"configure a backend. Values supported in <value> are those included by "
|
|
821
|
-
"`flwr.common.typing.ConfigsRecordValues`. ",
|
|
822
|
-
)
|
|
823
|
-
parser.add_argument(
|
|
824
|
-
"--app-dir",
|
|
825
|
-
default="",
|
|
826
|
-
help="Add specified directory to the PYTHONPATH and load"
|
|
827
|
-
"ClientApp from there."
|
|
828
|
-
" Default: current working directory.",
|
|
829
|
-
)
|
flwr/server/driver/__init__.py
CHANGED
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
from .driver import Driver
|
|
19
|
-
from .grpc_driver import GrpcDriver
|
|
19
|
+
from .grpc_driver import GrpcDriver
|
|
20
|
+
from .inmemory_driver import InMemoryDriver
|
|
20
21
|
|
|
21
22
|
__all__ = [
|
|
22
23
|
"Driver",
|
|
23
24
|
"GrpcDriver",
|
|
24
|
-
"
|
|
25
|
+
"InMemoryDriver",
|
|
25
26
|
]
|