hatchet-sdk 1.2.6__py3-none-any.whl → 1.3.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 +7 -5
- hatchet_sdk/client.py +14 -6
- hatchet_sdk/clients/admin.py +57 -15
- hatchet_sdk/clients/dispatcher/action_listener.py +2 -2
- hatchet_sdk/clients/dispatcher/dispatcher.py +20 -7
- hatchet_sdk/clients/event_ts.py +25 -5
- hatchet_sdk/clients/listeners/durable_event_listener.py +125 -0
- hatchet_sdk/clients/listeners/pooled_listener.py +255 -0
- hatchet_sdk/clients/listeners/workflow_listener.py +62 -0
- hatchet_sdk/clients/rest/api/api_token_api.py +24 -24
- hatchet_sdk/clients/rest/api/default_api.py +64 -64
- hatchet_sdk/clients/rest/api/event_api.py +64 -64
- hatchet_sdk/clients/rest/api/github_api.py +8 -8
- hatchet_sdk/clients/rest/api/healthcheck_api.py +16 -16
- hatchet_sdk/clients/rest/api/log_api.py +16 -16
- hatchet_sdk/clients/rest/api/metadata_api.py +24 -24
- hatchet_sdk/clients/rest/api/rate_limits_api.py +8 -8
- hatchet_sdk/clients/rest/api/slack_api.py +16 -16
- hatchet_sdk/clients/rest/api/sns_api.py +24 -24
- hatchet_sdk/clients/rest/api/step_run_api.py +56 -56
- hatchet_sdk/clients/rest/api/task_api.py +56 -56
- hatchet_sdk/clients/rest/api/tenant_api.py +128 -128
- hatchet_sdk/clients/rest/api/user_api.py +96 -96
- hatchet_sdk/clients/rest/api/worker_api.py +24 -24
- hatchet_sdk/clients/rest/api/workflow_api.py +144 -144
- hatchet_sdk/clients/rest/api/workflow_run_api.py +48 -48
- hatchet_sdk/clients/rest/api/workflow_runs_api.py +40 -40
- hatchet_sdk/clients/rest/api_client.py +5 -8
- hatchet_sdk/clients/rest/configuration.py +7 -3
- hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py +2 -2
- hatchet_sdk/clients/rest/models/v1_task_summary.py +5 -0
- hatchet_sdk/clients/rest/models/v1_workflow_run.py +5 -0
- hatchet_sdk/clients/rest/rest.py +160 -111
- hatchet_sdk/clients/v1/api_client.py +2 -2
- hatchet_sdk/context/context.py +22 -21
- hatchet_sdk/features/cron.py +41 -40
- hatchet_sdk/features/logs.py +7 -6
- hatchet_sdk/features/metrics.py +19 -18
- hatchet_sdk/features/runs.py +88 -68
- hatchet_sdk/features/scheduled.py +42 -42
- hatchet_sdk/features/workers.py +17 -16
- hatchet_sdk/features/workflows.py +15 -14
- hatchet_sdk/hatchet.py +1 -1
- hatchet_sdk/runnables/standalone.py +12 -9
- hatchet_sdk/runnables/task.py +66 -2
- hatchet_sdk/runnables/types.py +8 -0
- hatchet_sdk/runnables/workflow.py +26 -125
- hatchet_sdk/waits.py +8 -8
- hatchet_sdk/worker/runner/run_loop_manager.py +4 -4
- hatchet_sdk/worker/runner/runner.py +22 -11
- hatchet_sdk/worker/worker.py +29 -25
- hatchet_sdk/workflow_run.py +58 -9
- {hatchet_sdk-1.2.6.dist-info → hatchet_sdk-1.3.1.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.2.6.dist-info → hatchet_sdk-1.3.1.dist-info}/RECORD +57 -57
- hatchet_sdk/clients/durable_event_listener.py +0 -329
- hatchet_sdk/clients/workflow_listener.py +0 -288
- hatchet_sdk/utils/aio.py +0 -43
- /hatchet_sdk/clients/{run_event_listener.py → listeners/run_event_listener.py} +0 -0
- {hatchet_sdk-1.2.6.dist-info → hatchet_sdk-1.3.1.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.2.6.dist-info → hatchet_sdk-1.3.1.dist-info}/entry_points.txt +0 -0
hatchet_sdk/features/cron.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
1
3
|
from pydantic import BaseModel, Field, field_validator
|
|
2
4
|
|
|
3
5
|
from hatchet_sdk.clients.rest.api.workflow_api import WorkflowApi
|
|
@@ -18,7 +20,6 @@ from hatchet_sdk.clients.v1.api_client import (
|
|
|
18
20
|
BaseRestClient,
|
|
19
21
|
maybe_additional_metadata_to_kv,
|
|
20
22
|
)
|
|
21
|
-
from hatchet_sdk.utils.aio import run_async_from_sync
|
|
22
23
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
23
24
|
|
|
24
25
|
|
|
@@ -77,7 +78,7 @@ class CronClient(BaseRestClient):
|
|
|
77
78
|
def _wa(self, client: ApiClient) -> WorkflowApi:
|
|
78
79
|
return WorkflowApi(client)
|
|
79
80
|
|
|
80
|
-
|
|
81
|
+
def create(
|
|
81
82
|
self,
|
|
82
83
|
workflow_name: str,
|
|
83
84
|
cron_name: str,
|
|
@@ -102,8 +103,8 @@ class CronClient(BaseRestClient):
|
|
|
102
103
|
expression=expression, input=input, additional_metadata=additional_metadata
|
|
103
104
|
)
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
return
|
|
106
|
+
with self.client() as client:
|
|
107
|
+
return self._wra(client).cron_workflow_trigger_create(
|
|
107
108
|
tenant=self.client_config.tenant_id,
|
|
108
109
|
workflow=workflow_name,
|
|
109
110
|
create_cron_workflow_trigger_request=CreateCronWorkflowTriggerRequest(
|
|
@@ -114,7 +115,7 @@ class CronClient(BaseRestClient):
|
|
|
114
115
|
),
|
|
115
116
|
)
|
|
116
117
|
|
|
117
|
-
def
|
|
118
|
+
async def aio_create(
|
|
118
119
|
self,
|
|
119
120
|
workflow_name: str,
|
|
120
121
|
cron_name: str,
|
|
@@ -122,8 +123,8 @@ class CronClient(BaseRestClient):
|
|
|
122
123
|
input: JSONSerializableMapping,
|
|
123
124
|
additional_metadata: JSONSerializableMapping,
|
|
124
125
|
) -> CronWorkflows:
|
|
125
|
-
return
|
|
126
|
-
self.
|
|
126
|
+
return await asyncio.to_thread(
|
|
127
|
+
self.create,
|
|
127
128
|
workflow_name,
|
|
128
129
|
cron_name,
|
|
129
130
|
expression,
|
|
@@ -131,20 +132,20 @@ class CronClient(BaseRestClient):
|
|
|
131
132
|
additional_metadata,
|
|
132
133
|
)
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
def delete(self, cron_id: str) -> None:
|
|
135
136
|
"""
|
|
136
137
|
Asynchronously deletes a workflow cron trigger.
|
|
137
138
|
|
|
138
139
|
Args:
|
|
139
140
|
cron_id (str): The cron trigger ID or CronWorkflows instance to delete.
|
|
140
141
|
"""
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
with self.client() as client:
|
|
143
|
+
self._wa(client).workflow_cron_delete(
|
|
143
144
|
tenant=self.client_config.tenant_id, cron_workflow=str(cron_id)
|
|
144
145
|
)
|
|
145
146
|
|
|
146
|
-
def
|
|
147
|
-
return
|
|
147
|
+
async def aio_delete(self, cron_id: str) -> None:
|
|
148
|
+
return await asyncio.to_thread(self.delete, cron_id)
|
|
148
149
|
|
|
149
150
|
async def aio_list(
|
|
150
151
|
self,
|
|
@@ -156,7 +157,7 @@ class CronClient(BaseRestClient):
|
|
|
156
157
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
157
158
|
) -> CronWorkflowsList:
|
|
158
159
|
"""
|
|
159
|
-
|
|
160
|
+
Synchronously retrieves a list of all workflow cron triggers matching the criteria.
|
|
160
161
|
|
|
161
162
|
Args:
|
|
162
163
|
offset (int | None): The offset to start the list from.
|
|
@@ -169,18 +170,15 @@ class CronClient(BaseRestClient):
|
|
|
169
170
|
Returns:
|
|
170
171
|
CronWorkflowsList: A list of cron workflows.
|
|
171
172
|
"""
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
order_by_field=order_by_field,
|
|
182
|
-
order_by_direction=order_by_direction,
|
|
183
|
-
)
|
|
173
|
+
return await asyncio.to_thread(
|
|
174
|
+
self.list,
|
|
175
|
+
offset=offset,
|
|
176
|
+
limit=limit,
|
|
177
|
+
workflow_id=workflow_id,
|
|
178
|
+
additional_metadata=additional_metadata,
|
|
179
|
+
order_by_field=order_by_field,
|
|
180
|
+
order_by_direction=order_by_direction,
|
|
181
|
+
)
|
|
184
182
|
|
|
185
183
|
def list(
|
|
186
184
|
self,
|
|
@@ -192,7 +190,7 @@ class CronClient(BaseRestClient):
|
|
|
192
190
|
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
193
191
|
) -> CronWorkflowsList:
|
|
194
192
|
"""
|
|
195
|
-
|
|
193
|
+
Asynchronously retrieves a list of all workflow cron triggers matching the criteria.
|
|
196
194
|
|
|
197
195
|
Args:
|
|
198
196
|
offset (int | None): The offset to start the list from.
|
|
@@ -205,17 +203,20 @@ class CronClient(BaseRestClient):
|
|
|
205
203
|
Returns:
|
|
206
204
|
CronWorkflowsList: A list of cron workflows.
|
|
207
205
|
"""
|
|
208
|
-
|
|
209
|
-
self.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
with self.client() as client:
|
|
207
|
+
return self._wa(client).cron_workflow_list(
|
|
208
|
+
tenant=self.client_config.tenant_id,
|
|
209
|
+
offset=offset,
|
|
210
|
+
limit=limit,
|
|
211
|
+
workflow_id=workflow_id,
|
|
212
|
+
additional_metadata=maybe_additional_metadata_to_kv(
|
|
213
|
+
additional_metadata
|
|
214
|
+
),
|
|
215
|
+
order_by_field=order_by_field,
|
|
216
|
+
order_by_direction=order_by_direction,
|
|
217
|
+
)
|
|
217
218
|
|
|
218
|
-
|
|
219
|
+
def get(self, cron_id: str) -> CronWorkflows:
|
|
219
220
|
"""
|
|
220
221
|
Asynchronously retrieves a specific workflow cron trigger by ID.
|
|
221
222
|
|
|
@@ -225,12 +226,12 @@ class CronClient(BaseRestClient):
|
|
|
225
226
|
Returns:
|
|
226
227
|
CronWorkflows: The requested cron workflow instance.
|
|
227
228
|
"""
|
|
228
|
-
|
|
229
|
-
return
|
|
229
|
+
with self.client() as client:
|
|
230
|
+
return self._wa(client).workflow_cron_get(
|
|
230
231
|
tenant=self.client_config.tenant_id, cron_workflow=str(cron_id)
|
|
231
232
|
)
|
|
232
233
|
|
|
233
|
-
def
|
|
234
|
+
async def aio_get(self, cron_id: str) -> CronWorkflows:
|
|
234
235
|
"""
|
|
235
236
|
Synchronously retrieves a specific workflow cron trigger by ID.
|
|
236
237
|
|
|
@@ -240,4 +241,4 @@ class CronClient(BaseRestClient):
|
|
|
240
241
|
Returns:
|
|
241
242
|
CronWorkflows: The requested cron workflow instance.
|
|
242
243
|
"""
|
|
243
|
-
return
|
|
244
|
+
return await asyncio.to_thread(self.get, cron_id)
|
hatchet_sdk/features/logs.py
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
1
3
|
from hatchet_sdk.clients.rest.api.log_api import LogApi
|
|
2
4
|
from hatchet_sdk.clients.rest.api_client import ApiClient
|
|
3
5
|
from hatchet_sdk.clients.rest.models.v1_log_line_list import V1LogLineList
|
|
4
6
|
from hatchet_sdk.clients.v1.api_client import BaseRestClient
|
|
5
|
-
from hatchet_sdk.utils.aio import run_async_from_sync
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class LogsClient(BaseRestClient):
|
|
9
10
|
def _la(self, client: ApiClient) -> LogApi:
|
|
10
11
|
return LogApi(client)
|
|
11
12
|
|
|
12
|
-
async def aio_list(self, task_run_id: str) -> V1LogLineList:
|
|
13
|
-
async with self.client() as client:
|
|
14
|
-
return await self._la(client).v1_log_line_list(task=task_run_id)
|
|
15
|
-
|
|
16
13
|
def list(self, task_run_id: str) -> V1LogLineList:
|
|
17
|
-
|
|
14
|
+
with self.client() as client:
|
|
15
|
+
return self._la(client).v1_log_line_list(task=task_run_id)
|
|
16
|
+
|
|
17
|
+
async def aio_list(self, task_run_id: str) -> V1LogLineList:
|
|
18
|
+
return await asyncio.to_thread(self.list, task_run_id)
|
hatchet_sdk/features/metrics.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
1
3
|
from hatchet_sdk.clients.rest.api.tenant_api import TenantApi
|
|
2
4
|
from hatchet_sdk.clients.rest.api.workflow_api import WorkflowApi
|
|
3
5
|
from hatchet_sdk.clients.rest.api_client import ApiClient
|
|
@@ -11,7 +13,6 @@ from hatchet_sdk.clients.v1.api_client import (
|
|
|
11
13
|
BaseRestClient,
|
|
12
14
|
maybe_additional_metadata_to_kv,
|
|
13
15
|
)
|
|
14
|
-
from hatchet_sdk.utils.aio import run_async_from_sync
|
|
15
16
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
16
17
|
|
|
17
18
|
|
|
@@ -22,34 +23,34 @@ class MetricsClient(BaseRestClient):
|
|
|
22
23
|
def _ta(self, client: ApiClient) -> TenantApi:
|
|
23
24
|
return TenantApi(client)
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
def get_workflow_metrics(
|
|
26
27
|
self,
|
|
27
28
|
workflow_id: str,
|
|
28
29
|
status: WorkflowRunStatus | None = None,
|
|
29
30
|
group_key: str | None = None,
|
|
30
31
|
) -> WorkflowMetrics:
|
|
31
|
-
|
|
32
|
-
return
|
|
32
|
+
with self.client() as client:
|
|
33
|
+
return self._wa(client).workflow_get_metrics(
|
|
33
34
|
workflow=workflow_id, status=status, group_key=group_key
|
|
34
35
|
)
|
|
35
36
|
|
|
36
|
-
def
|
|
37
|
+
async def aio_get_workflow_metrics(
|
|
37
38
|
self,
|
|
38
39
|
workflow_id: str,
|
|
39
40
|
status: WorkflowRunStatus | None = None,
|
|
40
41
|
group_key: str | None = None,
|
|
41
42
|
) -> WorkflowMetrics:
|
|
42
|
-
return
|
|
43
|
-
self.
|
|
43
|
+
return await asyncio.to_thread(
|
|
44
|
+
self.get_workflow_metrics, workflow_id, status, group_key
|
|
44
45
|
)
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
def get_queue_metrics(
|
|
47
48
|
self,
|
|
48
49
|
workflow_ids: list[str] | None = None,
|
|
49
50
|
additional_metadata: JSONSerializableMapping | None = None,
|
|
50
51
|
) -> TenantQueueMetrics:
|
|
51
|
-
|
|
52
|
-
return
|
|
52
|
+
with self.client() as client:
|
|
53
|
+
return self._wa(client).tenant_get_queue_metrics(
|
|
53
54
|
tenant=self.client_config.tenant_id,
|
|
54
55
|
workflows=workflow_ids,
|
|
55
56
|
additional_metadata=maybe_additional_metadata_to_kv(
|
|
@@ -57,20 +58,20 @@ class MetricsClient(BaseRestClient):
|
|
|
57
58
|
),
|
|
58
59
|
)
|
|
59
60
|
|
|
60
|
-
def
|
|
61
|
+
async def aio_get_queue_metrics(
|
|
61
62
|
self,
|
|
62
63
|
workflow_ids: list[str] | None = None,
|
|
63
64
|
additional_metadata: JSONSerializableMapping | None = None,
|
|
64
65
|
) -> TenantQueueMetrics:
|
|
65
|
-
return
|
|
66
|
-
self.
|
|
66
|
+
return await asyncio.to_thread(
|
|
67
|
+
self.get_queue_metrics, workflow_ids, additional_metadata
|
|
67
68
|
)
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
return
|
|
70
|
+
def get_task_metrics(self) -> TenantStepRunQueueMetrics:
|
|
71
|
+
with self.client() as client:
|
|
72
|
+
return self._ta(client).tenant_get_step_run_queue_metrics(
|
|
72
73
|
tenant=self.client_config.tenant_id
|
|
73
74
|
)
|
|
74
75
|
|
|
75
|
-
def
|
|
76
|
-
return
|
|
76
|
+
async def aio_get_task_metrics(self) -> TenantStepRunQueueMetrics:
|
|
77
|
+
return await asyncio.to_thread(self.get_task_metrics)
|
hatchet_sdk/features/runs.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
from datetime import datetime, timedelta
|
|
2
|
-
from typing import Literal, overload
|
|
3
|
+
from typing import TYPE_CHECKING, Literal, overload
|
|
3
4
|
|
|
4
5
|
from pydantic import BaseModel, model_validator
|
|
5
6
|
|
|
7
|
+
from hatchet_sdk.clients.listeners.run_event_listener import RunEventListenerClient
|
|
8
|
+
from hatchet_sdk.clients.listeners.workflow_listener import PooledWorkflowRunListener
|
|
6
9
|
from hatchet_sdk.clients.rest.api.task_api import TaskApi
|
|
7
10
|
from hatchet_sdk.clients.rest.api.workflow_runs_api import WorkflowRunsApi
|
|
8
11
|
from hatchet_sdk.clients.rest.api_client import ApiClient
|
|
@@ -19,9 +22,11 @@ from hatchet_sdk.clients.v1.api_client import (
|
|
|
19
22
|
BaseRestClient,
|
|
20
23
|
maybe_additional_metadata_to_kv,
|
|
21
24
|
)
|
|
22
|
-
from hatchet_sdk.
|
|
25
|
+
from hatchet_sdk.config import ClientConfig
|
|
23
26
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
24
|
-
|
|
27
|
+
|
|
28
|
+
if TYPE_CHECKING:
|
|
29
|
+
from hatchet_sdk.workflow_run import WorkflowRunRef
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
class RunFilter(BaseModel):
|
|
@@ -84,18 +89,29 @@ class BulkCancelReplayOpts(BaseModel):
|
|
|
84
89
|
|
|
85
90
|
|
|
86
91
|
class RunsClient(BaseRestClient):
|
|
92
|
+
def __init__(
|
|
93
|
+
self,
|
|
94
|
+
config: ClientConfig,
|
|
95
|
+
workflow_run_listener: PooledWorkflowRunListener,
|
|
96
|
+
workflow_run_event_listener: RunEventListenerClient,
|
|
97
|
+
) -> None:
|
|
98
|
+
super().__init__(config)
|
|
99
|
+
|
|
100
|
+
self.workflow_run_listener = workflow_run_listener
|
|
101
|
+
self.workflow_run_event_listener = workflow_run_event_listener
|
|
102
|
+
|
|
87
103
|
def _wra(self, client: ApiClient) -> WorkflowRunsApi:
|
|
88
104
|
return WorkflowRunsApi(client)
|
|
89
105
|
|
|
90
106
|
def _ta(self, client: ApiClient) -> TaskApi:
|
|
91
107
|
return TaskApi(client)
|
|
92
108
|
|
|
93
|
-
async def aio_get(self, workflow_run_id: str) -> V1WorkflowRunDetails:
|
|
94
|
-
async with self.client() as client:
|
|
95
|
-
return await self._wra(client).v1_workflow_run_get(str(workflow_run_id))
|
|
96
|
-
|
|
97
109
|
def get(self, workflow_run_id: str) -> V1WorkflowRunDetails:
|
|
98
|
-
|
|
110
|
+
with self.client() as client:
|
|
111
|
+
return self._wra(client).v1_workflow_run_get(str(workflow_run_id))
|
|
112
|
+
|
|
113
|
+
async def aio_get(self, workflow_run_id: str) -> V1WorkflowRunDetails:
|
|
114
|
+
return await asyncio.to_thread(self.get, workflow_run_id)
|
|
99
115
|
|
|
100
116
|
async def aio_list(
|
|
101
117
|
self,
|
|
@@ -110,22 +126,19 @@ class RunsClient(BaseRestClient):
|
|
|
110
126
|
worker_id: str | None = None,
|
|
111
127
|
parent_task_external_id: str | None = None,
|
|
112
128
|
) -> V1TaskSummaryList:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
worker_id=worker_id,
|
|
127
|
-
parent_task_external_id=parent_task_external_id,
|
|
128
|
-
)
|
|
129
|
+
return await asyncio.to_thread(
|
|
130
|
+
self.list,
|
|
131
|
+
since=since,
|
|
132
|
+
only_tasks=only_tasks,
|
|
133
|
+
offset=offset,
|
|
134
|
+
limit=limit,
|
|
135
|
+
statuses=statuses,
|
|
136
|
+
until=until,
|
|
137
|
+
additional_metadata=additional_metadata,
|
|
138
|
+
workflow_ids=workflow_ids,
|
|
139
|
+
worker_id=worker_id,
|
|
140
|
+
parent_task_external_id=parent_task_external_id,
|
|
141
|
+
)
|
|
129
142
|
|
|
130
143
|
def list(
|
|
131
144
|
self,
|
|
@@ -140,28 +153,31 @@ class RunsClient(BaseRestClient):
|
|
|
140
153
|
worker_id: str | None = None,
|
|
141
154
|
parent_task_external_id: str | None = None,
|
|
142
155
|
) -> V1TaskSummaryList:
|
|
143
|
-
|
|
144
|
-
self.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
with self.client() as client:
|
|
157
|
+
return self._wra(client).v1_workflow_run_list(
|
|
158
|
+
tenant=self.client_config.tenant_id,
|
|
159
|
+
since=since,
|
|
160
|
+
only_tasks=only_tasks,
|
|
161
|
+
offset=offset,
|
|
162
|
+
limit=limit,
|
|
163
|
+
statuses=statuses,
|
|
164
|
+
until=until,
|
|
165
|
+
additional_metadata=maybe_additional_metadata_to_kv(
|
|
166
|
+
additional_metadata
|
|
167
|
+
),
|
|
168
|
+
workflow_ids=workflow_ids,
|
|
169
|
+
worker_id=worker_id,
|
|
170
|
+
parent_task_external_id=parent_task_external_id,
|
|
171
|
+
)
|
|
156
172
|
|
|
157
|
-
|
|
173
|
+
def create(
|
|
158
174
|
self,
|
|
159
175
|
workflow_name: str,
|
|
160
176
|
input: JSONSerializableMapping,
|
|
161
177
|
additional_metadata: JSONSerializableMapping = {},
|
|
162
178
|
) -> V1WorkflowRunDetails:
|
|
163
|
-
|
|
164
|
-
return
|
|
179
|
+
with self.client() as client:
|
|
180
|
+
return self._wra(client).v1_workflow_run_create(
|
|
165
181
|
tenant=self.client_config.tenant_id,
|
|
166
182
|
v1_trigger_workflow_run_request=V1TriggerWorkflowRunRequest(
|
|
167
183
|
workflowName=workflow_name,
|
|
@@ -170,60 +186,64 @@ class RunsClient(BaseRestClient):
|
|
|
170
186
|
),
|
|
171
187
|
)
|
|
172
188
|
|
|
173
|
-
def
|
|
189
|
+
async def aio_create(
|
|
174
190
|
self,
|
|
175
191
|
workflow_name: str,
|
|
176
192
|
input: JSONSerializableMapping,
|
|
177
193
|
additional_metadata: JSONSerializableMapping = {},
|
|
178
194
|
) -> V1WorkflowRunDetails:
|
|
179
|
-
return
|
|
180
|
-
self.
|
|
195
|
+
return await asyncio.to_thread(
|
|
196
|
+
self.create, workflow_name, input, additional_metadata
|
|
181
197
|
)
|
|
182
198
|
|
|
183
|
-
async def aio_replay(self, run_id: str) -> None:
|
|
184
|
-
await self.aio_bulk_replay(opts=BulkCancelReplayOpts(ids=[run_id]))
|
|
185
|
-
|
|
186
199
|
def replay(self, run_id: str) -> None:
|
|
187
|
-
|
|
200
|
+
self.bulk_replay(opts=BulkCancelReplayOpts(ids=[run_id]))
|
|
188
201
|
|
|
189
|
-
async def
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
async def aio_replay(self, run_id: str) -> None:
|
|
203
|
+
return await asyncio.to_thread(self.replay, run_id)
|
|
204
|
+
|
|
205
|
+
def bulk_replay(self, opts: BulkCancelReplayOpts) -> None:
|
|
206
|
+
with self.client() as client:
|
|
207
|
+
self._ta(client).v1_task_replay(
|
|
192
208
|
tenant=self.client_config.tenant_id,
|
|
193
209
|
v1_replay_task_request=opts.to_request("replay"),
|
|
194
210
|
)
|
|
195
211
|
|
|
196
|
-
def
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
async def aio_cancel(self, run_id: str) -> None:
|
|
200
|
-
await self.aio_bulk_cancel(opts=BulkCancelReplayOpts(ids=[run_id]))
|
|
212
|
+
async def aio_bulk_replay(self, opts: BulkCancelReplayOpts) -> None:
|
|
213
|
+
return await asyncio.to_thread(self.bulk_replay, opts)
|
|
201
214
|
|
|
202
215
|
def cancel(self, run_id: str) -> None:
|
|
203
|
-
|
|
216
|
+
self.bulk_cancel(opts=BulkCancelReplayOpts(ids=[run_id]))
|
|
204
217
|
|
|
205
|
-
async def
|
|
206
|
-
|
|
207
|
-
|
|
218
|
+
async def aio_cancel(self, run_id: str) -> None:
|
|
219
|
+
return await asyncio.to_thread(self.cancel, run_id)
|
|
220
|
+
|
|
221
|
+
def bulk_cancel(self, opts: BulkCancelReplayOpts) -> None:
|
|
222
|
+
with self.client() as client:
|
|
223
|
+
self._ta(client).v1_task_cancel(
|
|
208
224
|
tenant=self.client_config.tenant_id,
|
|
209
225
|
v1_cancel_task_request=opts.to_request("cancel"),
|
|
210
226
|
)
|
|
211
227
|
|
|
212
|
-
def
|
|
213
|
-
return
|
|
214
|
-
|
|
215
|
-
async def aio_get_result(self, run_id: str) -> JSONSerializableMapping:
|
|
216
|
-
details = await self.aio_get(run_id)
|
|
217
|
-
|
|
218
|
-
return details.run.output
|
|
228
|
+
async def aio_bulk_cancel(self, opts: BulkCancelReplayOpts) -> None:
|
|
229
|
+
return await asyncio.to_thread(self.bulk_cancel, opts)
|
|
219
230
|
|
|
220
231
|
def get_result(self, run_id: str) -> JSONSerializableMapping:
|
|
221
232
|
details = self.get(run_id)
|
|
222
233
|
|
|
223
234
|
return details.run.output
|
|
224
235
|
|
|
225
|
-
def get_run_ref(self, workflow_run_id: str) -> WorkflowRunRef:
|
|
236
|
+
def get_run_ref(self, workflow_run_id: str) -> "WorkflowRunRef":
|
|
237
|
+
from hatchet_sdk.workflow_run import WorkflowRunRef
|
|
238
|
+
|
|
226
239
|
return WorkflowRunRef(
|
|
227
240
|
workflow_run_id=workflow_run_id,
|
|
228
|
-
|
|
241
|
+
workflow_run_event_listener=self.workflow_run_event_listener,
|
|
242
|
+
workflow_run_listener=self.workflow_run_listener,
|
|
243
|
+
runs_client=self,
|
|
229
244
|
)
|
|
245
|
+
|
|
246
|
+
async def aio_get_result(self, run_id: str) -> JSONSerializableMapping:
|
|
247
|
+
details = await asyncio.to_thread(self.get, run_id)
|
|
248
|
+
|
|
249
|
+
return details.run.output
|