hatchet-sdk 1.16.2__py3-none-any.whl → 1.16.4__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 +2 -0
- hatchet_sdk/connection.py +6 -1
- hatchet_sdk/context/context.py +40 -1
- hatchet_sdk/runnables/types.py +2 -2
- hatchet_sdk/worker/runner/run_loop_manager.py +8 -5
- hatchet_sdk/worker/runner/utils/capture_logs.py +11 -1
- {hatchet_sdk-1.16.2.dist-info → hatchet_sdk-1.16.4.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.16.2.dist-info → hatchet_sdk-1.16.4.dist-info}/RECORD +11 -11
- {hatchet_sdk-1.16.2.dist-info → hatchet_sdk-1.16.4.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.16.2.dist-info → hatchet_sdk-1.16.4.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,8 @@ 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
|
|
87
|
+
grpc_enable_fork_support: bool = False
|
|
86
88
|
|
|
87
89
|
@model_validator(mode="after")
|
|
88
90
|
def validate_token_and_tenant(self) -> "ClientConfig":
|
hatchet_sdk/connection.py
CHANGED
|
@@ -60,7 +60,12 @@ def new_conn(config: ClientConfig, aio: bool) -> grpc.Channel | grpc.aio.Channel
|
|
|
60
60
|
|
|
61
61
|
# Set environment variable to disable fork support. Reference: https://github.com/grpc/grpc/issues/28557
|
|
62
62
|
# When steps execute via os.fork, we see `TSI_DATA_CORRUPTED` errors.
|
|
63
|
-
|
|
63
|
+
# needs to be the string "True" or "False"
|
|
64
|
+
os.environ["GRPC_ENABLE_FORK_SUPPORT"] = str(config.grpc_enable_fork_support)
|
|
65
|
+
|
|
66
|
+
if config.grpc_enable_fork_support:
|
|
67
|
+
# See discussion: https://github.com/hatchet-dev/hatchet/pull/2057#discussion_r2243233357
|
|
68
|
+
os.environ["GRPC_POLL_STRATEGY"] = "poll"
|
|
64
69
|
|
|
65
70
|
if config.tls_config.strategy == "none":
|
|
66
71
|
conn = start.insecure_channel(
|
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
|
)
|
hatchet_sdk/runnables/types.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
|
-
from collections.abc import Callable
|
|
3
|
+
from collections.abc import Callable, Mapping
|
|
4
4
|
from enum import Enum
|
|
5
5
|
from typing import Any, ParamSpec, TypeGuard, TypeVar
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ from hatchet_sdk.contracts.v1.workflows_pb2 import DefaultFilter as DefaultFilte
|
|
|
12
12
|
from hatchet_sdk.utils.timedelta_to_expression import Duration
|
|
13
13
|
from hatchet_sdk.utils.typing import AwaitableLike, JSONSerializableMapping
|
|
14
14
|
|
|
15
|
-
ValidTaskReturnType = BaseModel |
|
|
15
|
+
ValidTaskReturnType = BaseModel | Mapping[str, Any] | None
|
|
16
16
|
|
|
17
17
|
R = TypeVar("R", bound=ValidTaskReturnType)
|
|
18
18
|
P = ParamSpec("P")
|
|
@@ -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=
|
|
243
|
-
hatchet_sdk/connection.py,sha256=
|
|
242
|
+
hatchet_sdk/config.py,sha256=9yXDCBfVW5AHosiSRWiEScSFSsm7Lx7wi0urNLC11Ck,5266
|
|
243
|
+
hatchet_sdk/connection.py,sha256=XCBY9-UxaN3blakgZ59AhDpjb1ilLOOlmNNM6QaDtMM,2961
|
|
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
|
|
@@ -284,7 +284,7 @@ hatchet_sdk/rate_limit.py,sha256=TwbCuggiZaWpYuo4mjVLlE-z1OfQ2mRBiVvCSaG3lv4,391
|
|
|
284
284
|
hatchet_sdk/runnables/action.py,sha256=zrVHpyzIQ9XZgWwY69b_6uhZd53An4trRoLd9b3os5E,4384
|
|
285
285
|
hatchet_sdk/runnables/contextvars.py,sha256=jHrrewUlFPAT9f2u3VCsuSlDBtBoagEUtUzJOSmm4yk,1118
|
|
286
286
|
hatchet_sdk/runnables/task.py,sha256=-5AeToJqIbpgGeyrol5VJaFGND4l_UY8k9VIhrUBXaw,12796
|
|
287
|
-
hatchet_sdk/runnables/types.py,sha256=
|
|
287
|
+
hatchet_sdk/runnables/types.py,sha256=M23xSMTBPl12CXCCXZ0wbnqZ_sePB6CJKtOdipiNDlg,4362
|
|
288
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
|
|
@@ -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.4.dist-info/METADATA,sha256=COvbSNkoetUrfskndrS4s3PJ8MsNs4-36OjEuUeOOGc,3636
|
|
527
|
+
hatchet_sdk-1.16.4.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
528
|
+
hatchet_sdk-1.16.4.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
|
|
529
|
+
hatchet_sdk-1.16.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|