modAL 1.2.3.dev15__py3-none-any.whl → 1.2.3.dev16__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.
@@ -271,15 +271,13 @@ def process_exception_before_retry(
271
271
  fn_name: str,
272
272
  n_retries: int,
273
273
  delay: float,
274
- total_deadline: Optional[float],
275
274
  idempotency_key: str,
276
275
  ):
277
276
  """Process exception before retry, used by `_retry_transient_errors`."""
278
277
  with suppress_tb_frames(1):
279
278
  if final_attempt:
280
279
  logger.debug(
281
- f"Final attempt failed with {repr(exc)} {n_retries=} {delay=} "
282
- f"{total_deadline=} for {fn_name} ({idempotency_key[:8]})"
280
+ f"Final attempt failed with {repr(exc)} {n_retries=} {delay=} for {fn_name} ({idempotency_key[:8]})"
283
281
  )
284
282
  if isinstance(exc, OSError):
285
283
  raise ConnectionError(str(exc))
@@ -358,6 +356,7 @@ async def _retry_transient_errors(
358
356
  timeout = min(timeouts) # In case the function provided both types of timeouts
359
357
  else:
360
358
  timeout = None
359
+
361
360
  try:
362
361
  with suppress_tb_frames(1):
363
362
  return await fn_callable(req, metadata=attempt_metadata, timeout=timeout)
@@ -366,21 +365,29 @@ async def _retry_transient_errors(
366
365
  # in grpclib<=0.4.7. See above (search for `write_appdata`).
367
366
 
368
367
  # Server side instruction for retries
369
- if isinstance(exc, GRPCError) and (server_retry_policy := get_server_retry_policy(exc)):
368
+ max_throttle_wait: Optional[int] = config.get("max_throttle_wait")
369
+ if (
370
+ max_throttle_wait != 0
371
+ and isinstance(exc, GRPCError)
372
+ and (server_retry_policy := get_server_retry_policy(exc))
373
+ ):
370
374
  server_delay = server_retry_policy.retry_after_secs
371
375
 
372
- # When `total_deadline` is not defined and server gives instruction for retries, then use
373
- # `max_throttle_wait`.
374
- if total_deadline is None and (max_throttle_wait := config.get("max_throttle_wait")):
375
- total_deadline = t0 + max_throttle_wait
376
+ now = time.time()
376
377
 
377
- final_attempt = (
378
- total_deadline is not None
379
- and time.time() + server_delay + retry.attempt_timeout_floor >= total_deadline
378
+ # We check if the timeout will be reached **after** the sleep, so we can raise an error early
379
+ # without needing to actually sleep.
380
+ total_timeout_will_be_reached = (
381
+ retry.total_timeout is not None and (now + server_delay - t0) >= retry.total_timeout
382
+ )
383
+ max_throttle_will_be_reached = (
384
+ max_throttle_wait is not None and (now + server_delay - t0) >= max_throttle_wait
380
385
  )
386
+ final_attempt = total_timeout_will_be_reached or max_throttle_will_be_reached
387
+
381
388
  with suppress_tb_frames(1):
382
389
  process_exception_before_retry(
383
- exc, final_attempt, fn.name, n_retries, server_delay, total_deadline, idempotency_key
390
+ exc, final_attempt, fn.name, n_retries, server_delay, idempotency_key
384
391
  )
385
392
 
386
393
  now = time.time()
@@ -411,9 +418,7 @@ async def _retry_transient_errors(
411
418
  final_attempt = False
412
419
 
413
420
  with suppress_tb_frames(1):
414
- process_exception_before_retry(
415
- exc, final_attempt, fn.name, n_retries, delay, total_deadline, idempotency_key
416
- )
421
+ process_exception_before_retry(exc, final_attempt, fn.name, n_retries, delay, idempotency_key)
417
422
 
418
423
  n_retries += 1
419
424
 
modal/client.pyi CHANGED
@@ -32,7 +32,7 @@ class _Client:
32
32
  server_url: str,
33
33
  client_type: int,
34
34
  credentials: typing.Optional[tuple[str, str]],
35
- version: str = "1.2.3.dev15",
35
+ version: str = "1.2.3.dev16",
36
36
  ):
37
37
  """mdmd:hidden
38
38
  The Modal client object is not intended to be instantiated directly by users.
@@ -163,7 +163,7 @@ class Client:
163
163
  server_url: str,
164
164
  client_type: int,
165
165
  credentials: typing.Optional[tuple[str, str]],
166
- version: str = "1.2.3.dev15",
166
+ version: str = "1.2.3.dev16",
167
167
  ):
168
168
  """mdmd:hidden
169
169
  The Modal client object is not intended to be instantiated directly by users.
modal/config.py CHANGED
@@ -221,13 +221,6 @@ def _enforce_suffix_rules(x: str) -> str:
221
221
  return x
222
222
 
223
223
 
224
- def _int_or_none(x: str) -> Optional[int]:
225
- if not x:
226
- return None
227
- x_int = int(x)
228
- return x_int if x_int > 0 else None
229
-
230
-
231
224
  class _Setting(typing.NamedTuple):
232
225
  default: typing.Any = None
233
226
  transform: typing.Callable[[str], typing.Any] = lambda x: x # noqa: E731
@@ -269,7 +262,7 @@ _SETTINGS = {
269
262
  transform=lambda s: _check_value(["pickle", "cbor"])(s.lower()),
270
263
  ),
271
264
  "dev_suffix": _Setting("", transform=_enforce_suffix_rules),
272
- "max_throttle_wait": _Setting(None, transform=_int_or_none),
265
+ "max_throttle_wait": _Setting(None, transform=lambda x: int(x) if x else None),
273
266
  }
274
267
 
275
268
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: modal
3
- Version: 1.2.3.dev15
3
+ Version: 1.2.3.dev16
4
4
  Summary: Python client library for Modal
5
5
  Author-email: Modal Labs <support@modal.com>
6
6
  License: Apache-2.0
@@ -26,12 +26,12 @@ modal/app.pyi,sha256=nI_Tibj-rI5I7dJFJnczbHvcmVzCvvCih0tMzoQlr_Y,50835
26
26
  modal/billing.py,sha256=zmQ3bcCJlwa4KD1IA_QgdWpm1pn13c-7qfy79iEauYI,195
27
27
  modal/call_graph.py,sha256=1g2DGcMIJvRy-xKicuf63IVE98gJSnQsr8R_NVMptNc,2581
28
28
  modal/client.py,sha256=k1CqQ_0t4-vHylkqYZgYCnClg-FT0QrTPAKivL01A_k,14354
29
- modal/client.pyi,sha256=zMiMyLkDECv-um8xP_nXTYekpY0J2oED0ErIY7lDdso,13148
29
+ modal/client.pyi,sha256=aZlrkkekFOI4eHfHtEjrFyctSVzw38l47F3Paa3n28c,13148
30
30
  modal/cloud_bucket_mount.py,sha256=cvVj5Rt4nDHoQbTneoJPTaAcnl_Ab_mrsjnnzd0v9OI,6013
31
31
  modal/cloud_bucket_mount.pyi,sha256=vXusGMOUk9HjCs4lhxteuCK4xLQclPfugGWKo7LECEA,7539
32
32
  modal/cls.py,sha256=4T__mtYlQUnkatif1Wnr8Ld9DN_ySydHj2UwhRg89ok,41984
33
33
  modal/cls.pyi,sha256=p8Unbfr0yUdAzYYnD7erSRO7dH-87HkAg4oAn6srBzA,27424
34
- modal/config.py,sha256=gmL1zcJlyhX_hKE1Xm_86KysXfTUiutVSASxXgHFztQ,13534
34
+ modal/config.py,sha256=byOUVfUibX9Ixrhbz5z4HDcgn-8S5OFicD6xGUErqZs,13415
35
35
  modal/container_process.py,sha256=KG2ZkFOWe2KN1b8dFSBLBoW5pWoRxBzJ20MLhDTicJs,16749
36
36
  modal/container_process.pyi,sha256=xMKr-VbQsydS8AbhAys9UTpHHnH2QRyINpPtPG7NwmI,8373
37
37
  modal/dict.py,sha256=Omfmj3fUyg7ijTI33Z97geyK7MW8T31LRm-N7pZqSwU,21582
@@ -104,7 +104,7 @@ modal/_utils/docker_utils.py,sha256=h1uETghR40mp_y3fSWuZAfbIASH1HMzuphJHghAL6DU,
104
104
  modal/_utils/function_utils.py,sha256=wL2AA8aEftxCBATPStHgKDRPxrFjPAv-rHt0Wb7y9Ts,28629
105
105
  modal/_utils/git_utils.py,sha256=qtUU6JAttF55ZxYq51y55OR58B0tDPZsZWK5dJe6W5g,3182
106
106
  modal/_utils/grpc_testing.py,sha256=H1zHqthv19eGPJz2HKXDyWXWGSqO4BRsxah3L5Xaa8A,8619
107
- modal/_utils/grpc_utils.py,sha256=1jmpMRuShYdnqmCLUfQt5bO9KFioAjVmkjjEBhyz_18,16263
107
+ modal/_utils/grpc_utils.py,sha256=kGYfkZNoYzaDCeeDxL8Z1oMRcGRMBpLS40B2tYUAnS8,16417
108
108
  modal/_utils/hash_utils.py,sha256=zg3J6OGxTFGSFri1qQ12giDz90lWk8bzaxCTUCRtiX4,3034
109
109
  modal/_utils/http_utils.py,sha256=yeTFsXYr0rYMEhB7vBP7audG9Uc7OLhzKBANFDZWVt0,2451
110
110
  modal/_utils/jwt_utils.py,sha256=fxH9plyrbAemTbjSsQtzIdDXE9QXxvMC4DiUZ16G0aA,1360
@@ -158,7 +158,7 @@ modal/experimental/__init__.py,sha256=sCwNbBLcR2t-jhrpwtMAPGKt2WNqXBg0xkNZdyB-6C
158
158
  modal/experimental/flash.py,sha256=RKS3X3h4tY_mOLcMzbRs5tNCLPFL01dBAhCZSqCeBgA,26675
159
159
  modal/experimental/flash.pyi,sha256=uwinKAYxpunNNfBj58FP88DXb535Qik4F6tnJKPAIwQ,14696
160
160
  modal/experimental/ipython.py,sha256=TrCfmol9LGsRZMeDoeMPx3Hv3BFqQhYnmD_iH0pqdhk,2904
161
- modal-1.2.3.dev15.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
161
+ modal-1.2.3.dev16.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
162
162
  modal_docs/__init__.py,sha256=svYKtV8HDwDCN86zbdWqyq5T8sMdGDj0PVlzc2tIxDM,28
163
163
  modal_docs/gen_cli_docs.py,sha256=c1yfBS_x--gL5bs0N4ihMwqwX8l3IBWSkBAKNNIi6bQ,3801
164
164
  modal_docs/gen_reference_docs.py,sha256=d_CQUGQ0rfw28u75I2mov9AlS773z9rG40-yq5o7g2U,6359
@@ -186,10 +186,10 @@ modal_proto/task_command_router_pb2.py,sha256=_pD2ZpU0bNzhwBdzmLoLyLtAtftI_Agxwn
186
186
  modal_proto/task_command_router_pb2.pyi,sha256=EyDgXPLr7alqjXYERV8w_MPuO404x0uCppmSkrfE9IE,14589
187
187
  modal_proto/task_command_router_pb2_grpc.py,sha256=uEQ0HdrCp8v-9bB5yIic9muA8spCShLHY6Bz9cCgOUE,10114
188
188
  modal_proto/task_command_router_pb2_grpc.pyi,sha256=s3Yxsrawdj4nr8vqQqsAxyX6ilWaGbdECy425KKbLIA,3301
189
- modal_version/__init__.py,sha256=zYqIo07pfBOafxOQqy2ixFUKAuoev-A5xeuVBgFXN_Y,121
189
+ modal_version/__init__.py,sha256=W4GhojSH5h6GCtV3WlNQg5YXcoazI5vU-5Vy9Qsx6ko,121
190
190
  modal_version/__main__.py,sha256=2FO0yYQQwDTh6udt1h-cBnGd1c4ZyHnHSI4BksxzVac,105
191
- modal-1.2.3.dev15.dist-info/METADATA,sha256=gKLHENGMQmHESi0ICzHHU5JB8fqE__EaiGy5x1oRi48,2490
192
- modal-1.2.3.dev15.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
193
- modal-1.2.3.dev15.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
194
- modal-1.2.3.dev15.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
195
- modal-1.2.3.dev15.dist-info/RECORD,,
191
+ modal-1.2.3.dev16.dist-info/METADATA,sha256=ZsNb5qRrYwKAuduKDY5MN2iECZ93D5vnvXxDijyGyG8,2490
192
+ modal-1.2.3.dev16.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
193
+ modal-1.2.3.dev16.dist-info/entry_points.txt,sha256=An-wYgeEUnm6xzrAP9_NTSTSciYvvEWsMZILtYrvpAI,46
194
+ modal-1.2.3.dev16.dist-info/top_level.txt,sha256=4BWzoKYREKUZ5iyPzZpjqx4G8uB5TWxXPDwibLcVa7k,43
195
+ modal-1.2.3.dev16.dist-info/RECORD,,
modal_version/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # Copyright Modal Labs 2025
2
2
  """Supplies the current version of the modal client library."""
3
3
 
4
- __version__ = "1.2.3.dev15"
4
+ __version__ = "1.2.3.dev16"