hatchet-sdk 1.14.0__py3-none-any.whl → 1.14.1__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/__init__.py CHANGED
@@ -130,6 +130,14 @@ from hatchet_sdk.clients.rest.models.workflow_version_definition import (
130
130
  WorkflowVersionDefinition,
131
131
  )
132
132
  from hatchet_sdk.clients.rest.models.workflow_version_meta import WorkflowVersionMeta
133
+ from hatchet_sdk.conditions import (
134
+ Condition,
135
+ OrGroup,
136
+ ParentCondition,
137
+ SleepCondition,
138
+ UserEventCondition,
139
+ or_,
140
+ )
133
141
  from hatchet_sdk.config import ClientConfig, ClientTLSConfig, OpenTelemetryConfig
134
142
  from hatchet_sdk.context.context import Context, DurableContext
135
143
  from hatchet_sdk.context.worker_context import WorkerContext
@@ -158,14 +166,6 @@ from hatchet_sdk.runnables.types import (
158
166
  )
159
167
  from hatchet_sdk.runnables.workflow import TaskRunRef
160
168
  from hatchet_sdk.utils.opentelemetry import OTelAttribute
161
- from hatchet_sdk.waits import (
162
- Condition,
163
- OrGroup,
164
- ParentCondition,
165
- SleepCondition,
166
- UserEventCondition,
167
- or_,
168
- )
169
169
  from hatchet_sdk.worker.worker import Worker, WorkerStartOptions, WorkerStatus
170
170
  from hatchet_sdk.workflow_run import WorkflowRunRef
171
171
 
@@ -8,6 +8,7 @@ from pydantic import BaseModel, ConfigDict
8
8
 
9
9
  from hatchet_sdk.clients.listeners.pooled_listener import PooledListener
10
10
  from hatchet_sdk.clients.rest.tenacity_utils import tenacity_retry
11
+ from hatchet_sdk.conditions import Condition, SleepCondition, UserEventCondition
11
12
  from hatchet_sdk.config import ClientConfig
12
13
  from hatchet_sdk.connection import new_conn
13
14
  from hatchet_sdk.contracts.v1.dispatcher_pb2 import (
@@ -20,7 +21,6 @@ from hatchet_sdk.contracts.v1.dispatcher_pb2 import (
20
21
  from hatchet_sdk.contracts.v1.dispatcher_pb2_grpc import V1DispatcherStub
21
22
  from hatchet_sdk.contracts.v1.shared.condition_pb2 import DurableEventListenerConditions
22
23
  from hatchet_sdk.metadata import get_metadata
23
- from hatchet_sdk.waits import SleepCondition, UserEventCondition
24
24
 
25
25
  DEFAULT_DURABLE_EVENT_LISTENER_RETRY_INTERVAL = 3 # seconds
26
26
  DEFAULT_DURABLE_EVENT_LISTENER_RETRY_COUNT = 5
@@ -32,7 +32,7 @@ class RegisterDurableEventRequest(BaseModel):
32
32
 
33
33
  task_id: str
34
34
  signal_key: str
35
- conditions: list[SleepCondition | UserEventCondition]
35
+ conditions: list[Condition]
36
36
  config: ClientConfig
37
37
 
38
38
  def to_proto(self) -> RegisterDurableEventRequestProto:
@@ -140,3 +140,18 @@ class OrGroup:
140
140
 
141
141
  def or_(*conditions: Condition) -> OrGroup:
142
142
  return OrGroup(conditions=list(conditions))
143
+
144
+
145
+ def flatten_conditions(conditions: list[Condition | OrGroup]) -> list[Condition]:
146
+ flattened: list[Condition] = []
147
+
148
+ for condition in conditions:
149
+ if isinstance(condition, OrGroup):
150
+ for or_condition in condition.conditions:
151
+ or_condition.base.or_group_id = condition.or_group_id
152
+
153
+ flattened.extend(condition.conditions)
154
+ else:
155
+ flattened.append(condition)
156
+
157
+ return flattened
@@ -14,12 +14,17 @@ from hatchet_sdk.clients.listeners.durable_event_listener import (
14
14
  DurableEventListener,
15
15
  RegisterDurableEventRequest,
16
16
  )
17
+ from hatchet_sdk.conditions import (
18
+ OrGroup,
19
+ SleepCondition,
20
+ UserEventCondition,
21
+ flatten_conditions,
22
+ )
17
23
  from hatchet_sdk.context.worker_context import WorkerContext
18
24
  from hatchet_sdk.features.runs import RunsClient
19
25
  from hatchet_sdk.logger import logger
20
26
  from hatchet_sdk.utils.timedelta_to_expression import Duration, timedelta_to_expr
21
27
  from hatchet_sdk.utils.typing import JSONSerializableMapping
22
- from hatchet_sdk.waits import SleepCondition, UserEventCondition
23
28
  from hatchet_sdk.worker.runner.utils.capture_logs import AsyncLogSender, LogRecord
24
29
 
25
30
  if TYPE_CHECKING:
@@ -367,7 +372,9 @@ class Context:
367
372
 
368
373
  class DurableContext(Context):
369
374
  async def aio_wait_for(
370
- self, signal_key: str, *conditions: SleepCondition | UserEventCondition
375
+ self,
376
+ signal_key: str,
377
+ *conditions: SleepCondition | UserEventCondition | OrGroup,
371
378
  ) -> dict[str, Any]:
372
379
  """
373
380
  Durably wait for either a sleep or an event.
@@ -386,7 +393,7 @@ class DurableContext(Context):
386
393
  request = RegisterDurableEventRequest(
387
394
  task_id=task_id,
388
395
  signal_key=signal_key,
389
- conditions=list(conditions),
396
+ conditions=flatten_conditions(list(conditions)),
390
397
  config=self.runs_client.client_config,
391
398
  )
392
399
 
@@ -1,6 +1,15 @@
1
1
  from collections.abc import Callable
2
2
  from typing import TYPE_CHECKING, Any, Generic, cast, get_type_hints
3
3
 
4
+ from hatchet_sdk.conditions import (
5
+ Action,
6
+ Condition,
7
+ OrGroup,
8
+ ParentCondition,
9
+ SleepCondition,
10
+ UserEventCondition,
11
+ flatten_conditions,
12
+ )
4
13
  from hatchet_sdk.context.context import Context, DurableContext
5
14
  from hatchet_sdk.contracts.v1.shared.condition_pb2 import TaskConditions
6
15
  from hatchet_sdk.contracts.v1.workflows_pb2 import (
@@ -24,14 +33,6 @@ from hatchet_sdk.utils.typing import (
24
33
  TaskIOValidator,
25
34
  is_basemodel_subclass,
26
35
  )
27
- from hatchet_sdk.waits import (
28
- Action,
29
- Condition,
30
- OrGroup,
31
- ParentCondition,
32
- SleepCondition,
33
- UserEventCondition,
34
- )
35
36
 
36
37
  if TYPE_CHECKING:
37
38
  from hatchet_sdk.runnables.workflow import Workflow
@@ -84,9 +85,9 @@ class Task(Generic[TWorkflowInput, R]):
84
85
  self.backoff_max_seconds = backoff_max_seconds
85
86
  self.concurrency = concurrency or []
86
87
 
87
- self.wait_for = self._flatten_conditions(wait_for or [])
88
- self.skip_if = self._flatten_conditions(skip_if or [])
89
- self.cancel_if = self._flatten_conditions(cancel_if or [])
88
+ self.wait_for = flatten_conditions(wait_for or [])
89
+ self.skip_if = flatten_conditions(skip_if or [])
90
+ self.cancel_if = flatten_conditions(cancel_if or [])
90
91
 
91
92
  return_type = get_type_hints(_fn).get("return")
92
93
 
@@ -95,22 +96,6 @@ class Task(Generic[TWorkflowInput, R]):
95
96
  step_output=return_type if is_basemodel_subclass(return_type) else None,
96
97
  )
97
98
 
98
- def _flatten_conditions(
99
- self, conditions: list[Condition | OrGroup]
100
- ) -> list[Condition]:
101
- flattened: list[Condition] = []
102
-
103
- for condition in conditions:
104
- if isinstance(condition, OrGroup):
105
- for or_condition in condition.conditions:
106
- or_condition.base.or_group_id = condition.or_group_id
107
-
108
- flattened.extend(condition.conditions)
109
- else:
110
- flattened.append(condition)
111
-
112
- return flattened
113
-
114
99
  def call(self, ctx: Context | DurableContext) -> R:
115
100
  if self.is_async_function:
116
101
  raise TypeError(f"{self.name} is not a sync function. Use `acall` instead.")
@@ -17,6 +17,7 @@ from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows
17
17
  from hatchet_sdk.clients.rest.models.v1_filter import V1Filter
18
18
  from hatchet_sdk.clients.rest.models.v1_task_status import V1TaskStatus
19
19
  from hatchet_sdk.clients.rest.models.v1_task_summary import V1TaskSummary
20
+ from hatchet_sdk.conditions import Condition, OrGroup
20
21
  from hatchet_sdk.context.context import Context, DurableContext
21
22
  from hatchet_sdk.contracts.v1.workflows_pb2 import (
22
23
  CreateWorkflowVersionRequest,
@@ -43,7 +44,6 @@ from hatchet_sdk.utils.typing import (
43
44
  JSONSerializableMapping,
44
45
  is_basemodel_subclass,
45
46
  )
46
- from hatchet_sdk.waits import Condition, OrGroup
47
47
  from hatchet_sdk.workflow_run import WorkflowRunRef
48
48
 
49
49
  if TYPE_CHECKING:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hatchet-sdk
3
- Version: 1.14.0
3
+ Version: 1.14.1
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Alexander Belanger
@@ -1,11 +1,11 @@
1
- hatchet_sdk/__init__.py,sha256=PR-MvXgk-NVy-dgFg4uvXJe_1WSlJjzVb6cS4RKE3i0,10635
1
+ hatchet_sdk/__init__.py,sha256=3iVKyZ4OnGxZWU0YtXQG9imlljPNBdPARqqCm6Ft03o,10640
2
2
  hatchet_sdk/client.py,sha256=OXb2hOJ5p7pY5QMlM4cydb4aGyf6bDdbyWQjPMVCe64,2413
3
3
  hatchet_sdk/clients/admin.py,sha256=t8GXhjMiFp9iL0ofISNxSOKlfwaOTX2iQbZfz1G0pHU,16936
4
4
  hatchet_sdk/clients/dispatcher/action_listener.py,sha256=tFknXH9iSP0OFYYVcKeDZVrcDNIz00ZQVTxSbHpbKhI,13863
5
5
  hatchet_sdk/clients/dispatcher/dispatcher.py,sha256=5qyvLqiCJeW0n9rzqGUNasW95ATywcq5dJrT_ePKmUw,8114
6
6
  hatchet_sdk/clients/event_ts.py,sha256=d9NTfjWVk84QMB5XTWkDZ2UfsIIn5ytAEn6S5fhpxss,2121
7
7
  hatchet_sdk/clients/events.py,sha256=wE36_Wyb8BLywpuc8epRj7ZZDN9UCmztn6g3wdgRivM,8849
8
- hatchet_sdk/clients/listeners/durable_event_listener.py,sha256=0sc9DaGBS_cH2mvXLz13EEKO6I0Fq0lhRsTM4E6qKgs,4176
8
+ hatchet_sdk/clients/listeners/durable_event_listener.py,sha256=55WbVQpm65ccVSQtqz-Z_4EI8Gig-7MzH5F9Arh-rb0,4166
9
9
  hatchet_sdk/clients/listeners/pooled_listener.py,sha256=m0OwZhMVRyGCmw7XYvh_5R5Mpeg-TrJyPnQ3-d5NnJg,8514
10
10
  hatchet_sdk/clients/listeners/run_event_listener.py,sha256=CNXG5a_MUoYnNVmfrXkW1w3v6UnImyeUFXHQ96n4ULM,10222
11
11
  hatchet_sdk/clients/listeners/workflow_listener.py,sha256=u7qkr_uqnk3Pq_dARM3ah0nd1KtL3D_UQwbZ5IdcnjE,2283
@@ -230,10 +230,11 @@ hatchet_sdk/clients/rest/models/workflow_workers_count.py,sha256=qhzqfvjjIDyARki
230
230
  hatchet_sdk/clients/rest/rest.py,sha256=zZHTzgl-NBdcK6XhG23m_s9RKRONGPPItzGe407s7GA,9262
231
231
  hatchet_sdk/clients/rest/tenacity_utils.py,sha256=SQuy4x9scgBpqygRrGdjP7dJz4u4VVAEbjnieid4KcU,1029
232
232
  hatchet_sdk/clients/v1/api_client.py,sha256=mJQUZ3cOxlFJiwWKK5F8jBxcpNZ7A2292HucrBqurbg,1205
233
+ hatchet_sdk/conditions.py,sha256=CnhpkXgVXM3wc0kAX8KZQA6tp8NFAbdzAN2xFbw7Hb0,4522
233
234
  hatchet_sdk/config.py,sha256=DKOSCyOhFMx9d3Rvu5z9aImbOgZgwdNSg3XVzyVHn3g,5185
234
235
  hatchet_sdk/connection.py,sha256=oRxLs_lBRgHfE4jGLZJimr25ymlEJnK1ZXlh-CasjPo,2696
235
236
  hatchet_sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
236
- hatchet_sdk/context/context.py,sha256=gGQ_H_eUEPWGn6ac62sAFUnsS0pRtm9UibxPy8PJUT8,14309
237
+ hatchet_sdk/context/context.py,sha256=I5XfQ_m-Mn33G2no2x5ahd9S-jxMMsEnynhh5Q4JJx8,14411
237
238
  hatchet_sdk/context/worker_context.py,sha256=3lGkOYmDixeuSmqxXbsYav2gErcjP8cDa2m0t0iomjI,884
238
239
  hatchet_sdk/contracts/dispatcher_pb2.py,sha256=W9aGh-wctZhLjUXUdeQTxH4qArsw6D0kIAWM9SVCX5o,14786
239
240
  hatchet_sdk/contracts/dispatcher_pb2.pyi,sha256=9Qoz88G-btdlTuxvk4knqfnYdcIXy3oR9DTh6MwIdP4,18923
@@ -273,9 +274,9 @@ hatchet_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
273
274
  hatchet_sdk/rate_limit.py,sha256=TwbCuggiZaWpYuo4mjVLlE-z1OfQ2mRBiVvCSaG3lv4,3919
274
275
  hatchet_sdk/runnables/action.py,sha256=zrVHpyzIQ9XZgWwY69b_6uhZd53An4trRoLd9b3os5E,4384
275
276
  hatchet_sdk/runnables/contextvars.py,sha256=T2LWiXhcSyQYJY_-pfqMjDNjf6PdtDwyXyCZ6zIyWK0,929
276
- hatchet_sdk/runnables/task.py,sha256=YjAKjL5stGd0JLwsg-rTMQOZ0ZXI0TQg8pIPZ_PgMls,7212
277
+ hatchet_sdk/runnables/task.py,sha256=VEYabAl38U9L_igSDgZSzUL7-c-sX6YFRP0wsqGTadU,6714
277
278
  hatchet_sdk/runnables/types.py,sha256=QFayOJ_Oi8tOYI6Sjl9bwjftM96QZh9XIlfFnSNgEXI,4359
278
- hatchet_sdk/runnables/workflow.py,sha256=cGRbNMvlxZeuySXVgQ3eitTYY-78W7tGPOwFSFIfTFE,49322
279
+ hatchet_sdk/runnables/workflow.py,sha256=AVYMg_QTN9YkddFuOBa8iq9oQinRPdHo9UJsgI2TWHQ,49327
279
280
  hatchet_sdk/token.py,sha256=KjIiInwG5Kqd_FO4BSW1x_5Uc7PFbnzIVJqr50-ZldE,779
280
281
  hatchet_sdk/utils/backoff.py,sha256=6B5Rb5nLKw_TqqgpJMYjIBV1PTTtbOMRZCveisVhg_I,353
281
282
  hatchet_sdk/utils/opentelemetry.py,sha256=64TVwCLrUzEmcL2BUNPV_QubfiR5jajOZtVeGYLnEEA,1226
@@ -503,7 +504,6 @@ hatchet_sdk/v0/worker/runner/utils/error_with_traceback.py,sha256=Iih_s8JNqrinXE
503
504
  hatchet_sdk/v0/worker/worker.py,sha256=QtkabDUSAnNExi2sTY5VLSAJak_X0DQNGjei8GtYSR4,13021
504
505
  hatchet_sdk/v0/workflow.py,sha256=txhAZC0ohjhRrviIKn1yCR-ybqoQJ4jCrTc7vIkfO3g,9381
505
506
  hatchet_sdk/v0/workflow_run.py,sha256=jsEZprXshrSV7i_TtL5uoCL03D18zQ3NeJCq7mp97Dg,1752
506
- hatchet_sdk/waits.py,sha256=yJm5U2VfiVHfLLj0SwG6RDnpLH3F4VL3rZ2iiY_IwMY,4073
507
507
  hatchet_sdk/worker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
508
508
  hatchet_sdk/worker/action_listener_process.py,sha256=Xzzn1dDFJrqnC9HBsh3fYI8lfpOD4Ecze47qmm_XUWE,12923
509
509
  hatchet_sdk/worker/runner/run_loop_manager.py,sha256=GeILClNXaDbsjXCQb0bBdgeyAwZGem2JdaH0t6wz__I,4053
@@ -511,7 +511,7 @@ hatchet_sdk/worker/runner/runner.py,sha256=5dOLFJIEWHed2sQxSeWmqMFWVViYTnfvk70n1
511
511
  hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=DKw6boqVsSCM1XvBWYuc833MZxCdSpMxg3l4aAqKPyw,3465
512
512
  hatchet_sdk/worker/worker.py,sha256=nDuRo_LishRuOCTnDonc7G7qeOoW93nRHGd-fQOE_bs,16541
513
513
  hatchet_sdk/workflow_run.py,sha256=KcylcqRwKADtnzOTjoiVr1vdr7qTZFtDeD5aRS6A4Y8,2823
514
- hatchet_sdk-1.14.0.dist-info/METADATA,sha256=x3QO_B5tvFv5v4FQEr4BAFLsZvEQN1z7Unk36scw8T0,3636
515
- hatchet_sdk-1.14.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
516
- hatchet_sdk-1.14.0.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
517
- hatchet_sdk-1.14.0.dist-info/RECORD,,
514
+ hatchet_sdk-1.14.1.dist-info/METADATA,sha256=Eygcnag5XEsRLK-kC1LDbF5L3YJmLIazhyLFTOZeLBY,3636
515
+ hatchet_sdk-1.14.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
516
+ hatchet_sdk-1.14.1.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
517
+ hatchet_sdk-1.14.1.dist-info/RECORD,,