hatchet-sdk 1.16.2__py3-none-any.whl → 1.16.3__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 hatchet-sdk might be problematic. Click here for more details.

@@ -33,5 +33,9 @@ def tenacity_should_retry(ex: BaseException) -> bool:
33
33
  return ex.code() not in [
34
34
  grpc.StatusCode.UNIMPLEMENTED,
35
35
  grpc.StatusCode.NOT_FOUND,
36
+ grpc.StatusCode.INVALID_ARGUMENT,
37
+ grpc.StatusCode.ALREADY_EXISTS,
38
+ grpc.StatusCode.UNAUTHENTICATED,
39
+ grpc.StatusCode.PERMISSION_DENIED,
36
40
  ]
37
41
  return False
hatchet_sdk/config.py CHANGED
@@ -83,6 +83,7 @@ class ClientConfig(BaseSettings):
83
83
  enable_thread_pool_monitoring: bool = False
84
84
 
85
85
  terminate_worker_after_num_tasks: int | None = None
86
+ disable_log_capture: bool = False
86
87
 
87
88
  @model_validator(mode="after")
88
89
  def validate_token_and_tenant(self) -> "ClientConfig":
@@ -371,6 +371,42 @@ class Context:
371
371
 
372
372
 
373
373
  class DurableContext(Context):
374
+ def __init__(
375
+ self,
376
+ action: Action,
377
+ dispatcher_client: DispatcherClient,
378
+ admin_client: AdminClient,
379
+ event_client: EventClient,
380
+ durable_event_listener: DurableEventListener | None,
381
+ worker: WorkerContext,
382
+ runs_client: RunsClient,
383
+ lifespan_context: Any | None,
384
+ log_sender: AsyncLogSender,
385
+ ):
386
+ super().__init__(
387
+ action,
388
+ dispatcher_client,
389
+ admin_client,
390
+ event_client,
391
+ durable_event_listener,
392
+ worker,
393
+ runs_client,
394
+ lifespan_context,
395
+ log_sender,
396
+ )
397
+
398
+ self._wait_index = 0
399
+
400
+ @property
401
+ def wait_index(self) -> int:
402
+ return self._wait_index
403
+
404
+ def _increment_wait_index(self) -> int:
405
+ index = self._wait_index
406
+ self._wait_index += 1
407
+
408
+ return index
409
+
374
410
  async def aio_wait_for(
375
411
  self,
376
412
  signal_key: str,
@@ -411,6 +447,9 @@ class DurableContext(Context):
411
447
  For more complicated conditions, use `ctx.aio_wait_for` directly.
412
448
  """
413
449
 
450
+ wait_index = self._increment_wait_index()
451
+
414
452
  return await self.aio_wait_for(
415
- f"sleep:{timedelta_to_expr(duration)}", SleepCondition(duration=duration)
453
+ f"sleep:{timedelta_to_expr(duration)}-{wait_index}",
454
+ SleepCondition(duration=duration),
416
455
  )
@@ -60,11 +60,14 @@ class WorkerActionRunLoopManager:
60
60
  self.start_loop_manager_task = self.loop.create_task(self.aio_start())
61
61
 
62
62
  async def aio_start(self, retry_count: int = 1) -> None:
63
- await capture_logs(
64
- self.client.log_interceptor,
65
- self.log_sender,
66
- self._async_start,
67
- )()
63
+ if self.client.config.disable_log_capture:
64
+ await self._async_start()
65
+ else:
66
+ await capture_logs(
67
+ self.client.log_interceptor,
68
+ self.log_sender,
69
+ self._async_start,
70
+ )()
68
71
 
69
72
  async def _async_start(self) -> None:
70
73
  logger.info("starting runner...")
@@ -122,7 +122,17 @@ def capture_logs(
122
122
  async def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
123
123
  log_stream = StringIO()
124
124
  custom_handler = CustomLogHandler(log_sender, log_stream)
125
- custom_handler.setLevel(logging.INFO)
125
+ custom_handler.setLevel(logger.level)
126
+
127
+ if logger.handlers:
128
+ for handler in logger.handlers:
129
+ if handler.formatter:
130
+ custom_handler.setFormatter(handler.formatter)
131
+ break
132
+
133
+ for handler in logger.handlers:
134
+ for filter_obj in handler.filters:
135
+ custom_handler.addFilter(filter_obj)
126
136
 
127
137
  if not any(h for h in logger.handlers if isinstance(h, CustomLogHandler)):
128
138
  logger.addHandler(custom_handler)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hatchet-sdk
3
- Version: 1.16.2
3
+ Version: 1.16.3
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Alexander Belanger
@@ -236,13 +236,13 @@ hatchet_sdk/clients/rest/models/workflow_version_definition.py,sha256=e18BUh1XO0
236
236
  hatchet_sdk/clients/rest/models/workflow_version_meta.py,sha256=TW4R7bAuYAg_LraN-8psdZqp2E8wH9hYyL5Sji86aLk,3791
237
237
  hatchet_sdk/clients/rest/models/workflow_workers_count.py,sha256=qhzqfvjjIDyARkiiLGluMIqEmqO-diHTsjlu0Doi0yg,2875
238
238
  hatchet_sdk/clients/rest/rest.py,sha256=zZHTzgl-NBdcK6XhG23m_s9RKRONGPPItzGe407s7GA,9262
239
- hatchet_sdk/clients/rest/tenacity_utils.py,sha256=i-j75qvPpU2zYqiOGN2x-2_Gjx6LXksPP4fvwGNuf8M,1029
239
+ hatchet_sdk/clients/rest/tenacity_utils.py,sha256=WeNt_1ah2-NKB9qTI3JnTjItpSviBV95U0cPM4kB5as,1211
240
240
  hatchet_sdk/clients/v1/api_client.py,sha256=vUaQr7Xi71a2kFHkZy-pB3tCg3-t0ROlqbPUQA6skIA,2013
241
241
  hatchet_sdk/conditions.py,sha256=CnhpkXgVXM3wc0kAX8KZQA6tp8NFAbdzAN2xFbw7Hb0,4522
242
- hatchet_sdk/config.py,sha256=DKOSCyOhFMx9d3Rvu5z9aImbOgZgwdNSg3XVzyVHn3g,5185
242
+ hatchet_sdk/config.py,sha256=KrlQY7G0oWOIZkyQ48oW_gGVfeoPnGfr0zoRzsvsDpk,5223
243
243
  hatchet_sdk/connection.py,sha256=oRxLs_lBRgHfE4jGLZJimr25ymlEJnK1ZXlh-CasjPo,2696
244
244
  hatchet_sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
245
- hatchet_sdk/context/context.py,sha256=6Qqxt5XljoEz2Jo4scbBeTDaWMNNIKnIcPP-swtxe44,14390
245
+ hatchet_sdk/context/context.py,sha256=NZzFLu1hOZqsZNGSF8T_LrZOMfFDX-2DIyNMtZXs2ck,15359
246
246
  hatchet_sdk/context/worker_context.py,sha256=3lGkOYmDixeuSmqxXbsYav2gErcjP8cDa2m0t0iomjI,884
247
247
  hatchet_sdk/contracts/dispatcher_pb2.py,sha256=W9aGh-wctZhLjUXUdeQTxH4qArsw6D0kIAWM9SVCX5o,14786
248
248
  hatchet_sdk/contracts/dispatcher_pb2.pyi,sha256=9Qoz88G-btdlTuxvk4knqfnYdcIXy3oR9DTh6MwIdP4,18923
@@ -518,12 +518,12 @@ hatchet_sdk/v0/workflow.py,sha256=txhAZC0ohjhRrviIKn1yCR-ybqoQJ4jCrTc7vIkfO3g,93
518
518
  hatchet_sdk/v0/workflow_run.py,sha256=jsEZprXshrSV7i_TtL5uoCL03D18zQ3NeJCq7mp97Dg,1752
519
519
  hatchet_sdk/worker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
520
520
  hatchet_sdk/worker/action_listener_process.py,sha256=CzXen-7tFG_rryvM2xWV2_KMUFC2-i_Ts643TB_Urd8,12878
521
- hatchet_sdk/worker/runner/run_loop_manager.py,sha256=GeILClNXaDbsjXCQb0bBdgeyAwZGem2JdaH0t6wz__I,4053
521
+ hatchet_sdk/worker/runner/run_loop_manager.py,sha256=BcdfxSvZdrxbeTZSUASwCTMKJe6pwLorHVKPTprkM2k,4176
522
522
  hatchet_sdk/worker/runner/runner.py,sha256=L5J_dbwpz2P0rbDzpxW1udByQJHii28KEvzx-1LxB_8,22406
523
- hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=4n3iDhuxSMD18A8h6NlaxCMdIJ7Upy7CdqwOQOW08LU,4029
523
+ hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=FBEcPTi6cxFsGPER51k-xeMUzVJhLIAq7NyKTHCM5-E,4386
524
524
  hatchet_sdk/worker/worker.py,sha256=9EiESMMcS7voa4cAnmnHMx4rC-pqaTmP74bcTbFPqfQ,16435
525
525
  hatchet_sdk/workflow_run.py,sha256=KcylcqRwKADtnzOTjoiVr1vdr7qTZFtDeD5aRS6A4Y8,2823
526
- hatchet_sdk-1.16.2.dist-info/METADATA,sha256=A7zCOAign8t1cgVoxKENGtlU02zv8GfSx8jqiJ6hygI,3636
527
- hatchet_sdk-1.16.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
528
- hatchet_sdk-1.16.2.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
529
- hatchet_sdk-1.16.2.dist-info/RECORD,,
526
+ hatchet_sdk-1.16.3.dist-info/METADATA,sha256=lIngkLTlNoiS2dAMwdaqLKTHe21uUaeccfobZvc51V0,3636
527
+ hatchet_sdk-1.16.3.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
528
+ hatchet_sdk-1.16.3.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
529
+ hatchet_sdk-1.16.3.dist-info/RECORD,,