hatchet-sdk 1.3.1__py3-none-any.whl → 1.3.2__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.

@@ -19,7 +19,7 @@ from hatchet_sdk.context.worker_context import WorkerContext
19
19
  from hatchet_sdk.features.runs import RunsClient
20
20
  from hatchet_sdk.logger import logger
21
21
  from hatchet_sdk.utils.timedelta_to_expression import Duration, timedelta_to_expr
22
- from hatchet_sdk.utils.typing import JSONSerializableMapping, WorkflowValidator
22
+ from hatchet_sdk.utils.typing import JSONSerializableMapping
23
23
  from hatchet_sdk.waits import SleepCondition, UserEventCondition
24
24
 
25
25
  if TYPE_CHECKING:
@@ -37,10 +37,8 @@ class Context:
37
37
  durable_event_listener: DurableEventListener | None,
38
38
  worker: WorkerContext,
39
39
  runs_client: RunsClient,
40
- validator_registry: dict[str, WorkflowValidator] = {},
41
40
  ):
42
41
  self.worker = worker
43
- self.validator_registry = validator_registry
44
42
 
45
43
  self.data = action.action_payload
46
44
 
@@ -74,27 +72,12 @@ class Context:
74
72
  if self.was_skipped(task):
75
73
  raise ValueError("{task.name} was skipped")
76
74
 
77
- action_prefix = self.action.action_id.split(":")[0]
78
-
79
- workflow_validator = next(
80
- (
81
- v
82
- for k, v in self.validator_registry.items()
83
- if k == f"{action_prefix}:{task.name}"
84
- ),
85
- None,
86
- )
87
-
88
75
  try:
89
76
  parent_step_data = cast(R, self.data.parents[task.name])
90
77
  except KeyError:
91
78
  raise ValueError(f"Step output for '{task.name}' not found")
92
79
 
93
- if (
94
- parent_step_data
95
- and workflow_validator
96
- and (v := workflow_validator.step_output)
97
- ):
80
+ if parent_step_data and (v := task.validators.step_output):
98
81
  return cast(R, v.model_validate(parent_step_data))
99
82
 
100
83
  return parent_step_data
@@ -7,6 +7,7 @@ from typing import (
7
7
  TypeVar,
8
8
  Union,
9
9
  cast,
10
+ get_type_hints,
10
11
  )
11
12
 
12
13
  from hatchet_sdk.context.context import Context, DurableContext
@@ -28,6 +29,7 @@ from hatchet_sdk.runnables.types import (
28
29
  is_sync_fn,
29
30
  )
30
31
  from hatchet_sdk.utils.timedelta_to_expression import Duration, timedelta_to_expr
32
+ from hatchet_sdk.utils.typing import TaskIOValidator, is_basemodel_subclass
31
33
  from hatchet_sdk.waits import (
32
34
  Action,
33
35
  Condition,
@@ -106,6 +108,13 @@ class Task(Generic[TWorkflowInput, R]):
106
108
  self.skip_if = self._flatten_conditions(skip_if)
107
109
  self.cancel_if = self._flatten_conditions(cancel_if)
108
110
 
111
+ return_type = get_type_hints(_fn).get("return")
112
+
113
+ self.validators: TaskIOValidator = TaskIOValidator(
114
+ workflow_input=workflow.config.input_validator,
115
+ step_output=return_type if is_basemodel_subclass(return_type) else None,
116
+ )
117
+
109
118
  def _flatten_conditions(
110
119
  self, conditions: list[Condition | OrGroup]
111
120
  ) -> list[Condition]:
@@ -1,9 +1,7 @@
1
- from typing import Any, Mapping, Type, TypeGuard, TypeVar
1
+ from typing import Any, Mapping, Type, TypeGuard
2
2
 
3
3
  from pydantic import BaseModel
4
4
 
5
- T = TypeVar("T", bound=BaseModel)
6
-
7
5
 
8
6
  def is_basemodel_subclass(model: Any) -> TypeGuard[Type[BaseModel]]:
9
7
  try:
@@ -12,7 +10,7 @@ def is_basemodel_subclass(model: Any) -> TypeGuard[Type[BaseModel]]:
12
10
  return False
13
11
 
14
12
 
15
- class WorkflowValidator(BaseModel):
13
+ class TaskIOValidator(BaseModel):
16
14
  workflow_input: Type[BaseModel] | None = None
17
15
  step_output: Type[BaseModel] | None = None
18
16
 
@@ -8,7 +8,6 @@ from hatchet_sdk.clients.dispatcher.action_listener import Action
8
8
  from hatchet_sdk.config import ClientConfig
9
9
  from hatchet_sdk.logger import logger
10
10
  from hatchet_sdk.runnables.task import Task
11
- from hatchet_sdk.utils.typing import WorkflowValidator
12
11
  from hatchet_sdk.worker.action_listener_process import ActionEvent
13
12
  from hatchet_sdk.worker.runner.runner import Runner
14
13
  from hatchet_sdk.worker.runner.utils.capture_logs import capture_logs
@@ -24,7 +23,6 @@ class WorkerActionRunLoopManager:
24
23
  self,
25
24
  name: str,
26
25
  action_registry: dict[str, Task[Any, Any]],
27
- validator_registry: dict[str, WorkflowValidator],
28
26
  slots: int | None,
29
27
  config: ClientConfig,
30
28
  action_queue: "Queue[Action | STOP_LOOP_TYPE]",
@@ -36,7 +34,6 @@ class WorkerActionRunLoopManager:
36
34
  ) -> None:
37
35
  self.name = name
38
36
  self.action_registry = action_registry
39
- self.validator_registry = validator_registry
40
37
  self.slots = slots
41
38
  self.config = config
42
39
  self.action_queue = action_queue
@@ -88,7 +85,6 @@ class WorkerActionRunLoopManager:
88
85
  self.slots,
89
86
  self.handle_kill,
90
87
  self.action_registry,
91
- self.validator_registry,
92
88
  self.labels,
93
89
  )
94
90
 
@@ -43,7 +43,6 @@ from hatchet_sdk.runnables.contextvars import (
43
43
  )
44
44
  from hatchet_sdk.runnables.task import Task
45
45
  from hatchet_sdk.runnables.types import R, TWorkflowInput
46
- from hatchet_sdk.utils.typing import WorkflowValidator
47
46
  from hatchet_sdk.worker.action_listener_process import ActionEvent
48
47
  from hatchet_sdk.worker.runner.utils.capture_logs import copy_context_vars
49
48
 
@@ -63,7 +62,6 @@ class Runner:
63
62
  slots: int | None = None,
64
63
  handle_kill: bool = True,
65
64
  action_registry: dict[str, Task[TWorkflowInput, R]] = {},
66
- validator_registry: dict[str, WorkflowValidator] = {},
67
65
  labels: dict[str, str | int] = {},
68
66
  ):
69
67
  # We store the config so we can dynamically create clients for the dispatcher client.
@@ -73,7 +71,6 @@ class Runner:
73
71
  self.tasks: dict[str, asyncio.Task[Any]] = {} # Store run ids and futures
74
72
  self.contexts: dict[str, Context] = {} # Store run ids and contexts
75
73
  self.action_registry = action_registry
76
- self.validator_registry = validator_registry
77
74
 
78
75
  self.event_queue = event_queue
79
76
 
@@ -305,7 +302,6 @@ class Runner:
305
302
  event_client=self.event_client,
306
303
  durable_event_listener=self.durable_event_listener,
307
304
  worker=self.worker_context,
308
- validator_registry=self.validator_registry,
309
305
  runs_client=self.runs_client,
310
306
  )
311
307
 
@@ -10,7 +10,7 @@ from enum import Enum
10
10
  from multiprocessing import Queue
11
11
  from multiprocessing.process import BaseProcess
12
12
  from types import FrameType
13
- from typing import Any, TypeVar, get_type_hints
13
+ from typing import Any, TypeVar
14
14
  from warnings import warn
15
15
 
16
16
  from aiohttp import web
@@ -26,7 +26,6 @@ from hatchet_sdk.contracts.v1.workflows_pb2 import CreateWorkflowVersionRequest
26
26
  from hatchet_sdk.logger import logger
27
27
  from hatchet_sdk.runnables.task import Task
28
28
  from hatchet_sdk.runnables.workflow import BaseWorkflow
29
- from hatchet_sdk.utils.typing import WorkflowValidator, is_basemodel_subclass
30
29
  from hatchet_sdk.worker.action_listener_process import (
31
30
  ActionEvent,
32
31
  worker_action_listener_process,
@@ -87,8 +86,6 @@ class Worker:
87
86
  self.action_registry: dict[str, Task[Any, Any]] = {}
88
87
  self.durable_action_registry: dict[str, Task[Any, Any]] = {}
89
88
 
90
- self.validator_registry: dict[str, WorkflowValidator] = {}
91
-
92
89
  self.killing: bool = False
93
90
  self._status: WorkerStatus
94
91
 
@@ -153,13 +150,6 @@ class Worker:
153
150
  self.has_any_non_durable = True
154
151
  self.action_registry[action_name] = step
155
152
 
156
- return_type = get_type_hints(step.fn).get("return")
157
-
158
- self.validator_registry[action_name] = WorkflowValidator(
159
- workflow_input=workflow.config.input_validator,
160
- step_output=return_type if is_basemodel_subclass(return_type) else None,
161
- )
162
-
163
153
  def register_workflows(self, workflows: list[BaseWorkflow[Any]]) -> None:
164
154
  for workflow in workflows:
165
155
  self.register_workflow(workflow)
@@ -285,7 +275,6 @@ class Worker:
285
275
  return WorkerActionRunLoopManager(
286
276
  self.name + ("_durable" if is_durable else ""),
287
277
  self.durable_action_registry if is_durable else self.action_registry,
288
- self.validator_registry,
289
278
  1_000 if is_durable else self.slots,
290
279
  self.config,
291
280
  self.durable_action_queue if is_durable else self.action_queue,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hatchet-sdk
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary:
5
5
  Author: Alexander Belanger
6
6
  Author-email: alexander@hatchet.run
@@ -221,7 +221,7 @@ hatchet_sdk/clients/v1/api_client.py,sha256=mJQUZ3cOxlFJiwWKK5F8jBxcpNZ7A2292Huc
221
221
  hatchet_sdk/config.py,sha256=jJA76BOvVdfOQHy6TKclAvr2qyblcM-Pz5J-hVAdpQ4,3588
222
222
  hatchet_sdk/connection.py,sha256=B5gT5NL9BBB5-l9U_cN6pMlraQk880rEYMnqaK_dgL0,2590
223
223
  hatchet_sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
224
- hatchet_sdk/context/context.py,sha256=FUClTuxFETBAljI0gknOdqkCEgkY2EX1lOx2xib2xzk,9659
224
+ hatchet_sdk/context/context.py,sha256=povQ0iO-QOi_lzntSWUiZPGbtpNTq-1m80b3zjIX74A,9163
225
225
  hatchet_sdk/context/worker_context.py,sha256=OVcEWvdT_Kpd0nlg61VAPUgIPSFzSLs0aSrXWj-1GX4,974
226
226
  hatchet_sdk/contracts/dispatcher_pb2.py,sha256=SN4CIKeQwYkrbfRGhdhZo2uBn4nGzjUWIC1vvXdDeOQ,14503
227
227
  hatchet_sdk/contracts/dispatcher_pb2.pyi,sha256=ZSGio5eYxkw-QuQx2C5ASTNcKzeMQn5JTnWaRiThafM,18455
@@ -259,14 +259,14 @@ hatchet_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
259
259
  hatchet_sdk/rate_limit.py,sha256=TwbCuggiZaWpYuo4mjVLlE-z1OfQ2mRBiVvCSaG3lv4,3919
260
260
  hatchet_sdk/runnables/contextvars.py,sha256=6MDocAMmlyiRW37oQ1jyx10tAlJs-xgDjR3xPoPz05g,426
261
261
  hatchet_sdk/runnables/standalone.py,sha256=KyKA3UeuyU_IK0t-c0Q56Lm-W4rewILkfHlenjos474,6276
262
- hatchet_sdk/runnables/task.py,sha256=R7QpxHsMKQSp6V84NeQ8oFdTNLPY77Ocx0MM1Q3xX40,7164
262
+ hatchet_sdk/runnables/task.py,sha256=nZPclBbNaYRMlCLOYi91YU503MiTcGSp92Unh3_nKvs,7533
263
263
  hatchet_sdk/runnables/types.py,sha256=1Y2mS7bDVY86rE7SSMzt9KKcF8qGiaiEmQ85jR8DMT4,4500
264
264
  hatchet_sdk/runnables/workflow.py,sha256=FcmN7-cmI32GnnkKGKhUL2xV3z7vfBK43LmJVuKKiyo,27771
265
265
  hatchet_sdk/token.py,sha256=KjIiInwG5Kqd_FO4BSW1x_5Uc7PFbnzIVJqr50-ZldE,779
266
266
  hatchet_sdk/utils/backoff.py,sha256=6B5Rb5nLKw_TqqgpJMYjIBV1PTTtbOMRZCveisVhg_I,353
267
267
  hatchet_sdk/utils/proto_enums.py,sha256=0UybwE3s7TcqmzoQSO8YnhgAKOS8WZXsyPchB8-eksw,1247
268
268
  hatchet_sdk/utils/timedelta_to_expression.py,sha256=n5jIxlcswN9GwFPjktuMceedekzWWT6X7U6gbsZciIQ,455
269
- hatchet_sdk/utils/typing.py,sha256=ohzSvBciQKiFwY-rCWdpodEZb4iAilQ87rjOBakY4MQ,473
269
+ hatchet_sdk/utils/typing.py,sha256=huflXWR7fvRfIFYdqQIrQmn9jtukzOWoTpW3AXGk5c0,427
270
270
  hatchet_sdk/v0/__init__.py,sha256=YNh-0rPHS0rcphmykJ1N2NMfgvERF4oJpBtx3IH_E_M,9657
271
271
  hatchet_sdk/v0/client.py,sha256=G1RDZln9Og7tRQulogXkZw8TsVlx7f0VvmtFI_VAe6E,3495
272
272
  hatchet_sdk/v0/clients/admin.py,sha256=l6fW21p_3pROz8mVB2QOXX0Pg5poeLXcBNEm6Uids30,18071
@@ -501,12 +501,12 @@ hatchet_sdk/v0/workflow_run.py,sha256=jsEZprXshrSV7i_TtL5uoCL03D18zQ3NeJCq7mp97D
501
501
  hatchet_sdk/waits.py,sha256=dTrelK8Lk0W5anq3TlpJwAK5z8TJ0FW7XgoSg8bf8fA,3351
502
502
  hatchet_sdk/worker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
503
503
  hatchet_sdk/worker/action_listener_process.py,sha256=KxS7-wBpfKnsq0LNSvk-MG442Lh60iQMy3VpD1FW3mU,11703
504
- hatchet_sdk/worker/runner/run_loop_manager.py,sha256=P0iyKSfAb0IW5LDUnwzUOgCp0lPpAAKXCkeTXGQq8oY,3893
505
- hatchet_sdk/worker/runner/runner.py,sha256=mfEsR2EDcKPkEIylkz3FLsMC33OqTs4r5zpxCIjitoc,17446
504
+ hatchet_sdk/worker/runner/run_loop_manager.py,sha256=QrhhAMnQmyThDMgohZwFw-0AVPHvhT4seK2FVCzvC7c,3690
505
+ hatchet_sdk/worker/runner/runner.py,sha256=t8U4QK2GYNjgxGHFmD9RW12e3vungu_bvBSBBdIb_cs,17219
506
506
  hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=nHRPSiDBqzhObM7i2X7t03OupVFnE7kQBdR2Ckgg-2w,2709
507
- hatchet_sdk/worker/worker.py,sha256=dcJEMeogodhLEi_5a0ldJLZ5EEN7DNcr8aiFLknTb18,14667
507
+ hatchet_sdk/worker/worker.py,sha256=5DfmNNjGuYtn-n9Qce1B2XCLKjnIXzNwF8VLW-wtI5Y,14161
508
508
  hatchet_sdk/workflow_run.py,sha256=ZwH0HLFGFVXz6jbiqSv4w0Om2XuR52Tzzw6LH4y65jQ,2765
509
- hatchet_sdk-1.3.1.dist-info/METADATA,sha256=sS8Lrxkr6HvdjuhsP0vmjACIGE_pXxfGBH6uyzvgF1M,3571
510
- hatchet_sdk-1.3.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
511
- hatchet_sdk-1.3.1.dist-info/entry_points.txt,sha256=5mTp_AsCWK5raiVxP_MU9eBCgkRGl4OsN6chpHcvm7o,1235
512
- hatchet_sdk-1.3.1.dist-info/RECORD,,
509
+ hatchet_sdk-1.3.2.dist-info/METADATA,sha256=tWsWj0cUquv41Ih8O3mIM3Pwk6jl3mp0rIBWExejSI0,3571
510
+ hatchet_sdk-1.3.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
511
+ hatchet_sdk-1.3.2.dist-info/entry_points.txt,sha256=5mTp_AsCWK5raiVxP_MU9eBCgkRGl4OsN6chpHcvm7o,1235
512
+ hatchet_sdk-1.3.2.dist-info/RECORD,,