flwr-nightly 1.6.0.dev20231030__py3-none-any.whl → 1.6.0.dev20231101__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- flwr/common/retry_invoker.py +17 -16
- {flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/METADATA +1 -1
- {flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/RECORD +6 -6
- {flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/LICENSE +0 -0
- {flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/entry_points.txt +0 -0
flwr/common/retry_invoker.py
CHANGED
@@ -107,7 +107,7 @@ class RetryInvoker:
|
|
107
107
|
|
108
108
|
Parameters
|
109
109
|
----------
|
110
|
-
|
110
|
+
wait_factory: Callable[[], Generator[float, None, None]]
|
111
111
|
A generator yielding successive wait times in seconds. If the generator
|
112
112
|
is finite, the giveup event will be triggered when the generator raises
|
113
113
|
`StopIteration`.
|
@@ -129,11 +129,11 @@ class RetryInvoker:
|
|
129
129
|
data class object detailing the invocation.
|
130
130
|
on_giveup: Optional[Callable[[RetryState], None]] (default: None)
|
131
131
|
A callable to be executed in the event that `max_tries` or `max_time` is
|
132
|
-
exceeded, `should_giveup` returns True, or `
|
132
|
+
exceeded, `should_giveup` returns True, or `wait_factory()` generator raises
|
133
133
|
`StopInteration`. The parameter is a data class object detailing the
|
134
134
|
invocation.
|
135
135
|
jitter: Optional[Callable[[float], float]] (default: full_jitter)
|
136
|
-
A function of the value yielded by `
|
136
|
+
A function of the value yielded by `wait_factory()` returning the actual time
|
137
137
|
to wait. This function helps distribute wait times stochastically to avoid
|
138
138
|
timing collisions across concurrent clients. Wait times are jittered by
|
139
139
|
default using the `full_jitter` function. To disable jittering, pass
|
@@ -145,20 +145,20 @@ class RetryInvoker:
|
|
145
145
|
|
146
146
|
Examples
|
147
147
|
--------
|
148
|
-
Initialize a `RetryInvoker` with exponential backoff and
|
148
|
+
Initialize a `RetryInvoker` with exponential backoff and invoke a function:
|
149
149
|
|
150
150
|
>>> invoker = RetryInvoker(
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
151
|
+
... exponential, # Or use `lambda: exponential(3, 2)` to pass arguments
|
152
|
+
... grpc.RpcError,
|
153
|
+
... max_tries=3,
|
154
|
+
... max_time=None,
|
155
|
+
... )
|
156
156
|
>>> invoker.invoke(my_func, arg1, arg2, kw1=kwarg1)
|
157
157
|
"""
|
158
158
|
|
159
159
|
def __init__(
|
160
160
|
self,
|
161
|
-
|
161
|
+
wait_factory: Callable[[], Generator[float, None, None]],
|
162
162
|
recoverable_exceptions: Union[Type[Exception], Tuple[Type[Exception], ...]],
|
163
163
|
max_tries: Optional[int],
|
164
164
|
max_time: Optional[float],
|
@@ -169,7 +169,7 @@ class RetryInvoker:
|
|
169
169
|
jitter: Optional[Callable[[float], float]] = full_jitter,
|
170
170
|
should_giveup: Optional[Callable[[Exception], bool]] = None,
|
171
171
|
) -> None:
|
172
|
-
self.
|
172
|
+
self.wait_factory = wait_factory
|
173
173
|
self.recoverable_exceptions = recoverable_exceptions
|
174
174
|
self.max_tries = max_tries
|
175
175
|
self.max_time = max_time
|
@@ -183,8 +183,8 @@ class RetryInvoker:
|
|
183
183
|
def invoke(
|
184
184
|
self,
|
185
185
|
target: Callable[..., Any],
|
186
|
-
*args:
|
187
|
-
**kwargs:
|
186
|
+
*args: Any,
|
187
|
+
**kwargs: Any,
|
188
188
|
) -> Any:
|
189
189
|
"""Safely invoke the provided callable with retry mechanisms.
|
190
190
|
|
@@ -212,12 +212,12 @@ class RetryInvoker:
|
|
212
212
|
------
|
213
213
|
Exception
|
214
214
|
If the number of tries exceeds `max_tries`, if the total time
|
215
|
-
exceeds `max_time`, if `
|
215
|
+
exceeds `max_time`, if `wait_factory()` generator raises `StopInteration`,
|
216
216
|
or if the `should_giveup` returns True for a raised exception.
|
217
217
|
|
218
218
|
Notes
|
219
219
|
-----
|
220
|
-
The time between retries is determined by the provided `
|
220
|
+
The time between retries is determined by the provided `wait_factory()`
|
221
221
|
generator and can optionally be jittered using the `jitter` function.
|
222
222
|
The recoverable exceptions that trigger a retry, as well as conditions to
|
223
223
|
stop retries, are also determined by the class's initialization parameters.
|
@@ -230,6 +230,7 @@ class RetryInvoker:
|
|
230
230
|
handler(cast(RetryState, ref_state[0]))
|
231
231
|
|
232
232
|
try_cnt = 0
|
233
|
+
wait_generator = self.wait_factory()
|
233
234
|
start = time.time()
|
234
235
|
ref_state: List[Optional[RetryState]] = [None]
|
235
236
|
|
@@ -265,7 +266,7 @@ class RetryInvoker:
|
|
265
266
|
raise
|
266
267
|
|
267
268
|
try:
|
268
|
-
wait_time = next(
|
269
|
+
wait_time = next(wait_generator)
|
269
270
|
if self.jitter is not None:
|
270
271
|
wait_time = self.jitter(wait_time)
|
271
272
|
if self.max_time is not None:
|
{flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/RECORD
RENAMED
@@ -26,7 +26,7 @@ flwr/common/dp.py,sha256=hF45cPElXxcQsh4AoquAyaTrNi0xCrIcKx7xOcV_1XU,1782
|
|
26
26
|
flwr/common/grpc.py,sha256=JmFrGeEqFjMKkf6Mn6NlMJdjk27pYHzsn7CquAfR4R0,1896
|
27
27
|
flwr/common/logger.py,sha256=Plgdf5NULsv9leDeNOXTeCqK-7LkZh8R34RPT4EkOs8,3466
|
28
28
|
flwr/common/parameter.py,sha256=-bFAUayToYDF50FZGrBC1hQYJCQDtB2bbr3ZuVLMtdE,2095
|
29
|
-
flwr/common/retry_invoker.py,sha256=
|
29
|
+
flwr/common/retry_invoker.py,sha256=RBTiDnYyePWvhBH9GqcWZl0tQaUOVUqOVBwfGprXWEg,10810
|
30
30
|
flwr/common/secure_aggregation/__init__.py,sha256=29nHIUO2L8-KhNHQ2KmIgRo_4CPkq4LgLCUN0on5FgI,731
|
31
31
|
flwr/common/secure_aggregation/crypto/__init__.py,sha256=dz7pVx2aPrHxr_AwgO5mIiTzu4PcvUxRq9NLBbFcsf8,738
|
32
32
|
flwr/common/secure_aggregation/crypto/shamir.py,sha256=yY35ZgHlB4YyGW_buG-1X-0M-ejXuQzISgYLgC_Z9TY,2792
|
@@ -122,8 +122,8 @@ flwr/simulation/ray_transport/__init__.py,sha256=FsaAnzC4cw4DqoouBCix6496k29jACk
|
|
122
122
|
flwr/simulation/ray_transport/ray_actor.py,sha256=EiyXPRnur8pOzGu_h5ZU4t8C5M_amnVPAQWyPSbAnEU,16564
|
123
123
|
flwr/simulation/ray_transport/ray_client_proxy.py,sha256=cPo3Ny1k5arqTLHD0bB5DSEuS66aE2SwEumtr8TzOGc,8778
|
124
124
|
flwr/simulation/ray_transport/utils.py,sha256=MVOH4l1ZPt64WidgBBay--1M3lS82CQ3ebmwU9Cvlo0,3369
|
125
|
-
flwr_nightly-1.6.0.
|
126
|
-
flwr_nightly-1.6.0.
|
127
|
-
flwr_nightly-1.6.0.
|
128
|
-
flwr_nightly-1.6.0.
|
129
|
-
flwr_nightly-1.6.0.
|
125
|
+
flwr_nightly-1.6.0.dev20231101.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
126
|
+
flwr_nightly-1.6.0.dev20231101.dist-info/METADATA,sha256=R2keD6GeJ359rUi7o0nVXaiIXrzkPfaZs71po_Ul96g,13241
|
127
|
+
flwr_nightly-1.6.0.dev20231101.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
128
|
+
flwr_nightly-1.6.0.dev20231101.dist-info/entry_points.txt,sha256=1uLlD5tIunkzALMfMWnqjdE_D5hRUX_I1iMmOMv6tZI,181
|
129
|
+
flwr_nightly-1.6.0.dev20231101.dist-info/RECORD,,
|
{flwr_nightly-1.6.0.dev20231030.dist-info → flwr_nightly-1.6.0.dev20231101.dist-info}/LICENSE
RENAMED
File without changes
|
File without changes
|
File without changes
|