hatchet-sdk 1.10.1__py3-none-any.whl → 1.10.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.
- hatchet_sdk/clients/admin.py +5 -3
- hatchet_sdk/clients/dispatcher/action_listener.py +3 -119
- hatchet_sdk/clients/dispatcher/dispatcher.py +1 -1
- hatchet_sdk/opentelemetry/instrumentor.py +1 -1
- hatchet_sdk/runnables/action.py +125 -0
- hatchet_sdk/runnables/contextvars.py +6 -1
- hatchet_sdk/worker/action_listener_process.py +3 -2
- hatchet_sdk/worker/runner/run_loop_manager.py +1 -1
- hatchet_sdk/worker/runner/runner.py +5 -3
- hatchet_sdk/worker/worker.py +1 -1
- {hatchet_sdk-1.10.1.dist-info → hatchet_sdk-1.10.2.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.10.1.dist-info → hatchet_sdk-1.10.2.dist-info}/RECORD +14 -13
- {hatchet_sdk-1.10.1.dist-info → hatchet_sdk-1.10.2.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.10.1.dist-info → hatchet_sdk-1.10.2.dist-info}/entry_points.txt +0 -0
hatchet_sdk/clients/admin.py
CHANGED
|
@@ -20,6 +20,7 @@ from hatchet_sdk.features.runs import RunsClient
|
|
|
20
20
|
from hatchet_sdk.metadata import get_metadata
|
|
21
21
|
from hatchet_sdk.rate_limit import RateLimitDuration
|
|
22
22
|
from hatchet_sdk.runnables.contextvars import (
|
|
23
|
+
ctx_action_key,
|
|
23
24
|
ctx_step_run_id,
|
|
24
25
|
ctx_worker_id,
|
|
25
26
|
ctx_workflow_run_id,
|
|
@@ -281,11 +282,12 @@ class AdminClient:
|
|
|
281
282
|
workflow_run_id = ctx_workflow_run_id.get()
|
|
282
283
|
step_run_id = ctx_step_run_id.get()
|
|
283
284
|
worker_id = ctx_worker_id.get()
|
|
284
|
-
|
|
285
|
+
action_key = ctx_action_key.get()
|
|
286
|
+
spawn_index = workflow_spawn_indices[action_key] if action_key else 0
|
|
285
287
|
|
|
286
288
|
## Increment the spawn_index for the parent workflow
|
|
287
|
-
if
|
|
288
|
-
workflow_spawn_indices[
|
|
289
|
+
if action_key:
|
|
290
|
+
workflow_spawn_indices[action_key] += 1
|
|
289
291
|
|
|
290
292
|
desired_worker_id = (
|
|
291
293
|
(options.desired_worker_id or worker_id) if options.sticky else None
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
3
|
import time
|
|
4
|
-
from
|
|
5
|
-
from enum import Enum
|
|
6
|
-
from typing import TYPE_CHECKING, Any, AsyncGenerator, cast
|
|
4
|
+
from typing import TYPE_CHECKING, AsyncGenerator, cast
|
|
7
5
|
|
|
8
6
|
import grpc
|
|
9
7
|
import grpc.aio
|
|
10
|
-
from pydantic import BaseModel, ConfigDict, Field,
|
|
8
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
11
9
|
|
|
12
10
|
from hatchet_sdk.clients.event_ts import (
|
|
13
11
|
ThreadSafeEvent,
|
|
@@ -30,8 +28,8 @@ from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
|
30
28
|
from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
31
29
|
from hatchet_sdk.logger import logger
|
|
32
30
|
from hatchet_sdk.metadata import get_metadata
|
|
31
|
+
from hatchet_sdk.runnables.action import Action, ActionPayload, ActionType
|
|
33
32
|
from hatchet_sdk.utils.backoff import exp_backoff_sleep
|
|
34
|
-
from hatchet_sdk.utils.opentelemetry import OTelAttribute
|
|
35
33
|
from hatchet_sdk.utils.proto_enums import convert_proto_enum_to_python
|
|
36
34
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
37
35
|
|
|
@@ -67,120 +65,6 @@ class GetActionListenerRequest(BaseModel):
|
|
|
67
65
|
return self
|
|
68
66
|
|
|
69
67
|
|
|
70
|
-
class ActionPayload(BaseModel):
|
|
71
|
-
model_config = ConfigDict(extra="allow")
|
|
72
|
-
|
|
73
|
-
input: JSONSerializableMapping = Field(default_factory=dict)
|
|
74
|
-
parents: dict[str, JSONSerializableMapping] = Field(default_factory=dict)
|
|
75
|
-
overrides: JSONSerializableMapping = Field(default_factory=dict)
|
|
76
|
-
user_data: JSONSerializableMapping = Field(default_factory=dict)
|
|
77
|
-
step_run_errors: dict[str, str] = Field(default_factory=dict)
|
|
78
|
-
triggered_by: str | None = None
|
|
79
|
-
triggers: JSONSerializableMapping = Field(default_factory=dict)
|
|
80
|
-
filter_payload: JSONSerializableMapping = Field(default_factory=dict)
|
|
81
|
-
|
|
82
|
-
@field_validator(
|
|
83
|
-
"input",
|
|
84
|
-
"parents",
|
|
85
|
-
"overrides",
|
|
86
|
-
"user_data",
|
|
87
|
-
"step_run_errors",
|
|
88
|
-
"filter_payload",
|
|
89
|
-
mode="before",
|
|
90
|
-
)
|
|
91
|
-
@classmethod
|
|
92
|
-
def validate_fields(cls, v: Any) -> Any:
|
|
93
|
-
return v or {}
|
|
94
|
-
|
|
95
|
-
@model_validator(mode="after")
|
|
96
|
-
def validate_filter_payload(self) -> "ActionPayload":
|
|
97
|
-
self.filter_payload = self.triggers.get("filter_payload", {})
|
|
98
|
-
|
|
99
|
-
return self
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
class ActionType(str, Enum):
|
|
103
|
-
START_STEP_RUN = "START_STEP_RUN"
|
|
104
|
-
CANCEL_STEP_RUN = "CANCEL_STEP_RUN"
|
|
105
|
-
START_GET_GROUP_KEY = "START_GET_GROUP_KEY"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
ActionKey = str
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class Action(BaseModel):
|
|
112
|
-
worker_id: str
|
|
113
|
-
tenant_id: str
|
|
114
|
-
workflow_run_id: str
|
|
115
|
-
workflow_id: str | None = None
|
|
116
|
-
workflow_version_id: str | None = None
|
|
117
|
-
get_group_key_run_id: str
|
|
118
|
-
job_id: str
|
|
119
|
-
job_name: str
|
|
120
|
-
job_run_id: str
|
|
121
|
-
step_id: str
|
|
122
|
-
step_run_id: str
|
|
123
|
-
action_id: str
|
|
124
|
-
action_type: ActionType
|
|
125
|
-
retry_count: int
|
|
126
|
-
action_payload: ActionPayload
|
|
127
|
-
additional_metadata: JSONSerializableMapping = field(default_factory=dict)
|
|
128
|
-
|
|
129
|
-
child_workflow_index: int | None = None
|
|
130
|
-
child_workflow_key: str | None = None
|
|
131
|
-
parent_workflow_run_id: str | None = None
|
|
132
|
-
|
|
133
|
-
priority: int | None = None
|
|
134
|
-
|
|
135
|
-
def _dump_payload_to_str(self) -> str:
|
|
136
|
-
try:
|
|
137
|
-
return json.dumps(self.action_payload.model_dump(), default=str)
|
|
138
|
-
except Exception:
|
|
139
|
-
return str(self.action_payload)
|
|
140
|
-
|
|
141
|
-
def get_otel_attributes(self, config: "ClientConfig") -> dict[str, str | int]:
|
|
142
|
-
try:
|
|
143
|
-
payload_str = json.dumps(self.action_payload.model_dump(), default=str)
|
|
144
|
-
except Exception:
|
|
145
|
-
payload_str = str(self.action_payload)
|
|
146
|
-
|
|
147
|
-
attrs: dict[OTelAttribute, str | int | None] = {
|
|
148
|
-
OTelAttribute.TENANT_ID: self.tenant_id,
|
|
149
|
-
OTelAttribute.WORKER_ID: self.worker_id,
|
|
150
|
-
OTelAttribute.WORKFLOW_RUN_ID: self.workflow_run_id,
|
|
151
|
-
OTelAttribute.STEP_ID: self.step_id,
|
|
152
|
-
OTelAttribute.STEP_RUN_ID: self.step_run_id,
|
|
153
|
-
OTelAttribute.RETRY_COUNT: self.retry_count,
|
|
154
|
-
OTelAttribute.PARENT_WORKFLOW_RUN_ID: self.parent_workflow_run_id,
|
|
155
|
-
OTelAttribute.CHILD_WORKFLOW_INDEX: self.child_workflow_index,
|
|
156
|
-
OTelAttribute.CHILD_WORKFLOW_KEY: self.child_workflow_key,
|
|
157
|
-
OTelAttribute.ACTION_PAYLOAD: payload_str,
|
|
158
|
-
OTelAttribute.WORKFLOW_NAME: self.job_name,
|
|
159
|
-
OTelAttribute.ACTION_NAME: self.action_id,
|
|
160
|
-
OTelAttribute.GET_GROUP_KEY_RUN_ID: self.get_group_key_run_id,
|
|
161
|
-
OTelAttribute.WORKFLOW_ID: self.workflow_id,
|
|
162
|
-
OTelAttribute.WORKFLOW_VERSION_ID: self.workflow_version_id,
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
f"hatchet.{k.value}": v
|
|
167
|
-
for k, v in attrs.items()
|
|
168
|
-
if v and k not in config.otel.excluded_attributes
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@property
|
|
172
|
-
def key(self) -> ActionKey:
|
|
173
|
-
"""
|
|
174
|
-
This key is used to uniquely identify a single step run by its id + retry count.
|
|
175
|
-
It's used when storing references to a task, a context, etc. in a dictionary so that
|
|
176
|
-
we can look up those items in the dictionary by a unique key.
|
|
177
|
-
"""
|
|
178
|
-
if self.action_type == ActionType.START_GET_GROUP_KEY:
|
|
179
|
-
return f"{self.get_group_key_run_id}/{self.retry_count}"
|
|
180
|
-
else:
|
|
181
|
-
return f"{self.step_run_id}/{self.retry_count}"
|
|
182
|
-
|
|
183
|
-
|
|
184
68
|
def parse_additional_metadata(additional_metadata: str) -> JSONSerializableMapping:
|
|
185
69
|
try:
|
|
186
70
|
return cast(
|
|
@@ -4,7 +4,6 @@ import grpc.aio
|
|
|
4
4
|
from google.protobuf.timestamp_pb2 import Timestamp
|
|
5
5
|
|
|
6
6
|
from hatchet_sdk.clients.dispatcher.action_listener import (
|
|
7
|
-
Action,
|
|
8
7
|
ActionListener,
|
|
9
8
|
GetActionListenerRequest,
|
|
10
9
|
)
|
|
@@ -29,6 +28,7 @@ from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
|
29
28
|
)
|
|
30
29
|
from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
31
30
|
from hatchet_sdk.metadata import get_metadata
|
|
31
|
+
from hatchet_sdk.runnables.action import Action
|
|
32
32
|
|
|
33
33
|
DEFAULT_REGISTER_TIMEOUT = 30
|
|
34
34
|
|
|
@@ -33,13 +33,13 @@ from hatchet_sdk.clients.admin import (
|
|
|
33
33
|
TriggerWorkflowOptions,
|
|
34
34
|
WorkflowRunTriggerConfig,
|
|
35
35
|
)
|
|
36
|
-
from hatchet_sdk.clients.dispatcher.action_listener import Action
|
|
37
36
|
from hatchet_sdk.clients.events import (
|
|
38
37
|
BulkPushEventWithMetadata,
|
|
39
38
|
EventClient,
|
|
40
39
|
PushEventOptions,
|
|
41
40
|
)
|
|
42
41
|
from hatchet_sdk.contracts.events_pb2 import Event
|
|
42
|
+
from hatchet_sdk.runnables.action import Action
|
|
43
43
|
from hatchet_sdk.worker.runner.runner import Runner
|
|
44
44
|
from hatchet_sdk.workflow_run import WorkflowRunRef
|
|
45
45
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from dataclasses import field
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
|
7
|
+
|
|
8
|
+
from hatchet_sdk.utils.opentelemetry import OTelAttribute
|
|
9
|
+
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from hatchet_sdk.config import ClientConfig
|
|
13
|
+
|
|
14
|
+
ActionKey = str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ActionPayload(BaseModel):
|
|
18
|
+
model_config = ConfigDict(extra="allow")
|
|
19
|
+
|
|
20
|
+
input: JSONSerializableMapping = Field(default_factory=dict)
|
|
21
|
+
parents: dict[str, JSONSerializableMapping] = Field(default_factory=dict)
|
|
22
|
+
overrides: JSONSerializableMapping = Field(default_factory=dict)
|
|
23
|
+
user_data: JSONSerializableMapping = Field(default_factory=dict)
|
|
24
|
+
step_run_errors: dict[str, str] = Field(default_factory=dict)
|
|
25
|
+
triggered_by: str | None = None
|
|
26
|
+
triggers: JSONSerializableMapping = Field(default_factory=dict)
|
|
27
|
+
filter_payload: JSONSerializableMapping = Field(default_factory=dict)
|
|
28
|
+
|
|
29
|
+
@field_validator(
|
|
30
|
+
"input",
|
|
31
|
+
"parents",
|
|
32
|
+
"overrides",
|
|
33
|
+
"user_data",
|
|
34
|
+
"step_run_errors",
|
|
35
|
+
"filter_payload",
|
|
36
|
+
mode="before",
|
|
37
|
+
)
|
|
38
|
+
@classmethod
|
|
39
|
+
def validate_fields(cls, v: Any) -> Any:
|
|
40
|
+
return v or {}
|
|
41
|
+
|
|
42
|
+
@model_validator(mode="after")
|
|
43
|
+
def validate_filter_payload(self) -> "ActionPayload":
|
|
44
|
+
self.filter_payload = self.triggers.get("filter_payload", {})
|
|
45
|
+
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ActionType(str, Enum):
|
|
50
|
+
START_STEP_RUN = "START_STEP_RUN"
|
|
51
|
+
CANCEL_STEP_RUN = "CANCEL_STEP_RUN"
|
|
52
|
+
START_GET_GROUP_KEY = "START_GET_GROUP_KEY"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Action(BaseModel):
|
|
56
|
+
worker_id: str
|
|
57
|
+
tenant_id: str
|
|
58
|
+
workflow_run_id: str
|
|
59
|
+
workflow_id: str | None = None
|
|
60
|
+
workflow_version_id: str | None = None
|
|
61
|
+
get_group_key_run_id: str
|
|
62
|
+
job_id: str
|
|
63
|
+
job_name: str
|
|
64
|
+
job_run_id: str
|
|
65
|
+
step_id: str
|
|
66
|
+
step_run_id: str
|
|
67
|
+
action_id: str
|
|
68
|
+
action_type: ActionType
|
|
69
|
+
retry_count: int
|
|
70
|
+
action_payload: ActionPayload
|
|
71
|
+
additional_metadata: JSONSerializableMapping = field(default_factory=dict)
|
|
72
|
+
|
|
73
|
+
child_workflow_index: int | None = None
|
|
74
|
+
child_workflow_key: str | None = None
|
|
75
|
+
parent_workflow_run_id: str | None = None
|
|
76
|
+
|
|
77
|
+
priority: int | None = None
|
|
78
|
+
|
|
79
|
+
def _dump_payload_to_str(self) -> str:
|
|
80
|
+
try:
|
|
81
|
+
return json.dumps(self.action_payload.model_dump(), default=str)
|
|
82
|
+
except Exception:
|
|
83
|
+
return str(self.action_payload)
|
|
84
|
+
|
|
85
|
+
def get_otel_attributes(self, config: "ClientConfig") -> dict[str, str | int]:
|
|
86
|
+
try:
|
|
87
|
+
payload_str = json.dumps(self.action_payload.model_dump(), default=str)
|
|
88
|
+
except Exception:
|
|
89
|
+
payload_str = str(self.action_payload)
|
|
90
|
+
|
|
91
|
+
attrs: dict[OTelAttribute, str | int | None] = {
|
|
92
|
+
OTelAttribute.TENANT_ID: self.tenant_id,
|
|
93
|
+
OTelAttribute.WORKER_ID: self.worker_id,
|
|
94
|
+
OTelAttribute.WORKFLOW_RUN_ID: self.workflow_run_id,
|
|
95
|
+
OTelAttribute.STEP_ID: self.step_id,
|
|
96
|
+
OTelAttribute.STEP_RUN_ID: self.step_run_id,
|
|
97
|
+
OTelAttribute.RETRY_COUNT: self.retry_count,
|
|
98
|
+
OTelAttribute.PARENT_WORKFLOW_RUN_ID: self.parent_workflow_run_id,
|
|
99
|
+
OTelAttribute.CHILD_WORKFLOW_INDEX: self.child_workflow_index,
|
|
100
|
+
OTelAttribute.CHILD_WORKFLOW_KEY: self.child_workflow_key,
|
|
101
|
+
OTelAttribute.ACTION_PAYLOAD: payload_str,
|
|
102
|
+
OTelAttribute.WORKFLOW_NAME: self.job_name,
|
|
103
|
+
OTelAttribute.ACTION_NAME: self.action_id,
|
|
104
|
+
OTelAttribute.GET_GROUP_KEY_RUN_ID: self.get_group_key_run_id,
|
|
105
|
+
OTelAttribute.WORKFLOW_ID: self.workflow_id,
|
|
106
|
+
OTelAttribute.WORKFLOW_VERSION_ID: self.workflow_version_id,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
f"hatchet.{k.value}": v
|
|
111
|
+
for k, v in attrs.items()
|
|
112
|
+
if v and k not in config.otel.excluded_attributes
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def key(self) -> ActionKey:
|
|
117
|
+
"""
|
|
118
|
+
This key is used to uniquely identify a single step run by its id + retry count.
|
|
119
|
+
It's used when storing references to a task, a context, etc. in a dictionary so that
|
|
120
|
+
we can look up those items in the dictionary by a unique key.
|
|
121
|
+
"""
|
|
122
|
+
if self.action_type == ActionType.START_GET_GROUP_KEY:
|
|
123
|
+
return f"{self.get_group_key_run_id}/{self.retry_count}"
|
|
124
|
+
else:
|
|
125
|
+
return f"{self.step_run_id}/{self.retry_count}"
|
|
@@ -2,11 +2,16 @@ import asyncio
|
|
|
2
2
|
from collections import Counter
|
|
3
3
|
from contextvars import ContextVar
|
|
4
4
|
|
|
5
|
+
from hatchet_sdk.runnables.action import ActionKey
|
|
6
|
+
|
|
5
7
|
ctx_workflow_run_id: ContextVar[str | None] = ContextVar(
|
|
6
8
|
"ctx_workflow_run_id", default=None
|
|
7
9
|
)
|
|
10
|
+
ctx_action_key: ContextVar[ActionKey | None] = ContextVar(
|
|
11
|
+
"ctx_action_key", default=None
|
|
12
|
+
)
|
|
8
13
|
ctx_step_run_id: ContextVar[str | None] = ContextVar("ctx_step_run_id", default=None)
|
|
9
14
|
ctx_worker_id: ContextVar[str | None] = ContextVar("ctx_worker_id", default=None)
|
|
10
15
|
|
|
11
|
-
workflow_spawn_indices = Counter[
|
|
16
|
+
workflow_spawn_indices = Counter[ActionKey]()
|
|
12
17
|
spawn_index_lock = asyncio.Lock()
|
|
@@ -10,9 +10,7 @@ import grpc
|
|
|
10
10
|
|
|
11
11
|
from hatchet_sdk.client import Client
|
|
12
12
|
from hatchet_sdk.clients.dispatcher.action_listener import (
|
|
13
|
-
Action,
|
|
14
13
|
ActionListener,
|
|
15
|
-
ActionType,
|
|
16
14
|
GetActionListenerRequest,
|
|
17
15
|
)
|
|
18
16
|
from hatchet_sdk.clients.dispatcher.dispatcher import DispatcherClient
|
|
@@ -23,7 +21,9 @@ from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
|
23
21
|
STEP_EVENT_TYPE_STARTED,
|
|
24
22
|
)
|
|
25
23
|
from hatchet_sdk.logger import logger
|
|
24
|
+
from hatchet_sdk.runnables.action import Action, ActionType
|
|
26
25
|
from hatchet_sdk.runnables.contextvars import (
|
|
26
|
+
ctx_action_key,
|
|
27
27
|
ctx_step_run_id,
|
|
28
28
|
ctx_worker_id,
|
|
29
29
|
ctx_workflow_run_id,
|
|
@@ -230,6 +230,7 @@ class WorkerActionListenerProcess:
|
|
|
230
230
|
ctx_step_run_id.set(action.step_run_id)
|
|
231
231
|
ctx_workflow_run_id.set(action.workflow_run_id)
|
|
232
232
|
ctx_worker_id.set(action.worker_id)
|
|
233
|
+
ctx_action_key.set(action.key)
|
|
233
234
|
|
|
234
235
|
# Process the action here
|
|
235
236
|
match action.action_type:
|
|
@@ -4,9 +4,9 @@ from multiprocessing import Queue
|
|
|
4
4
|
from typing import Any, Literal, TypeVar
|
|
5
5
|
|
|
6
6
|
from hatchet_sdk.client import Client
|
|
7
|
-
from hatchet_sdk.clients.dispatcher.action_listener import Action
|
|
8
7
|
from hatchet_sdk.config import ClientConfig
|
|
9
8
|
from hatchet_sdk.logger import logger
|
|
9
|
+
from hatchet_sdk.runnables.action import Action
|
|
10
10
|
from hatchet_sdk.runnables.task import Task
|
|
11
11
|
from hatchet_sdk.worker.action_listener_process import ActionEvent
|
|
12
12
|
from hatchet_sdk.worker.runner.runner import Runner
|
|
@@ -14,7 +14,6 @@ from pydantic import BaseModel
|
|
|
14
14
|
|
|
15
15
|
from hatchet_sdk.client import Client
|
|
16
16
|
from hatchet_sdk.clients.admin import AdminClient
|
|
17
|
-
from hatchet_sdk.clients.dispatcher.action_listener import Action, ActionKey, ActionType
|
|
18
17
|
from hatchet_sdk.clients.dispatcher.dispatcher import DispatcherClient
|
|
19
18
|
from hatchet_sdk.clients.events import EventClient
|
|
20
19
|
from hatchet_sdk.clients.listeners.durable_event_listener import DurableEventListener
|
|
@@ -34,7 +33,9 @@ from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
|
34
33
|
from hatchet_sdk.exceptions import NonRetryableException
|
|
35
34
|
from hatchet_sdk.features.runs import RunsClient
|
|
36
35
|
from hatchet_sdk.logger import logger
|
|
36
|
+
from hatchet_sdk.runnables.action import Action, ActionKey, ActionType
|
|
37
37
|
from hatchet_sdk.runnables.contextvars import (
|
|
38
|
+
ctx_action_key,
|
|
38
39
|
ctx_step_run_id,
|
|
39
40
|
ctx_worker_id,
|
|
40
41
|
ctx_workflow_run_id,
|
|
@@ -244,6 +245,7 @@ class Runner:
|
|
|
244
245
|
ctx_step_run_id.set(action.step_run_id)
|
|
245
246
|
ctx_workflow_run_id.set(action.workflow_run_id)
|
|
246
247
|
ctx_worker_id.set(action.worker_id)
|
|
248
|
+
ctx_action_key.set(action.key)
|
|
247
249
|
|
|
248
250
|
try:
|
|
249
251
|
if task.is_async_function:
|
|
@@ -388,9 +390,9 @@ class Runner:
|
|
|
388
390
|
|
|
389
391
|
## Once the step run completes, we need to remove the workflow spawn index
|
|
390
392
|
## so we don't leak memory
|
|
391
|
-
if action.
|
|
393
|
+
if action.key in workflow_spawn_indices:
|
|
392
394
|
async with spawn_index_lock:
|
|
393
|
-
workflow_spawn_indices.pop(action.
|
|
395
|
+
workflow_spawn_indices.pop(action.key)
|
|
394
396
|
|
|
395
397
|
## IMPORTANT: Keep this method's signature in sync with the wrapper in the OTel instrumentor
|
|
396
398
|
async def handle_start_group_key_run(self, action: Action) -> Exception | None:
|
hatchet_sdk/worker/worker.py
CHANGED
|
@@ -21,10 +21,10 @@ from prometheus_client import Gauge, generate_latest
|
|
|
21
21
|
from pydantic import BaseModel
|
|
22
22
|
|
|
23
23
|
from hatchet_sdk.client import Client
|
|
24
|
-
from hatchet_sdk.clients.dispatcher.action_listener import Action
|
|
25
24
|
from hatchet_sdk.config import ClientConfig
|
|
26
25
|
from hatchet_sdk.contracts.v1.workflows_pb2 import CreateWorkflowVersionRequest
|
|
27
26
|
from hatchet_sdk.logger import logger
|
|
27
|
+
from hatchet_sdk.runnables.action import Action
|
|
28
28
|
from hatchet_sdk.runnables.task import Task
|
|
29
29
|
from hatchet_sdk.runnables.workflow import BaseWorkflow
|
|
30
30
|
from hatchet_sdk.worker.action_listener_process import (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
hatchet_sdk/__init__.py,sha256=TW5T_It9W79Lfu-QaxMYBXMjYaXQdOpOS6bvYJm6VjQ,10198
|
|
2
2
|
hatchet_sdk/client.py,sha256=7ONBiE29OKQci3Qaz7U5e-WSxO_ohnWq8F-MSgzG2fU,2312
|
|
3
|
-
hatchet_sdk/clients/admin.py,sha256=
|
|
4
|
-
hatchet_sdk/clients/dispatcher/action_listener.py,sha256=
|
|
5
|
-
hatchet_sdk/clients/dispatcher/dispatcher.py,sha256=
|
|
3
|
+
hatchet_sdk/clients/admin.py,sha256=7Nxtn1KemJTjWs0yEaU7OyXIFQNFUF3NzLd2E_kJmMQ,16929
|
|
4
|
+
hatchet_sdk/clients/dispatcher/action_listener.py,sha256=XUDXye-HW4V30DBgjd_dmq7e03AS9eBxUJi1VsvfSqE,13837
|
|
5
|
+
hatchet_sdk/clients/dispatcher/dispatcher.py,sha256=LoxQEX5FS6v-qKRtOXoqsx3VlBUgFgTkbK58LU1eU3I,8176
|
|
6
6
|
hatchet_sdk/clients/event_ts.py,sha256=MudFszIb9IcPKQYvBTzcatPkcWEy3nxbAtEQ0_NYxMg,2094
|
|
7
7
|
hatchet_sdk/clients/events.py,sha256=6nfZogeEgXC0Tzq6RDCTVPcBvLBVBlEonlTo-ticfrc,7200
|
|
8
8
|
hatchet_sdk/clients/listeners/durable_event_listener.py,sha256=jpqnbZsuouWk3XaOIYL9apaGtVk65eKKq66eBP9klBs,4085
|
|
@@ -264,10 +264,11 @@ hatchet_sdk/hatchet.py,sha256=BVWSrKL6GCzarTNAte_r0iWsaBXntxNzrR-syR6qENI,22885
|
|
|
264
264
|
hatchet_sdk/labels.py,sha256=nATgxWE3lFxRTnfISEpoIRLGbMfAZsHF4lZTuG4Mfic,182
|
|
265
265
|
hatchet_sdk/logger.py,sha256=5uOr52T4mImSQm1QvWT8HvZFK5WfPNh3Y1cBQZRFgUQ,333
|
|
266
266
|
hatchet_sdk/metadata.py,sha256=XkRbhnghJJGCdVvF-uzyGBcNaTqpeQ3uiQvNNP1wyBc,107
|
|
267
|
-
hatchet_sdk/opentelemetry/instrumentor.py,sha256=
|
|
267
|
+
hatchet_sdk/opentelemetry/instrumentor.py,sha256=TMv2cks2O6026dZ0FGLcMGswCcKNjAFv4dSkRCnqxIw,14108
|
|
268
268
|
hatchet_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
269
269
|
hatchet_sdk/rate_limit.py,sha256=TwbCuggiZaWpYuo4mjVLlE-z1OfQ2mRBiVvCSaG3lv4,3919
|
|
270
|
-
hatchet_sdk/runnables/
|
|
270
|
+
hatchet_sdk/runnables/action.py,sha256=-CJ1b0SnLdXvWH9HZhhoAmKO68WJRGRn7Y7vcLNr1NU,4396
|
|
271
|
+
hatchet_sdk/runnables/contextvars.py,sha256=3hXlW03FNg2sEq8_A7wMPf_c7FTNuZqg5U9n2S2_hgg,580
|
|
271
272
|
hatchet_sdk/runnables/standalone.py,sha256=5MKyLIScJbTHc6N3lRJc6L2Y_9SZj_dQWLV9oA46kqk,15663
|
|
272
273
|
hatchet_sdk/runnables/task.py,sha256=AOpULMr3hqxn4W58Lh9oEvsXn_7PPB_c_sIqHRfQn5Q,7063
|
|
273
274
|
hatchet_sdk/runnables/types.py,sha256=5jf1c7_0QVUFh0bcXi4hIiaOdUiyhspU4LltoAFCwlM,3776
|
|
@@ -511,13 +512,13 @@ hatchet_sdk/v0/workflow.py,sha256=d4o425efk7J3JgLIge34MW_A3pzwnwSRtwEOgIqM2pc,93
|
|
|
511
512
|
hatchet_sdk/v0/workflow_run.py,sha256=jsEZprXshrSV7i_TtL5uoCL03D18zQ3NeJCq7mp97Dg,1752
|
|
512
513
|
hatchet_sdk/waits.py,sha256=L2xZUcmrQX-pTVXWv1W8suMoYU_eA0uowpollauQmOM,3893
|
|
513
514
|
hatchet_sdk/worker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
514
|
-
hatchet_sdk/worker/action_listener_process.py,sha256=
|
|
515
|
-
hatchet_sdk/worker/runner/run_loop_manager.py,sha256=
|
|
516
|
-
hatchet_sdk/worker/runner/runner.py,sha256=
|
|
515
|
+
hatchet_sdk/worker/action_listener_process.py,sha256=6WLtKLn8dRikzHLWwkHkoMuEf18WTKbxwNoT5WlPOBk,11874
|
|
516
|
+
hatchet_sdk/worker/runner/run_loop_manager.py,sha256=E3KD1r0-BBKUWlZJMDo9e2HHl4uAyvL8gX42-JCRLLc,3794
|
|
517
|
+
hatchet_sdk/worker/runner/runner.py,sha256=9Z3Ac6hRh5rjet7-BRtpcFARlhWvy6TNrdsdj61k_yk,18822
|
|
517
518
|
hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=nHRPSiDBqzhObM7i2X7t03OupVFnE7kQBdR2Ckgg-2w,2709
|
|
518
|
-
hatchet_sdk/worker/worker.py,sha256=
|
|
519
|
+
hatchet_sdk/worker/worker.py,sha256=SAucu3dg8lkKLbzb3noNWvClZ09lC5tuRcBkYZtIJ-0,16088
|
|
519
520
|
hatchet_sdk/workflow_run.py,sha256=ZwH0HLFGFVXz6jbiqSv4w0Om2XuR52Tzzw6LH4y65jQ,2765
|
|
520
|
-
hatchet_sdk-1.10.
|
|
521
|
-
hatchet_sdk-1.10.
|
|
522
|
-
hatchet_sdk-1.10.
|
|
523
|
-
hatchet_sdk-1.10.
|
|
521
|
+
hatchet_sdk-1.10.2.dist-info/METADATA,sha256=GDuCe5FAd2VC2rWKjkVr-QZbk9LSByY0r8YuQ13E1l8,3636
|
|
522
|
+
hatchet_sdk-1.10.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
523
|
+
hatchet_sdk-1.10.2.dist-info/entry_points.txt,sha256=Un_76pcLse-ZGBlwebhQpnTPyQrripeHW8J7qmEpGOk,1400
|
|
524
|
+
hatchet_sdk-1.10.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|