flwr-nightly 1.21.0.dev20250731__py3-none-any.whl → 1.21.0.dev20250801__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.
@@ -40,7 +40,7 @@ from flwr.common.secure_aggregation.crypto.symmetric_encryption import (
40
40
  generate_key_pairs,
41
41
  )
42
42
  from flwr.common.serde import message_from_proto, message_to_proto, run_from_proto
43
- from flwr.common.typing import Fab, Run, RunNotRunningException
43
+ from flwr.common.typing import Fab, Run
44
44
  from flwr.proto.fab_pb2 import GetFabRequest, GetFabResponse # pylint: disable=E0611
45
45
  from flwr.proto.fleet_pb2 import ( # pylint: disable=E0611
46
46
  CreateNodeRequest,
@@ -157,17 +157,6 @@ def grpc_request_response( # pylint: disable=R0913,R0914,R0915,R0917
157
157
  stub = adapter_cls(channel)
158
158
  node: Optional[Node] = None
159
159
 
160
- def _should_giveup_fn(e: Exception) -> bool:
161
- if e.code() == grpc.StatusCode.PERMISSION_DENIED: # type: ignore
162
- raise RunNotRunningException
163
- if e.code() == grpc.StatusCode.UNAVAILABLE: # type: ignore
164
- return False
165
- return True
166
-
167
- # Restrict retries to cases where the status code is UNAVAILABLE
168
- # If the status code is PERMISSION_DENIED, additionally raise RunNotRunningException
169
- retry_invoker.should_giveup = _should_giveup_fn
170
-
171
160
  # Wrap stub
172
161
  _wrap_stub(stub, retry_invoker)
173
162
  ###########################################################################
@@ -176,6 +176,9 @@ def http_request_response( # pylint: disable=R0913,R0914,R0915,R0917
176
176
  # Shared variables for inner functions
177
177
  node: Optional[Node] = None
178
178
 
179
+ # Remove should_giveup from RetryInvoker as REST does not support gRPC status codes
180
+ retry_invoker.should_giveup = None
181
+
179
182
  ###########################################################################
180
183
  # heartbeat/create_node/delete_node/receive/send/get_run functions
181
184
  ###########################################################################
flwr/common/args.py CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  import argparse
19
19
  import sys
20
- from logging import DEBUG, ERROR, WARN
20
+ from logging import DEBUG, ERROR, INFO, WARN
21
21
  from os.path import isfile
22
22
  from pathlib import Path
23
23
  from typing import Optional, Union
@@ -72,11 +72,7 @@ def try_obtain_root_certificates(
72
72
  else:
73
73
  # Load the certificates if provided, or load the system certificates
74
74
  if root_cert_path is None:
75
- log(
76
- WARN,
77
- "Both `--insecure` and `--root-certificates` were not set. "
78
- "Using system certificates.",
79
- )
75
+ log(INFO, "Using system certificates")
80
76
  root_certificates = None
81
77
  elif not isfile(root_cert_path):
82
78
  log(ERROR, "Path argument `--root-certificates` does not point to a file.")
@@ -17,6 +17,7 @@
17
17
 
18
18
  import itertools
19
19
  import random
20
+ import threading
20
21
  import time
21
22
  from collections.abc import Generator, Iterable
22
23
  from dataclasses import dataclass
@@ -319,8 +320,12 @@ class RetryInvoker:
319
320
 
320
321
  def _make_simple_grpc_retry_invoker() -> RetryInvoker:
321
322
  """Create a simple gRPC retry invoker."""
323
+ lock = threading.Lock()
324
+ system_healthy = threading.Event()
325
+ system_healthy.set() # Initially, the connection is healthy
322
326
 
323
- def _on_sucess(retry_state: RetryState) -> None:
327
+ def _on_success(retry_state: RetryState) -> None:
328
+ system_healthy.set()
324
329
  if retry_state.tries > 1:
325
330
  log(
326
331
  INFO,
@@ -329,17 +334,11 @@ def _make_simple_grpc_retry_invoker() -> RetryInvoker:
329
334
  retry_state.tries,
330
335
  )
331
336
 
332
- def _on_backoff(retry_state: RetryState) -> None:
333
- if retry_state.tries == 1:
334
- log(WARN, "Connection attempt failed, retrying...")
335
- else:
336
- log(
337
- WARN,
338
- "Connection attempt failed, retrying in %.2f seconds",
339
- retry_state.actual_wait,
340
- )
337
+ def _on_backoff(_: RetryState) -> None:
338
+ system_healthy.clear()
341
339
 
342
340
  def _on_giveup(retry_state: RetryState) -> None:
341
+ system_healthy.clear()
343
342
  if retry_state.tries > 1:
344
343
  log(
345
344
  WARN,
@@ -355,15 +354,35 @@ def _make_simple_grpc_retry_invoker() -> RetryInvoker:
355
354
  return False
356
355
  return True
357
356
 
357
+ def _wait(wait_time: float) -> None:
358
+ # Use a lock to prevent multiple gRPC calls from retrying concurrently,
359
+ # which is unnecessary since they are all likely to fail.
360
+ with lock:
361
+ # Log the wait time
362
+ log(
363
+ WARN,
364
+ "Connection attempt failed, retrying in %.2f seconds",
365
+ wait_time,
366
+ )
367
+
368
+ start = time.monotonic()
369
+ # Avoid sequential waits if the system is healthy
370
+ system_healthy.wait(wait_time)
371
+
372
+ remaining_time = wait_time - (time.monotonic() - start)
373
+ if remaining_time > 0:
374
+ time.sleep(remaining_time)
375
+
358
376
  return RetryInvoker(
359
377
  wait_gen_factory=lambda: exponential(max_delay=MAX_RETRY_DELAY),
360
378
  recoverable_exceptions=grpc.RpcError,
361
379
  max_tries=None,
362
380
  max_time=None,
363
- on_success=_on_sucess,
381
+ on_success=_on_success,
364
382
  on_backoff=_on_backoff,
365
383
  on_giveup=_on_giveup,
366
384
  should_giveup=_should_giveup_fn,
385
+ wait_function=_wait,
367
386
  )
368
387
 
369
388
 
@@ -21,7 +21,7 @@ import time
21
21
  from collections.abc import Iterator
22
22
  from contextlib import contextmanager
23
23
  from functools import partial
24
- from logging import INFO, WARN
24
+ from logging import INFO
25
25
  from pathlib import Path
26
26
  from typing import Callable, Optional, Union, cast
27
27
 
@@ -38,7 +38,6 @@ from flwr.common.constant import (
38
38
  CLIENT_OCTET,
39
39
  CLIENTAPPIO_API_DEFAULT_SERVER_ADDRESS,
40
40
  ISOLATION_MODE_SUBPROCESS,
41
- MAX_RETRY_DELAY,
42
41
  SERVER_OCTET,
43
42
  TRANSPORT_TYPE_GRPC_ADAPTER,
44
43
  TRANSPORT_TYPE_GRPC_RERE,
@@ -54,7 +53,7 @@ from flwr.common.inflatable_utils import (
54
53
  push_object_contents_from_iterable,
55
54
  )
56
55
  from flwr.common.logger import log
57
- from flwr.common.retry_invoker import RetryInvoker, RetryState, exponential
56
+ from flwr.common.retry_invoker import RetryInvoker, _make_simple_grpc_retry_invoker
58
57
  from flwr.common.telemetry import EventType
59
58
  from flwr.common.typing import Fab, Run, RunNotRunningException, UserConfig
60
59
  from flwr.proto.clientappio_pb2_grpc import add_ClientAppIoServicer_to_server
@@ -521,44 +520,14 @@ def _make_fleet_connection_retry_invoker(
521
520
  connection_error_type: type[Exception] = RpcError,
522
521
  ) -> RetryInvoker:
523
522
  """Create a retry invoker for fleet connection."""
524
-
525
- def _on_success(retry_state: RetryState) -> None:
526
- if retry_state.tries > 1:
527
- log(
528
- INFO,
529
- "Connection successful after %.2f seconds and %s tries.",
530
- retry_state.elapsed_time,
531
- retry_state.tries,
532
- )
533
-
534
- def _on_backoff(retry_state: RetryState) -> None:
535
- if retry_state.tries == 1:
536
- log(WARN, "Connection attempt failed, retrying...")
537
- else:
538
- log(
539
- WARN,
540
- "Connection attempt failed, retrying in %.2f seconds",
541
- retry_state.actual_wait,
542
- )
543
-
544
- return RetryInvoker(
545
- wait_gen_factory=lambda: exponential(max_delay=MAX_RETRY_DELAY),
546
- recoverable_exceptions=connection_error_type,
547
- max_tries=max_retries + 1 if max_retries is not None else None,
548
- max_time=max_wait_time,
549
- on_giveup=lambda retry_state: (
550
- log(
551
- WARN,
552
- "Giving up reconnection after %.2f seconds and %s tries.",
553
- retry_state.elapsed_time,
554
- retry_state.tries,
555
- )
556
- if retry_state.tries > 1
557
- else None
558
- ),
559
- on_success=_on_success,
560
- on_backoff=_on_backoff,
561
- )
523
+ retry_invoker = _make_simple_grpc_retry_invoker()
524
+ retry_invoker.recoverable_exceptions = connection_error_type
525
+ if max_retries is not None:
526
+ retry_invoker.max_tries = max_retries + 1
527
+ if max_wait_time is not None:
528
+ retry_invoker.max_time = max_wait_time
529
+
530
+ return retry_invoker
562
531
 
563
532
 
564
533
  def run_clientappio_api_grpc(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: flwr-nightly
3
- Version: 1.21.0.dev20250731
3
+ Version: 1.21.0.dev20250801
4
4
  Summary: Flower: A Friendly Federated AI Framework
5
5
  License: Apache-2.0
6
6
  Keywords: Artificial Intelligence,Federated AI,Federated Analytics,Federated Evaluation,Federated Learning,Flower,Machine Learning
@@ -84,7 +84,7 @@ flwr/client/grpc_adapter_client/__init__.py,sha256=RQWP5mFPROLHKgombiRvPXVWSoVrQ
84
84
  flwr/client/grpc_adapter_client/connection.py,sha256=JGv02EjSOAG1E5BRUD4lwXc1LLiYJ0OhInvp31qx1cU,4404
85
85
  flwr/client/grpc_rere_client/__init__.py,sha256=i7iS0Lt8B7q0E2L72e4F_YrKm6ClRKnd71PNA6PW2O0,752
86
86
  flwr/client/grpc_rere_client/client_interceptor.py,sha256=zFaVHw6AxeNO-7eCKKb-RxrPa7zbM5Z-2-1Efc4adQY,2451
87
- flwr/client/grpc_rere_client/connection.py,sha256=3P7hyu79th3ZtMbBLgGLODuTzwiO4fV6HmtoekNMifE,13521
87
+ flwr/client/grpc_rere_client/connection.py,sha256=uLcXAJoHHLVm4SVR3oFCpdqHrZJcT_kGqfC1g8reXAM,13008
88
88
  flwr/client/grpc_rere_client/grpc_adapter.py,sha256=dLGB5GriszAmtgvuFGuz_F7rIwpzLfDxhJ7T3Un-Ce0,6694
89
89
  flwr/client/message_handler/__init__.py,sha256=0lyljDVqre3WljiZbPcwCCf8GiIaSVI_yo_ylEyPwSE,719
90
90
  flwr/client/message_handler/message_handler.py,sha256=X9SXX6et97Lw9_DGD93HKsEBGNjXClcFgc_5aLK0oiU,6541
@@ -98,13 +98,13 @@ flwr/client/mod/secure_aggregation/secaggplus_mod.py,sha256=aKqjZCrikF73y3E-7h40
98
98
  flwr/client/mod/utils.py,sha256=FUgD2TfcWqSeF6jUKZ4i6Ke56U4Nrv85AeVb93s6R9g,1201
99
99
  flwr/client/numpy_client.py,sha256=Qq6ghsIAop2slKqAfgiI5NiHJ4LIxGmrik3Ror4_XVc,9581
100
100
  flwr/client/rest_client/__init__.py,sha256=MBiuK62hj439m9rtwSwI184Hth6Tt5GbmpNMyl3zkZY,735
101
- flwr/client/rest_client/connection.py,sha256=NsENBljtBCd6ToIVmAhBbVC6kTmtuArxb2LnE6-lIGY,15656
101
+ flwr/client/rest_client/connection.py,sha256=fyiS1aXTv71jWczx7mSco94LYJTBXgTF-p2PnAk3CL8,15784
102
102
  flwr/client/run_info_store.py,sha256=MaJ3UQ-07hWtK67wnWu0zR29jrk0fsfgJX506dvEOfE,4042
103
103
  flwr/client/typing.py,sha256=Jw3rawDzI_-ZDcRmEQcs5gZModY7oeQlEeltYsdOhlU,1048
104
104
  flwr/clientapp/__init__.py,sha256=zGW4z49Ojzoi1hDiRC7kyhLjijUilc6fqHhtM_ATRVA,719
105
105
  flwr/common/__init__.py,sha256=5GCLVk399Az_rTJHNticRlL0Sl_oPw_j5_LuFKfX7-M,4171
106
106
  flwr/common/address.py,sha256=9JucdTwlc-jpeJkRKeUboZoacUtErwSVtnDR9kAtLqE,4119
107
- flwr/common/args.py,sha256=-aX_jVnSaDrJR2KZ8Wq0Y3dQHII4R4MJtJOIXzVUA0c,5417
107
+ flwr/common/args.py,sha256=XFQ5PU0lU7NS1QCiKhhESHVeL8KSjcD3x8h4P3e5qlM,5298
108
108
  flwr/common/auth_plugin/__init__.py,sha256=3rzPkVLn9WyB5n7HLk1XGDw3SLCqRWAU1_CnglcWPfw,970
109
109
  flwr/common/auth_plugin/auth_plugin.py,sha256=kXx5o39vJchaPv28sK9qO6H_UXSWym6zRBbCa7sUwtQ,4825
110
110
  flwr/common/config.py,sha256=glcZDjco-amw1YfQcYTFJ4S1pt9APoexT-mf1QscuHs,13960
@@ -140,7 +140,7 @@ flwr/common/record/metricrecord.py,sha256=KOyJjJbvFV6IwBPbgm92FZ_0_hXpMHuwfCi1rh
140
140
  flwr/common/record/recorddict.py,sha256=p7hBimFpKM1XKUe6OAkR_7pYGzGL_EwUJUvJ8odZEcY,14986
141
141
  flwr/common/record/typeddict.py,sha256=dDKgUThs2BscYUNcgP82KP8-qfAYXYftDrf2LszAC_o,3599
142
142
  flwr/common/recorddict_compat.py,sha256=D5SqXWkqBddn5b6K_5UoH7aZ11UaN3lDTlzvHx3-rqk,14119
143
- flwr/common/retry_invoker.py,sha256=s5IGgRovE19laMetHFePoqIdMBYfz_KdXs-KyfaCrXw,14634
143
+ flwr/common/retry_invoker.py,sha256=uQeDcgoTgmFwhJ0mkDE2eNz2acF9eShaqMOO5boGrPQ,15285
144
144
  flwr/common/secure_aggregation/__init__.py,sha256=MgW6uHGhyFLBAYQqa1Vzs5n2Gc0d4yEw1_NmerFir70,731
145
145
  flwr/common/secure_aggregation/crypto/__init__.py,sha256=5E4q4-Fw0CNz4tLah_QHj7m_rDeM4ucHcFlPWB_Na3Q,738
146
146
  flwr/common/secure_aggregation/crypto/shamir.py,sha256=N8pPa5cEksowNoAqfFm5SP3IuxuVi9GGMa3JOtPniQY,3954
@@ -378,8 +378,8 @@ flwr/supernode/scheduler/simple_clientapp_scheduler_plugin.py,sha256=nnNuKhelrAE
378
378
  flwr/supernode/servicer/__init__.py,sha256=lucTzre5WPK7G1YLCfaqg3rbFWdNSb7ZTt-ca8gxdEo,717
379
379
  flwr/supernode/servicer/clientappio/__init__.py,sha256=7Oy62Y_oijqF7Dxi6tpcUQyOpLc_QpIRZ83NvwmB0Yg,813
380
380
  flwr/supernode/servicer/clientappio/clientappio_servicer.py,sha256=ClPoKco7Tjj_cxRPhZlQSrOvcGa8sJwGs26LUNZnI3Y,10608
381
- flwr/supernode/start_client_internal.py,sha256=VC7rV4QaX5Vk4Lw0DDodhwsKvGiHbr0mqrV0H77h1UI,21999
382
- flwr_nightly-1.21.0.dev20250731.dist-info/METADATA,sha256=ZA8ZpC8q5me0iPeqzlGiEug4ppSypQG9zoe75ICtLvY,15966
383
- flwr_nightly-1.21.0.dev20250731.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
384
- flwr_nightly-1.21.0.dev20250731.dist-info/entry_points.txt,sha256=jNpDXGBGgs21RqUxelF_jwGaxtqFwm-MQyfz-ZqSjrA,367
385
- flwr_nightly-1.21.0.dev20250731.dist-info/RECORD,,
381
+ flwr/supernode/start_client_internal.py,sha256=iqJR8WbCW-8RQIRNwARZYoxhnlaAo5KnluCOEfRoLWM,21020
382
+ flwr_nightly-1.21.0.dev20250801.dist-info/METADATA,sha256=bK5pwB6ZuUZaeFGcYNCDjT0D5q6NgZvI3WVbzjZhjBg,15966
383
+ flwr_nightly-1.21.0.dev20250801.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
384
+ flwr_nightly-1.21.0.dev20250801.dist-info/entry_points.txt,sha256=jNpDXGBGgs21RqUxelF_jwGaxtqFwm-MQyfz-ZqSjrA,367
385
+ flwr_nightly-1.21.0.dev20250801.dist-info/RECORD,,