flwr-nightly 1.9.0.dev20240524__py3-none-any.whl → 1.9.0.dev20240528__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/server/app.py CHANGED
@@ -15,15 +15,14 @@
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 ERROR, INFO, WARN
22
+ from logging import INFO, WARN
24
23
  from os.path import isfile
25
24
  from pathlib import Path
26
- from typing import List, Optional, Sequence, Set, Tuple
25
+ from typing import Optional, Sequence, Set, Tuple
27
26
 
28
27
  import grpc
29
28
  from cryptography.exceptions import UnsupportedAlgorithm
@@ -39,7 +38,6 @@ from flwr.common.constant import (
39
38
  MISSING_EXTRA_REST,
40
39
  TRANSPORT_TYPE_GRPC_RERE,
41
40
  TRANSPORT_TYPE_REST,
42
- TRANSPORT_TYPE_VCE,
43
41
  )
44
42
  from flwr.common.exit_handlers import register_exit_handlers
45
43
  from flwr.common.logger import log, warn_deprecated_feature
@@ -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
- args.ssl_keyfile,
361
- args.ssl_certfile,
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
 
@@ -456,8 +445,8 @@ def _try_setup_client_authentication(
456
445
  if certificates is None:
457
446
  sys.exit(
458
447
  "Authentication requires secure connections. "
459
- "Please provide certificate paths using '--certificates' and "
460
- "try again."
448
+ "Please provide certificate paths to `--ssl-certfile`, "
449
+ "`--ssl-keyfile`, and `—-ssl-ca-certfile` and try again."
461
450
  )
462
451
 
463
452
  client_keys_file_path = Path(args.auth_list_public_keys)
@@ -526,21 +515,52 @@ def _try_obtain_certificates(
526
515
  # Obtain certificates
527
516
  if args.insecure:
528
517
  log(WARN, "Option `--insecure` was set. Starting insecure HTTP server.")
529
- certificates = None
518
+ return None
530
519
  # Check if certificates are provided
531
- elif args.certificates:
532
- certificates = (
533
- Path(args.certificates[0]).read_bytes(), # CA certificate
534
- Path(args.certificates[1]).read_bytes(), # server certificate
535
- Path(args.certificates[2]).read_bytes(), # server private key
536
- )
537
- else:
538
- sys.exit(
539
- "Certificates are required unless running in insecure mode. "
540
- "Please provide certificate paths with '--certificates' or run the server "
541
- "in insecure mode using '--insecure' if you understand the risks."
542
- )
543
- return certificates
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
+ )
544
564
 
545
565
 
546
566
  def _run_fleet_api_grpc_rere(
@@ -569,29 +589,6 @@ def _run_fleet_api_grpc_rere(
569
589
  return fleet_grpc_server
570
590
 
571
591
 
572
- # pylint: disable=too-many-arguments
573
- def _run_fleet_api_vce(
574
- num_supernodes: int,
575
- client_app_attr: str,
576
- backend_name: str,
577
- backend_config_json_stream: str,
578
- app_dir: str,
579
- state_factory: StateFactory,
580
- f_stop: asyncio.Event,
581
- ) -> None:
582
- log(INFO, "Flower VCE: Starting Fleet API (VirtualClientEngine)")
583
-
584
- start_vce(
585
- num_supernodes=num_supernodes,
586
- client_app_attr=client_app_attr,
587
- backend_name=backend_name,
588
- backend_config_json_stream=backend_config_json_stream,
589
- state_factory=state_factory,
590
- app_dir=app_dir,
591
- f_stop=f_stop,
592
- )
593
-
594
-
595
592
  # pylint: disable=import-outside-toplevel,too-many-arguments
596
593
  def _run_fleet_api_rest(
597
594
  host: str,
@@ -619,14 +616,6 @@ def _run_fleet_api_rest(
619
616
  # See: https://www.starlette.io/applications/#accessing-the-app-instance
620
617
  fast_api_app.state.STATE_FACTORY = state_factory
621
618
 
622
- validation_exceptions = _validate_ssl_files(
623
- ssl_certfile=ssl_certfile, ssl_keyfile=ssl_keyfile
624
- )
625
- if any(validation_exceptions):
626
- # Starting with 3.11 we can use ExceptionGroup but for now
627
- # this seems to be the reasonable approach.
628
- raise ValueError(validation_exceptions)
629
-
630
619
  uvicorn.run(
631
620
  app="flwr.server.superlink.fleet.rest_rere.rest_api:app",
632
621
  port=port,
@@ -639,32 +628,6 @@ def _run_fleet_api_rest(
639
628
  )
640
629
 
641
630
 
642
- def _validate_ssl_files(
643
- ssl_keyfile: Optional[str], ssl_certfile: Optional[str]
644
- ) -> List[ValueError]:
645
- validation_exceptions = []
646
-
647
- if ssl_keyfile is not None and not isfile(ssl_keyfile):
648
- msg = "Path argument `--ssl-keyfile` does not point to a file."
649
- log(ERROR, msg)
650
- validation_exceptions.append(ValueError(msg))
651
-
652
- if ssl_certfile is not None and not isfile(ssl_certfile):
653
- msg = "Path argument `--ssl-certfile` does not point to a file."
654
- log(ERROR, msg)
655
- validation_exceptions.append(ValueError(msg))
656
-
657
- if not bool(ssl_keyfile) == bool(ssl_certfile):
658
- msg = (
659
- "When setting one of `--ssl-keyfile` and "
660
- "`--ssl-certfile`, both have to be used."
661
- )
662
- log(ERROR, msg)
663
- validation_exceptions.append(ValueError(msg))
664
-
665
- return validation_exceptions
666
-
667
-
668
631
  def _parse_args_run_driver_api() -> argparse.ArgumentParser:
669
632
  """Parse command line arguments for Driver API."""
670
633
  parser = argparse.ArgumentParser(
@@ -721,13 +684,23 @@ def _add_args_common(parser: argparse.ArgumentParser) -> None:
721
684
  "Use this flag only if you understand the risks.",
722
685
  )
723
686
  parser.add_argument(
724
- "--certificates",
725
- nargs=3,
726
- metavar=("CA_CERT", "SERVER_CERT", "PRIVATE_KEY"),
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.",
727
703
  type=str,
728
- help="Paths to the CA certificate, server certificate, and server private "
729
- "key, in that order. Note: The server can only be started without "
730
- "certificates by enabling the `--insecure` flag.",
731
704
  )
732
705
  parser.add_argument(
733
706
  "--database",
@@ -783,14 +756,6 @@ def _add_args_fleet_api(parser: argparse.ArgumentParser) -> None:
783
756
  help="Start a Fleet API server (REST, experimental)",
784
757
  )
785
758
 
786
- ex_group.add_argument(
787
- "--vce",
788
- action="store_const",
789
- dest="fleet_api_type",
790
- const=TRANSPORT_TYPE_VCE,
791
- help="Start a Fleet API server (VirtualClientEngine)",
792
- )
793
-
794
759
  # Fleet API gRPC-rere options
795
760
  grpc_rere_group = parser.add_argument_group(
796
761
  "Fleet API (gRPC-rere) server options", ""
@@ -808,54 +773,9 @@ def _add_args_fleet_api(parser: argparse.ArgumentParser) -> None:
808
773
  help="Fleet API (REST) server address (IPv4, IPv6, or a domain name)",
809
774
  default=ADDRESS_FLEET_API_REST,
810
775
  )
811
- rest_group.add_argument(
812
- "--ssl-certfile",
813
- help="Fleet API (REST) server SSL certificate file (as a path str), "
814
- "needed for using 'https'.",
815
- default=None,
816
- )
817
- rest_group.add_argument(
818
- "--ssl-keyfile",
819
- help="Fleet API (REST) server SSL private key file (as a path str), "
820
- "needed for using 'https'.",
821
- default=None,
822
- )
823
776
  rest_group.add_argument(
824
777
  "--rest-fleet-api-workers",
825
778
  help="Set the number of concurrent workers for the Fleet API REST server.",
826
779
  type=int,
827
780
  default=1,
828
781
  )
829
-
830
- # Fleet API VCE options
831
- vce_group = parser.add_argument_group("Fleet API (VCE) server options", "")
832
- vce_group.add_argument(
833
- "--client-app",
834
- help="For example: `client:app` or `project.package.module:wrapper.app`.",
835
- )
836
- vce_group.add_argument(
837
- "--num-supernodes",
838
- type=int,
839
- help="Number of simulated SuperNodes.",
840
- )
841
- vce_group.add_argument(
842
- "--backend",
843
- default="ray",
844
- type=str,
845
- help="Simulation backend that executes the ClientApp.",
846
- )
847
- vce_group.add_argument(
848
- "--backend-config",
849
- type=str,
850
- default='{"client_resources": {"num_cpus":1, "num_gpus":0.0}, "tensorflow": 0}',
851
- help='A JSON formatted stream, e.g \'{"<keyA>":<value>, "<keyB>":<value>}\' to '
852
- "configure a backend. Values supported in <value> are those included by "
853
- "`flwr.common.typing.ConfigsRecordValues`. ",
854
- )
855
- parser.add_argument(
856
- "--app-dir",
857
- default="",
858
- help="Add specified directory to the PYTHONPATH and load"
859
- "ClientApp from there."
860
- " Default: current working directory.",
861
- )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.9.0.dev20240524
3
+ Version: 1.9.0.dev20240528
4
4
  Summary: Flower: A Friendly Federated Learning Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -203,6 +203,7 @@ Other [examples](https://github.com/adap/flower/tree/main/examples):
203
203
  - [Flower through Docker Compose and with Grafana dashboard](https://github.com/adap/flower/tree/main/examples/flower-via-docker-compose)
204
204
  - [Flower with KaplanMeierFitter from the lifelines library](https://github.com/adap/flower/tree/main/examples/federated-kaplan-meier-fitter)
205
205
  - [Sample Level Privacy with Opacus](https://github.com/adap/flower/tree/main/examples/opacus)
206
+ - [Sample Level Privacy with TensorFlow-Privacy](https://github.com/adap/flower/tree/main/examples/tensorflow-privacy)
206
207
 
207
208
  ## Community
208
209
 
@@ -138,7 +138,7 @@ flwr/proto/transport_pb2_grpc.py,sha256=vLN3EHtx2aEEMCO4f1Upu-l27BPzd3-5pV-u8wPc
138
138
  flwr/proto/transport_pb2_grpc.pyi,sha256=AGXf8RiIiW2J5IKMlm_3qT3AzcDa4F3P5IqUjve_esA,766
139
139
  flwr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
140
140
  flwr/server/__init__.py,sha256=PWyHKu-_KFxGI7oFWSWwqMfTiG_phWECT80iv0saouA,1716
141
- flwr/server/app.py,sha256=ckderrJk1OZV2Oz5P-nCrXqGUCfXkXR-yZ_1DG6kcek,29973
141
+ flwr/server/app.py,sha256=aCKA2uYWzkDXrVyeCFvCG_0wGS28NeFXNf1TzOhoJ98,28034
142
142
  flwr/server/client_manager.py,sha256=T8UDSRJBVD3fyIDI7NTAA-NA7GPrMNNgH2OAF54RRxE,6127
143
143
  flwr/server/client_proxy.py,sha256=4G-oTwhb45sfWLx2uZdcXD98IZwdTS6F88xe3akCdUg,2399
144
144
  flwr/server/compat/__init__.py,sha256=VxnJtJyOjNFQXMNi9hIuzNlZM5n0Hj1p3aq_Pm2udw4,892
@@ -225,8 +225,8 @@ flwr/simulation/ray_transport/ray_actor.py,sha256=_wv2eP7qxkCZ-6rMyYWnjLrGPBZRxj
225
225
  flwr/simulation/ray_transport/ray_client_proxy.py,sha256=oDu4sEPIOu39vrNi-fqDAe10xtNUXMO49bM2RWfRcyw,6738
226
226
  flwr/simulation/ray_transport/utils.py,sha256=TYdtfg1P9VfTdLMOJlifInGpxWHYs9UfUqIv2wfkRLA,2392
227
227
  flwr/simulation/run_simulation.py,sha256=Jmc6DyN5UCY1U1PcDvL04NgYmEQ6ufJ1JisjG5yqfY8,15098
228
- flwr_nightly-1.9.0.dev20240524.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
229
- flwr_nightly-1.9.0.dev20240524.dist-info/METADATA,sha256=yuQ2S3IZH1eXBgK0nSrx0Bc7c4kwg71paLb--bFviO8,15398
230
- flwr_nightly-1.9.0.dev20240524.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
231
- flwr_nightly-1.9.0.dev20240524.dist-info/entry_points.txt,sha256=8JJPfpqMnXz9c5V_FSt07Xwd-wCWbAO3MFUDXQ5ZGsI,378
232
- flwr_nightly-1.9.0.dev20240524.dist-info/RECORD,,
228
+ flwr_nightly-1.9.0.dev20240528.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
229
+ flwr_nightly-1.9.0.dev20240528.dist-info/METADATA,sha256=zMRjpVo9OYc_ljbOlUDqTXIY4fKhwgfT0ScUBXV2Jnw,15517
230
+ flwr_nightly-1.9.0.dev20240528.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
231
+ flwr_nightly-1.9.0.dev20240528.dist-info/entry_points.txt,sha256=8JJPfpqMnXz9c5V_FSt07Xwd-wCWbAO3MFUDXQ5ZGsI,378
232
+ flwr_nightly-1.9.0.dev20240528.dist-info/RECORD,,