flwr-nightly 1.10.0.dev20240709__py3-none-any.whl → 1.10.0.dev20240710__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/new/new.py CHANGED
@@ -264,9 +264,11 @@ def new(
264
264
  bold=True,
265
265
  )
266
266
  )
267
+
268
+ _add = " huggingface-cli login\n" if framework_str == "flowertune" else ""
267
269
  print(
268
270
  typer.style(
269
- f" cd {package_name}\n" + " pip install -e .\n flwr run\n",
271
+ f" cd {package_name}\n" + " pip install -e .\n" + _add + " flwr run\n",
270
272
  fg=typer.colors.BRIGHT_CYAN,
271
273
  bold=True,
272
274
  )
@@ -178,7 +178,7 @@ def _get_load_client_app_fn(
178
178
  else:
179
179
  flwr_dir = Path(args.flwr_dir).absolute()
180
180
 
181
- sys.path.insert(0, str(flwr_dir.absolute()))
181
+ inserted_path = None
182
182
 
183
183
  default_app_ref: str = getattr(args, "client-app")
184
184
 
@@ -188,6 +188,11 @@ def _get_load_client_app_fn(
188
188
  "Flower SuperNode will load and validate ClientApp `%s`",
189
189
  getattr(args, "client-app"),
190
190
  )
191
+ # Insert sys.path
192
+ dir_path = Path(args.dir).absolute()
193
+ sys.path.insert(0, str(dir_path))
194
+ inserted_path = str(dir_path)
195
+
191
196
  valid, error_msg = validate(default_app_ref)
192
197
  if not valid and error_msg:
193
198
  raise LoadClientAppError(error_msg) from None
@@ -196,7 +201,7 @@ def _get_load_client_app_fn(
196
201
  # If multi-app feature is disabled
197
202
  if not multi_app:
198
203
  # Get sys path to be inserted
199
- sys_path = Path(args.dir).absolute()
204
+ dir_path = Path(args.dir).absolute()
200
205
 
201
206
  # Set app reference
202
207
  client_app_ref = default_app_ref
@@ -209,7 +214,7 @@ def _get_load_client_app_fn(
209
214
 
210
215
  log(WARN, "FAB ID is not provided; the default ClientApp will be loaded.")
211
216
  # Get sys path to be inserted
212
- sys_path = Path(args.dir).absolute()
217
+ dir_path = Path(args.dir).absolute()
213
218
 
214
219
  # Set app reference
215
220
  client_app_ref = default_app_ref
@@ -222,13 +227,21 @@ def _get_load_client_app_fn(
222
227
  raise LoadClientAppError("Failed to load ClientApp") from e
223
228
 
224
229
  # Get sys path to be inserted
225
- sys_path = Path(project_dir).absolute()
230
+ dir_path = Path(project_dir).absolute()
226
231
 
227
232
  # Set app reference
228
233
  client_app_ref = config["flower"]["components"]["clientapp"]
229
234
 
230
235
  # Set sys.path
231
- sys.path.insert(0, str(sys_path))
236
+ nonlocal inserted_path
237
+ if inserted_path != str(dir_path):
238
+ # Remove the previously inserted path
239
+ if inserted_path is not None:
240
+ sys.path.remove(inserted_path)
241
+ # Insert the new path
242
+ sys.path.insert(0, str(dir_path))
243
+
244
+ inserted_path = str(dir_path)
232
245
 
233
246
  # Load ClientApp
234
247
  log(
@@ -236,7 +249,7 @@ def _get_load_client_app_fn(
236
249
  "Loading ClientApp `%s`",
237
250
  client_app_ref,
238
251
  )
239
- client_app = load_app(client_app_ref, LoadClientAppError, sys_path)
252
+ client_app = load_app(client_app_ref, LoadClientAppError, dir_path)
240
253
 
241
254
  if not isinstance(client_app, ClientApp):
242
255
  raise LoadClientAppError(
@@ -30,7 +30,7 @@ from flwr.common.logger import log
30
30
  from flwr.common.message import Error
31
31
  from flwr.common.object_ref import load_app
32
32
  from flwr.common.serde import message_from_taskins, message_to_taskres
33
- from flwr.proto.task_pb2 import TaskIns # pylint: disable=E0611
33
+ from flwr.proto.task_pb2 import TaskIns, TaskRes # pylint: disable=E0611
34
34
  from flwr.server.superlink.state import StateFactory
35
35
 
36
36
  from .backend import Backend, error_messages_backends, supported_backends
@@ -54,17 +54,16 @@ def _register_nodes(
54
54
  # pylint: disable=too-many-arguments,too-many-locals
55
55
  async def worker(
56
56
  app_fn: Callable[[], ClientApp],
57
- queue: "asyncio.Queue[TaskIns]",
57
+ taskins_queue: "asyncio.Queue[TaskIns]",
58
+ taskres_queue: "asyncio.Queue[TaskRes]",
58
59
  node_states: Dict[int, NodeState],
59
- state_factory: StateFactory,
60
60
  backend: Backend,
61
61
  ) -> None:
62
62
  """Get TaskIns from queue and pass it to an actor in the pool to execute it."""
63
- state = state_factory.state()
64
63
  while True:
65
64
  out_mssg = None
66
65
  try:
67
- task_ins: TaskIns = await queue.get()
66
+ task_ins: TaskIns = await taskins_queue.get()
68
67
  node_id = task_ins.task.consumer.node_id
69
68
 
70
69
  # Register and retrieve runstate
@@ -111,7 +110,7 @@ async def worker(
111
110
  task_res = message_to_taskres(out_mssg)
112
111
  # Store TaskRes in state
113
112
  task_res.task.pushed_at = time.time()
114
- state.store_task_res(task_res)
113
+ await taskres_queue.put(task_res)
115
114
 
116
115
 
117
116
  async def add_taskins_to_queue(
@@ -162,6 +161,21 @@ async def add_taskins_to_queue(
162
161
  log(DEBUG, "Async producer: Stopped pulling from StateFactory.")
163
162
 
164
163
 
164
+ async def put_taskres_into_state(
165
+ queue: "asyncio.Queue[TaskRes]",
166
+ state_factory: StateFactory,
167
+ f_stop: asyncio.Event,
168
+ ) -> None:
169
+ """Remove TaskRes from queue and add into State."""
170
+ state = state_factory.state()
171
+ while not f_stop.is_set():
172
+ if queue.qsize():
173
+ task_res = await queue.get()
174
+ state.store_task_res(task_res)
175
+ else:
176
+ await asyncio.sleep(0.1)
177
+
178
+
165
179
  async def run(
166
180
  app_fn: Callable[[], ClientApp],
167
181
  backend_fn: Callable[[], Backend],
@@ -171,7 +185,8 @@ async def run(
171
185
  f_stop: asyncio.Event,
172
186
  ) -> None:
173
187
  """Run the VCE async."""
174
- queue: "asyncio.Queue[TaskIns]" = asyncio.Queue(128)
188
+ taskins_queue: "asyncio.Queue[TaskIns]" = asyncio.Queue(128)
189
+ taskres_queue: "asyncio.Queue[TaskRes]" = asyncio.Queue(128)
175
190
 
176
191
  try:
177
192
 
@@ -184,22 +199,37 @@ async def run(
184
199
  # Add workers (they submit Messages to Backend)
185
200
  worker_tasks = [
186
201
  asyncio.create_task(
187
- worker(app_fn, queue, node_states, state_factory, backend)
202
+ worker(
203
+ app_fn,
204
+ taskins_queue,
205
+ taskres_queue,
206
+ node_states,
207
+ backend,
208
+ )
188
209
  )
189
210
  for _ in range(backend.num_workers)
190
211
  ]
191
212
  # Create producer (adds TaskIns into Queue)
192
- producer = asyncio.create_task(
213
+ taskins_producer = asyncio.create_task(
193
214
  add_taskins_to_queue(
194
- queue, state_factory, nodes_mapping, backend, worker_tasks, f_stop
215
+ taskins_queue,
216
+ state_factory,
217
+ nodes_mapping,
218
+ backend,
219
+ worker_tasks,
220
+ f_stop,
195
221
  )
196
222
  )
197
223
 
198
- # Wait for producer to finish
199
- # The producer runs forever until f_stop is set or until
224
+ taskres_consumer = asyncio.create_task(
225
+ put_taskres_into_state(taskres_queue, state_factory, f_stop)
226
+ )
227
+
228
+ # Wait for asyncio taks pulling/pushing TaskIns/TaskRes.
229
+ # These run forever until f_stop is set or until
200
230
  # all worker (consumer) coroutines are completed. Workers
201
231
  # also run forever and only end if an exception is raised.
202
- await asyncio.gather(producer)
232
+ await asyncio.gather(*(taskins_producer, taskres_consumer))
203
233
 
204
234
  except Exception as ex:
205
235
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: flwr-nightly
3
- Version: 1.10.0.dev20240709
3
+ Version: 1.10.0.dev20240710
4
4
  Summary: Flower: A Friendly Federated Learning Framework
5
5
  Home-page: https://flower.ai
6
6
  License: Apache-2.0
@@ -6,7 +6,7 @@ flwr/cli/config_utils.py,sha256=ugUlqH52yxTPMtKw6q4xv5k2OVWUy89cwyJ5LB2RLgk,6037
6
6
  flwr/cli/example.py,sha256=1bGDYll3BXQY2kRqSN-oICqS5n1b9m0g0RvXTopXHl4,2215
7
7
  flwr/cli/install.py,sha256=Wz7Hqg2PE9N-w5CnqlH9Zr8mzADN2J7NLcUhgldZLWU,6579
8
8
  flwr/cli/new/__init__.py,sha256=cQzK1WH4JP2awef1t2UQ2xjl1agVEz9rwutV18SWV1k,789
9
- flwr/cli/new/new.py,sha256=ySz3yu-3IF_wencjajr4mA2VNoM6hKZZ5scKYZKzAII,9340
9
+ flwr/cli/new/new.py,sha256=vSLxyWOtD33U8mTGeqOhw5OjeDpFStekAVLUH9GJq6k,9432
10
10
  flwr/cli/new/templates/__init__.py,sha256=4luU8RL-CK8JJCstQ_ON809W9bNTkY1l9zSaPKBkgwY,725
11
11
  flwr/cli/new/templates/app/.gitignore.tpl,sha256=XixnHdyeMB2vwkGtGnwHqoWpH-9WChdyG0GXe57duhc,3078
12
12
  flwr/cli/new/templates/app/README.flowertune.md.tpl,sha256=PqzkGm0g6Zy-vZK9_0EO3f_U6g1r69lGc4UL8kds5Q8,2696
@@ -83,7 +83,7 @@ flwr/client/numpy_client.py,sha256=u76GWAdHmJM88Agm2EgLQSvO8Jnk225mJTk-_TmPjFE,1
83
83
  flwr/client/rest_client/__init__.py,sha256=5KGlp7pjc1dhNRkKlaNtUfQmg8wrRFh9lS3P3uRS-7Q,735
84
84
  flwr/client/rest_client/connection.py,sha256=nowX8_TMnaiIhBMU5f60sIOkvcS3DHOHBT_YrvCnxnw,12096
85
85
  flwr/client/supernode/__init__.py,sha256=SUhWOzcgXRNXk1V9UgB5-FaWukqqrOEajVUHEcPkwyQ,865
86
- flwr/client/supernode/app.py,sha256=WuTp0vt2ILyKHOCl9OUtFfdlUExt-eEUy9SOFVlJAEw,14857
86
+ flwr/client/supernode/app.py,sha256=jVg5vWJnE50jUJPOlK_hwA_RsGo_heygZeWHGsWH76g,15275
87
87
  flwr/client/typing.py,sha256=RJGVF64Z0nqW-qmdFuFaY4Jig3dMUFgNhFi-5dq-8-I,1069
88
88
  flwr/common/__init__.py,sha256=4cBLNNnNTwHDnL_HCxhU5ILCSZ6fYh3A_aMBtlvHTVw,3721
89
89
  flwr/common/address.py,sha256=wRu1Luezx1PWadwV9OA_KNko01oVvbRnPqfzaDn8QOk,1882
@@ -238,7 +238,7 @@ flwr/server/superlink/fleet/vce/__init__.py,sha256=36MHKiefnJeyjwMQzVUK4m06Ojon3
238
238
  flwr/server/superlink/fleet/vce/backend/__init__.py,sha256=oBIzmnrSSRvH_H0vRGEGWhWzQQwqe3zn6e13RsNwlIY,1466
239
239
  flwr/server/superlink/fleet/vce/backend/backend.py,sha256=LJsKl7oixVvptcG98Rd9ejJycNWcEVB0ODvSreLGp-A,2260
240
240
  flwr/server/superlink/fleet/vce/backend/raybackend.py,sha256=dwaebZfzvzlvjkMflH5hJ19-Sszvxt0AWwIEGk9BliU,7495
241
- flwr/server/superlink/fleet/vce/vce_api.py,sha256=skPxli2QKTn-zElEt7lak5Q4N5v8NZB-EeROKac2bAs,12387
241
+ flwr/server/superlink/fleet/vce/vce_api.py,sha256=JvkrLB26-sXbrsQKG4iGwgBYDIfuix3PJ1P6qd_nqxQ,13296
242
242
  flwr/server/superlink/state/__init__.py,sha256=Gj2OTFLXvA-mAjBvwuKDM3rDrVaQPcIoybSa2uskMTE,1003
243
243
  flwr/server/superlink/state/in_memory_state.py,sha256=fb-f4RGiqXON0DC7aSEMNuNIjH406BhBYrNNX5Kza2g,13061
244
244
  flwr/server/superlink/state/sqlite_state.py,sha256=dO374mTkvhWQSiwbqwUXVnAYHev-j2mHaX9v8wFmmMA,29044
@@ -268,8 +268,8 @@ flwr/superexec/deployment.py,sha256=xv5iQWuaMeeL0XE5KMLWq3gRU4lvsGu1-_oPIXi5x9E,
268
268
  flwr/superexec/exec_grpc.py,sha256=u-rztpOleqSGqgvNE-ZLw1HchNsBHU1-eB3m52GZ0pQ,1852
269
269
  flwr/superexec/exec_servicer.py,sha256=4R1f_9v0vly_bXpIYaXAeV1tO5LAy1AYygGGGNZmlQk,2194
270
270
  flwr/superexec/executor.py,sha256=TMQMMf-vv0htlv6v-eEBI67J1WL3Yz7dp_Fm1lgMEyU,1718
271
- flwr_nightly-1.10.0.dev20240709.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
272
- flwr_nightly-1.10.0.dev20240709.dist-info/METADATA,sha256=SwIZJql7j8ya90gfL7UYMaHCGdWj2T7e-vDFYW6rlvs,15614
273
- flwr_nightly-1.10.0.dev20240709.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
274
- flwr_nightly-1.10.0.dev20240709.dist-info/entry_points.txt,sha256=7qBQcA-bDGDxnJmLd9FYqglFQubjCNqyg9M8a-lukps,336
275
- flwr_nightly-1.10.0.dev20240709.dist-info/RECORD,,
271
+ flwr_nightly-1.10.0.dev20240710.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
272
+ flwr_nightly-1.10.0.dev20240710.dist-info/METADATA,sha256=d1HBDVTaENA9E7Peceqo7v7bNogHZJCWA4dKq581OCo,15614
273
+ flwr_nightly-1.10.0.dev20240710.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
274
+ flwr_nightly-1.10.0.dev20240710.dist-info/entry_points.txt,sha256=7qBQcA-bDGDxnJmLd9FYqglFQubjCNqyg9M8a-lukps,336
275
+ flwr_nightly-1.10.0.dev20240710.dist-info/RECORD,,