flwr-nightly 1.10.0.dev20240619__py3-none-any.whl → 1.10.0.dev20240620__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.

Files changed (86) hide show
  1. flwr/cli/app.py +3 -0
  2. flwr/cli/build.py +3 -7
  3. flwr/cli/new/new.py +1 -1
  4. flwr/cli/run/run.py +8 -1
  5. flwr/client/client_app.py +1 -1
  6. flwr/client/dpfedavg_numpy_client.py +1 -1
  7. flwr/client/grpc_rere_client/__init__.py +1 -1
  8. flwr/client/grpc_rere_client/connection.py +1 -1
  9. flwr/client/message_handler/__init__.py +1 -1
  10. flwr/client/message_handler/message_handler.py +1 -1
  11. flwr/client/mod/__init__.py +1 -1
  12. flwr/client/mod/secure_aggregation/__init__.py +1 -1
  13. flwr/client/mod/utils.py +1 -1
  14. flwr/client/rest_client/__init__.py +1 -1
  15. flwr/client/rest_client/connection.py +1 -1
  16. flwr/client/supernode/app.py +1 -1
  17. flwr/common/address.py +1 -1
  18. flwr/common/config.py +8 -6
  19. flwr/common/constant.py +1 -1
  20. flwr/common/date.py +1 -1
  21. flwr/common/dp.py +1 -1
  22. flwr/common/grpc.py +1 -1
  23. flwr/common/secure_aggregation/__init__.py +1 -1
  24. flwr/common/secure_aggregation/crypto/__init__.py +1 -1
  25. flwr/common/secure_aggregation/crypto/shamir.py +1 -1
  26. flwr/common/secure_aggregation/crypto/symmetric_encryption.py +1 -1
  27. flwr/common/secure_aggregation/ndarrays_arithmetic.py +1 -1
  28. flwr/common/secure_aggregation/quantization.py +1 -1
  29. flwr/common/secure_aggregation/secaggplus_constants.py +1 -1
  30. flwr/common/secure_aggregation/secaggplus_utils.py +1 -1
  31. flwr/common/version.py +14 -0
  32. flwr/server/compat/app.py +1 -1
  33. flwr/server/compat/app_utils.py +1 -1
  34. flwr/server/compat/driver_client_proxy.py +1 -1
  35. flwr/server/driver/driver.py +6 -0
  36. flwr/server/driver/grpc_driver.py +85 -63
  37. flwr/server/driver/inmemory_driver.py +28 -26
  38. flwr/server/run_serverapp.py +12 -7
  39. flwr/server/strategy/bulyan.py +1 -1
  40. flwr/server/strategy/dpfedavg_adaptive.py +1 -1
  41. flwr/server/strategy/dpfedavg_fixed.py +1 -1
  42. flwr/server/strategy/fedadagrad.py +1 -1
  43. flwr/server/strategy/fedadam.py +1 -1
  44. flwr/server/strategy/fedavg_android.py +1 -1
  45. flwr/server/strategy/fedavgm.py +1 -1
  46. flwr/server/strategy/fedmedian.py +1 -1
  47. flwr/server/strategy/fedopt.py +1 -1
  48. flwr/server/strategy/fedprox.py +1 -1
  49. flwr/server/strategy/fedxgb_bagging.py +1 -1
  50. flwr/server/strategy/fedxgb_cyclic.py +1 -1
  51. flwr/server/strategy/fedxgb_nn_avg.py +1 -1
  52. flwr/server/strategy/fedyogi.py +1 -1
  53. flwr/server/strategy/krum.py +1 -1
  54. flwr/server/strategy/qfedavg.py +1 -1
  55. flwr/server/superlink/driver/__init__.py +1 -1
  56. flwr/server/superlink/driver/driver_grpc.py +1 -1
  57. flwr/server/superlink/driver/driver_servicer.py +15 -3
  58. flwr/server/superlink/fleet/__init__.py +1 -1
  59. flwr/server/superlink/fleet/grpc_bidi/__init__.py +1 -1
  60. flwr/server/superlink/fleet/grpc_bidi/flower_service_servicer.py +1 -1
  61. flwr/server/superlink/fleet/grpc_bidi/grpc_bridge.py +1 -1
  62. flwr/server/superlink/fleet/grpc_bidi/grpc_client_proxy.py +1 -1
  63. flwr/server/superlink/fleet/grpc_bidi/grpc_server.py +1 -1
  64. flwr/server/superlink/fleet/grpc_rere/__init__.py +1 -1
  65. flwr/server/superlink/fleet/grpc_rere/fleet_servicer.py +1 -1
  66. flwr/server/superlink/fleet/message_handler/__init__.py +1 -1
  67. flwr/server/superlink/fleet/message_handler/message_handler.py +1 -1
  68. flwr/server/superlink/fleet/rest_rere/__init__.py +1 -1
  69. flwr/server/superlink/fleet/rest_rere/rest_api.py +1 -1
  70. flwr/server/superlink/state/__init__.py +1 -1
  71. flwr/server/superlink/state/in_memory_state.py +1 -1
  72. flwr/server/superlink/state/sqlite_state.py +1 -1
  73. flwr/server/superlink/state/state.py +1 -1
  74. flwr/server/superlink/state/state_factory.py +11 -2
  75. flwr/server/utils/__init__.py +1 -1
  76. flwr/server/utils/tensorboard.py +1 -1
  77. flwr/simulation/__init__.py +1 -1
  78. flwr/simulation/app.py +1 -1
  79. flwr/simulation/ray_transport/__init__.py +1 -1
  80. flwr/simulation/ray_transport/ray_client_proxy.py +1 -1
  81. flwr/simulation/run_simulation.py +15 -8
  82. {flwr_nightly-1.10.0.dev20240619.dist-info → flwr_nightly-1.10.0.dev20240620.dist-info}/METADATA +2 -1
  83. {flwr_nightly-1.10.0.dev20240619.dist-info → flwr_nightly-1.10.0.dev20240620.dist-info}/RECORD +86 -86
  84. {flwr_nightly-1.10.0.dev20240619.dist-info → flwr_nightly-1.10.0.dev20240620.dist-info}/LICENSE +0 -0
  85. {flwr_nightly-1.10.0.dev20240619.dist-info → flwr_nightly-1.10.0.dev20240620.dist-info}/WHEEL +0 -0
  86. {flwr_nightly-1.10.0.dev20240619.dist-info → flwr_nightly-1.10.0.dev20240620.dist-info}/entry_points.txt +0 -0
@@ -17,11 +17,12 @@
17
17
 
18
18
  import time
19
19
  import warnings
20
- from typing import Iterable, List, Optional
20
+ from typing import Iterable, List, Optional, cast
21
21
  from uuid import UUID
22
22
 
23
23
  from flwr.common import DEFAULT_TTL, Message, Metadata, RecordSet
24
24
  from flwr.common.serde import message_from_taskres, message_to_taskins
25
+ from flwr.common.typing import Run
25
26
  from flwr.proto.node_pb2 import Node # pylint: disable=E0611
26
27
  from flwr.server.superlink.state import StateFactory
27
28
 
@@ -33,30 +34,27 @@ class InMemoryDriver(Driver):
33
34
 
34
35
  Parameters
35
36
  ----------
37
+ run_id : int
38
+ The identifier of the run.
36
39
  state_factory : StateFactory
37
40
  A StateFactory embedding a state that this driver can interface with.
38
- fab_id : str (default: None)
39
- The identifier of the FAB used in the run.
40
- fab_version : str (default: None)
41
- The version of the FAB used in the run.
42
41
  """
43
42
 
44
43
  def __init__(
45
44
  self,
45
+ run_id: int,
46
46
  state_factory: StateFactory,
47
- fab_id: Optional[str] = None,
48
- fab_version: Optional[str] = None,
49
47
  ) -> None:
50
- self.run_id: Optional[int] = None
51
- self.fab_id = fab_id if fab_id is not None else ""
52
- self.fab_version = fab_version if fab_version is not None else ""
53
- self.node = Node(node_id=0, anonymous=True)
48
+ self._run_id = run_id
49
+ self._run: Optional[Run] = None
54
50
  self.state = state_factory.state()
51
+ self.node = Node(node_id=0, anonymous=True)
55
52
 
56
53
  def _check_message(self, message: Message) -> None:
54
+ self._init_run()
57
55
  # Check if the message is valid
58
56
  if not (
59
- message.metadata.run_id == self.run_id
57
+ message.metadata.run_id == cast(Run, self._run).run_id
60
58
  and message.metadata.src_node_id == self.node.node_id
61
59
  and message.metadata.message_id == ""
62
60
  and message.metadata.reply_to_message == ""
@@ -64,16 +62,20 @@ class InMemoryDriver(Driver):
64
62
  ):
65
63
  raise ValueError(f"Invalid message: {message}")
66
64
 
67
- def _get_run_id(self) -> int:
68
- """Return run_id.
69
-
70
- If unset, create a new run.
71
- """
72
- if self.run_id is None:
73
- self.run_id = self.state.create_run(
74
- fab_id=self.fab_id, fab_version=self.fab_version
75
- )
76
- return self.run_id
65
+ def _init_run(self) -> None:
66
+ """Initialize the run."""
67
+ if self._run is not None:
68
+ return
69
+ run = self.state.get_run(self._run_id)
70
+ if run is None:
71
+ raise RuntimeError(f"Cannot find the run with ID: {self._run_id}")
72
+ self._run = run
73
+
74
+ @property
75
+ def run(self) -> Run:
76
+ """Run ID."""
77
+ self._init_run()
78
+ return Run(**vars(cast(Run, self._run)))
77
79
 
78
80
  def create_message( # pylint: disable=too-many-arguments
79
81
  self,
@@ -88,7 +90,7 @@ class InMemoryDriver(Driver):
88
90
  This method constructs a new `Message` with given content and metadata.
89
91
  The `run_id` and `src_node_id` will be set automatically.
90
92
  """
91
- run_id = self._get_run_id()
93
+ self._init_run()
92
94
  if ttl:
93
95
  warnings.warn(
94
96
  "A custom TTL was set, but note that the SuperLink does not enforce "
@@ -99,7 +101,7 @@ class InMemoryDriver(Driver):
99
101
  ttl_ = DEFAULT_TTL if ttl is None else ttl
100
102
 
101
103
  metadata = Metadata(
102
- run_id=run_id,
104
+ run_id=cast(Run, self._run).run_id,
103
105
  message_id="", # Will be set by the server
104
106
  src_node_id=self.node.node_id,
105
107
  dst_node_id=dst_node_id,
@@ -112,8 +114,8 @@ class InMemoryDriver(Driver):
112
114
 
113
115
  def get_node_ids(self) -> List[int]:
114
116
  """Get node IDs."""
115
- run_id = self._get_run_id()
116
- return list(self.state.get_nodes(run_id))
117
+ self._init_run()
118
+ return list(self.state.get_nodes(cast(Run, self._run).run_id))
117
119
 
118
120
  def push_messages(self, messages: Iterable[Message]) -> Iterable[str]:
119
121
  """Push messages to specified node IDs.
@@ -24,8 +24,10 @@ from typing import Optional
24
24
  from flwr.common import Context, EventType, RecordSet, event
25
25
  from flwr.common.logger import log, update_console_handler, warn_deprecated_feature
26
26
  from flwr.common.object_ref import load_app
27
+ from flwr.proto.driver_pb2 import CreateRunRequest # pylint: disable=E0611
27
28
 
28
- from .driver import Driver, GrpcDriver
29
+ from .driver import Driver
30
+ from .driver.grpc_driver import GrpcDriver, GrpcDriverStub
29
31
  from .server_app import LoadServerAppError, ServerApp
30
32
 
31
33
  ADDRESS_DRIVER_API = "0.0.0.0:9091"
@@ -149,13 +151,16 @@ def run_server_app() -> None:
149
151
  server_app_dir = args.dir
150
152
  server_app_attr = getattr(args, "server-app")
151
153
 
152
- # Initialize GrpcDriver
153
- driver = GrpcDriver(
154
- driver_service_address=args.superlink,
155
- root_certificates=root_certificates,
156
- fab_id=args.fab_id,
157
- fab_version=args.fab_version,
154
+ # Create run
155
+ stub = GrpcDriverStub(
156
+ driver_service_address=args.superlink, root_certificates=root_certificates
158
157
  )
158
+ stub.connect()
159
+ req = CreateRunRequest(fab_id=args.fab_id, fab_version=args.fab_version)
160
+ res = stub.create_run(req)
161
+
162
+ # Initialize GrpcDriver
163
+ driver = GrpcDriver(run_id=res.run_id, stub=stub)
159
164
 
160
165
  # Run the ServerApp with the Driver
161
166
  run(driver=driver, server_app_dir=server_app_dir, server_app_attr=server_app_attr)
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -35,7 +35,11 @@ from flwr.proto.driver_pb2 import ( # pylint: disable=E0611
35
35
  PushTaskInsResponse,
36
36
  )
37
37
  from flwr.proto.node_pb2 import Node # pylint: disable=E0611
38
- from flwr.proto.run_pb2 import GetRunRequest, GetRunResponse # pylint: disable=E0611
38
+ from flwr.proto.run_pb2 import ( # pylint: disable=E0611
39
+ GetRunRequest,
40
+ GetRunResponse,
41
+ Run,
42
+ )
39
43
  from flwr.proto.task_pb2 import TaskRes # pylint: disable=E0611
40
44
  from flwr.server.superlink.state import State, StateFactory
41
45
  from flwr.server.utils.validator import validate_task_ins_or_res
@@ -134,7 +138,15 @@ class DriverServicer(driver_pb2_grpc.DriverServicer):
134
138
  self, request: GetRunRequest, context: grpc.ServicerContext
135
139
  ) -> GetRunResponse:
136
140
  """Get run information."""
137
- raise NotImplementedError
141
+ log(DEBUG, "DriverServicer.GetRun")
142
+
143
+ # Init state
144
+ state: State = self.state_factory.state()
145
+
146
+ # Retrieve run information
147
+ run = state.get_run(request.run_id)
148
+ run_proto = None if run is None else Run(**vars(run))
149
+ return GetRunResponse(run=run_proto)
138
150
 
139
151
 
140
152
  def _raise_if(validation_error: bool, detail: str) -> None:
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2024 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -26,7 +26,16 @@ from .state import State
26
26
 
27
27
 
28
28
  class StateFactory:
29
- """Factory class that creates State instances."""
29
+ """Factory class that creates State instances.
30
+
31
+ Parameters
32
+ ----------
33
+ database : str
34
+ A string representing the path to the database file that will be opened.
35
+ Note that passing ':memory:' will open a connection to a database that is
36
+ in RAM, instead of on disk. For more information on special in-memory
37
+ databases, please refer to https://sqlite.org/inmemorydb.html.
38
+ """
30
39
 
31
40
  def __init__(self, database: str) -> None:
32
41
  self.database = database
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
flwr/simulation/app.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2020 Flower Labs GmbH. All Rights Reserved.
1
+ # Copyright 2021 Flower Labs GmbH. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ from typing import Dict, Optional
27
27
  from flwr.client import ClientApp
28
28
  from flwr.common import EventType, event, log
29
29
  from flwr.common.logger import set_logger_propagation, update_console_handler
30
- from flwr.common.typing import ConfigsRecordValues
30
+ from flwr.common.typing import ConfigsRecordValues, Run
31
31
  from flwr.server.driver import Driver, InMemoryDriver
32
32
  from flwr.server.run_serverapp import run
33
33
  from flwr.server.server_app import ServerApp
@@ -169,11 +169,14 @@ def run_serverapp_th(
169
169
  return serverapp_th
170
170
 
171
171
 
172
- def _init_run_id(driver: InMemoryDriver, state: StateFactory, run_id: int) -> None:
173
- """Create a run with a given `run_id`."""
172
+ def _override_run_id(state: StateFactory, run_id_to_replace: int, run_id: int) -> None:
173
+ """Override the run_id of an existing Run."""
174
174
  log(DEBUG, "Pre-registering run with id %s", run_id)
175
- state.state().run_ids[run_id] = ("", "") # type: ignore
176
- driver.run_id = run_id
175
+ # Remove run
176
+ run_info: Run = state.state().run_ids.pop(run_id_to_replace) # type: ignore
177
+ # Update with new run_id and insert back in state
178
+ run_info.run_id = run_id
179
+ state.state().run_ids[run_id] = run_info # type: ignore
177
180
 
178
181
 
179
182
  # pylint: disable=too-many-locals
@@ -201,11 +204,15 @@ def _main_loop(
201
204
  f_stop = asyncio.Event()
202
205
  serverapp_th = None
203
206
  try:
204
- # Initialize Driver
205
- driver = InMemoryDriver(state_factory)
207
+ # Create run (with empty fab_id and fab_version)
208
+ run_id_ = state_factory.state().create_run("", "")
206
209
 
207
210
  if run_id:
208
- _init_run_id(driver, state_factory, run_id)
211
+ _override_run_id(state_factory, run_id_to_replace=run_id_, run_id=run_id)
212
+ run_id_ = run_id
213
+
214
+ # Initialize Driver
215
+ driver = InMemoryDriver(run_id=run_id_, state_factory=state_factory)
209
216
 
210
217
  # Get and run ServerApp thread
211
218
  serverapp_th = run_serverapp_th(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.10.0.dev20240619
3
+ Version: 1.10.0.dev20240620
4
4
  Summary: Flower: A Friendly Federated Learning Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -204,6 +204,7 @@ Other [examples](https://github.com/adap/flower/tree/main/examples):
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
206
  - [Sample Level Privacy with TensorFlow-Privacy](https://github.com/adap/flower/tree/main/examples/tensorflow-privacy)
207
+ - [Flower with a Tabular Dataset] (https://github.com/adap/flower/tree/main/examples/fl-tabular)
207
208
 
208
209
  ## Community
209
210