hatchet-sdk 1.16.1__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.
- hatchet_sdk/clients/rest/tenacity_utils.py +4 -0
- hatchet_sdk/config.py +1 -0
- hatchet_sdk/context/context.py +40 -1
- hatchet_sdk/runnables/workflow.py +4 -0
- hatchet_sdk/worker/runner/run_loop_manager.py +8 -5
- hatchet_sdk/worker/runner/utils/capture_logs.py +11 -1
- {hatchet_sdk-1.16.1.dist-info → hatchet_sdk-1.16.3.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.16.1.dist-info → hatchet_sdk-1.16.3.dist-info}/RECORD +10 -10
- {hatchet_sdk-1.16.1.dist-info → hatchet_sdk-1.16.3.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.16.1.dist-info → hatchet_sdk-1.16.3.dist-info}/entry_points.txt +0 -0
|
@@ -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":
|
hatchet_sdk/context/context.py
CHANGED
|
@@ -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)}",
|
|
453
|
+
f"sleep:{timedelta_to_expr(duration)}-{wait_index}",
|
|
454
|
+
SleepCondition(duration=duration),
|
|
416
455
|
)
|
|
@@ -219,6 +219,10 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
219
219
|
self.config.input_validator.model_validate(ctx.workflow_input),
|
|
220
220
|
)
|
|
221
221
|
|
|
222
|
+
@property
|
|
223
|
+
def input_validator(self) -> type[TWorkflowInput]:
|
|
224
|
+
return cast(type[TWorkflowInput], self.config.input_validator)
|
|
225
|
+
|
|
222
226
|
@property
|
|
223
227
|
def tasks(self) -> list[Task[TWorkflowInput, Any]]:
|
|
224
228
|
tasks = self._default_tasks + self._durable_tasks
|
|
@@ -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
|
-
|
|
64
|
-
self.
|
|
65
|
-
|
|
66
|
-
|
|
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(
|
|
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)
|
|
@@ -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=
|
|
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=
|
|
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=
|
|
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
|
|
@@ -285,7 +285,7 @@ hatchet_sdk/runnables/action.py,sha256=zrVHpyzIQ9XZgWwY69b_6uhZd53An4trRoLd9b3os
|
|
|
285
285
|
hatchet_sdk/runnables/contextvars.py,sha256=jHrrewUlFPAT9f2u3VCsuSlDBtBoagEUtUzJOSmm4yk,1118
|
|
286
286
|
hatchet_sdk/runnables/task.py,sha256=-5AeToJqIbpgGeyrol5VJaFGND4l_UY8k9VIhrUBXaw,12796
|
|
287
287
|
hatchet_sdk/runnables/types.py,sha256=QFayOJ_Oi8tOYI6Sjl9bwjftM96QZh9XIlfFnSNgEXI,4359
|
|
288
|
-
hatchet_sdk/runnables/workflow.py,sha256=
|
|
288
|
+
hatchet_sdk/runnables/workflow.py,sha256=_F5XIeokfQxMgrFtVjdM3ArtCwfKj3u51dinA7ouyWI,57513
|
|
289
289
|
hatchet_sdk/token.py,sha256=KjIiInwG5Kqd_FO4BSW1x_5Uc7PFbnzIVJqr50-ZldE,779
|
|
290
290
|
hatchet_sdk/utils/aio.py,sha256=cu1rD_UZkShtfzi7iXMYwBBaCRdxJQTdUC0_mf8nU2E,499
|
|
291
291
|
hatchet_sdk/utils/backoff.py,sha256=6B5Rb5nLKw_TqqgpJMYjIBV1PTTtbOMRZCveisVhg_I,353
|
|
@@ -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=
|
|
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=
|
|
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.
|
|
527
|
-
hatchet_sdk-1.16.
|
|
528
|
-
hatchet_sdk-1.16.
|
|
529
|
-
hatchet_sdk-1.16.
|
|
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,,
|
|
File without changes
|
|
File without changes
|