hatchet-sdk 1.6.2__py3-none-any.whl → 1.6.3__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/dispatcher/action_listener.py +9 -3
- hatchet_sdk/clients/event_ts.py +18 -7
- hatchet_sdk/clients/listeners/pooled_listener.py +9 -5
- hatchet_sdk/features/cron.py +58 -55
- hatchet_sdk/features/logs.py +16 -0
- hatchet_sdk/features/metrics.py +48 -0
- hatchet_sdk/features/rate_limits.py +24 -0
- hatchet_sdk/features/runs.py +143 -5
- hatchet_sdk/features/scheduled.py +51 -51
- hatchet_sdk/features/workers.py +40 -0
- hatchet_sdk/features/workflows.py +50 -0
- hatchet_sdk/hatchet.py +81 -108
- hatchet_sdk/opentelemetry/instrumentor.py +15 -17
- hatchet_sdk/runnables/standalone.py +111 -0
- hatchet_sdk/runnables/workflow.py +197 -76
- hatchet_sdk/v0/features/cron.py +3 -3
- hatchet_sdk/v0/features/scheduled.py +1 -1
- hatchet_sdk/v0/hatchet.py +3 -3
- hatchet_sdk/v0/opentelemetry/instrumentor.py +3 -6
- hatchet_sdk/worker/worker.py +3 -3
- {hatchet_sdk-1.6.2.dist-info → hatchet_sdk-1.6.3.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.6.2.dist-info → hatchet_sdk-1.6.3.dist-info}/RECORD +24 -24
- {hatchet_sdk-1.6.2.dist-info → hatchet_sdk-1.6.3.dist-info}/entry_points.txt +4 -0
- {hatchet_sdk-1.6.2.dist-info → hatchet_sdk-1.6.3.dist-info}/WHEEL +0 -0
hatchet_sdk/features/runs.py
CHANGED
|
@@ -89,6 +89,10 @@ class BulkCancelReplayOpts(BaseModel):
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
class RunsClient(BaseRestClient):
|
|
92
|
+
"""
|
|
93
|
+
The runs client is a client for interacting with task and workflow runs within Hatchet.
|
|
94
|
+
"""
|
|
95
|
+
|
|
92
96
|
def __init__(
|
|
93
97
|
self,
|
|
94
98
|
config: ClientConfig,
|
|
@@ -107,10 +111,22 @@ class RunsClient(BaseRestClient):
|
|
|
107
111
|
return TaskApi(client)
|
|
108
112
|
|
|
109
113
|
def get(self, workflow_run_id: str) -> V1WorkflowRunDetails:
|
|
114
|
+
"""
|
|
115
|
+
Get workflow run details for a given workflow run ID.
|
|
116
|
+
|
|
117
|
+
:param workflow_run_id: The ID of the workflow run to retrieve details for.
|
|
118
|
+
:return: Workflow run details for the specified workflow run ID.
|
|
119
|
+
"""
|
|
110
120
|
with self.client() as client:
|
|
111
121
|
return self._wra(client).v1_workflow_run_get(str(workflow_run_id))
|
|
112
122
|
|
|
113
123
|
async def aio_get(self, workflow_run_id: str) -> V1WorkflowRunDetails:
|
|
124
|
+
"""
|
|
125
|
+
Get workflow run details for a given workflow run ID.
|
|
126
|
+
|
|
127
|
+
:param workflow_run_id: The ID of the workflow run to retrieve details for.
|
|
128
|
+
:return: Workflow run details for the specified workflow run ID.
|
|
129
|
+
"""
|
|
114
130
|
return await asyncio.to_thread(self.get, workflow_run_id)
|
|
115
131
|
|
|
116
132
|
async def aio_list(
|
|
@@ -126,6 +142,22 @@ class RunsClient(BaseRestClient):
|
|
|
126
142
|
worker_id: str | None = None,
|
|
127
143
|
parent_task_external_id: str | None = None,
|
|
128
144
|
) -> V1TaskSummaryList:
|
|
145
|
+
"""
|
|
146
|
+
List task runs according to a set of filters.
|
|
147
|
+
|
|
148
|
+
:param since: The start time for filtering task runs.
|
|
149
|
+
:param only_tasks: Whether to only list task runs.
|
|
150
|
+
:param offset: The offset for pagination.
|
|
151
|
+
:param limit: The maximum number of task runs to return.
|
|
152
|
+
:param statuses: The statuses to filter task runs by.
|
|
153
|
+
:param until: The end time for filtering task runs.
|
|
154
|
+
:param additional_metadata: Additional metadata to filter task runs by.
|
|
155
|
+
:param workflow_ids: The workflow IDs to filter task runs by.
|
|
156
|
+
:param worker_id: The worker ID to filter task runs by.
|
|
157
|
+
:param parent_task_external_id: The parent task external ID to filter task runs by.
|
|
158
|
+
|
|
159
|
+
:return: A list of task runs matching the specified filters.
|
|
160
|
+
"""
|
|
129
161
|
return await asyncio.to_thread(
|
|
130
162
|
self.list,
|
|
131
163
|
since=since,
|
|
@@ -153,6 +185,22 @@ class RunsClient(BaseRestClient):
|
|
|
153
185
|
worker_id: str | None = None,
|
|
154
186
|
parent_task_external_id: str | None = None,
|
|
155
187
|
) -> V1TaskSummaryList:
|
|
188
|
+
"""
|
|
189
|
+
List task runs according to a set of filters.
|
|
190
|
+
|
|
191
|
+
:param since: The start time for filtering task runs.
|
|
192
|
+
:param only_tasks: Whether to only list task runs.
|
|
193
|
+
:param offset: The offset for pagination.
|
|
194
|
+
:param limit: The maximum number of task runs to return.
|
|
195
|
+
:param statuses: The statuses to filter task runs by.
|
|
196
|
+
:param until: The end time for filtering task runs.
|
|
197
|
+
:param additional_metadata: Additional metadata to filter task runs by.
|
|
198
|
+
:param workflow_ids: The workflow IDs to filter task runs by.
|
|
199
|
+
:param worker_id: The worker ID to filter task runs by.
|
|
200
|
+
:param parent_task_external_id: The parent task external ID to filter task runs by.
|
|
201
|
+
|
|
202
|
+
:return: A list of task runs matching the specified filters.
|
|
203
|
+
"""
|
|
156
204
|
with self.client() as client:
|
|
157
205
|
return self._wra(client).v1_workflow_run_list(
|
|
158
206
|
tenant=self.client_config.tenant_id,
|
|
@@ -177,6 +225,18 @@ class RunsClient(BaseRestClient):
|
|
|
177
225
|
additional_metadata: JSONSerializableMapping = {},
|
|
178
226
|
priority: int | None = None,
|
|
179
227
|
) -> V1WorkflowRunDetails:
|
|
228
|
+
"""
|
|
229
|
+
Trigger a new workflow run.
|
|
230
|
+
|
|
231
|
+
IMPORTANT: It's preferable to use `Workflow.run` (and similar) to trigger workflows if possible. This method is intended to be an escape hatch. For more details, see [the documentation](https://docs.hatchet.run/sdks/python/runnables#workflow).
|
|
232
|
+
|
|
233
|
+
:param workflow_name: The name of the workflow to trigger.
|
|
234
|
+
:param input: The input data for the workflow run.
|
|
235
|
+
:param additional_metadata: Additional metadata associated with the workflow run.
|
|
236
|
+
:param priority: The priority of the workflow run.
|
|
237
|
+
|
|
238
|
+
:return: The details of the triggered workflow run.
|
|
239
|
+
"""
|
|
180
240
|
with self.client() as client:
|
|
181
241
|
return self._wra(client).v1_workflow_run_create(
|
|
182
242
|
tenant=self.client_config.tenant_id,
|
|
@@ -195,17 +255,47 @@ class RunsClient(BaseRestClient):
|
|
|
195
255
|
additional_metadata: JSONSerializableMapping = {},
|
|
196
256
|
priority: int | None = None,
|
|
197
257
|
) -> V1WorkflowRunDetails:
|
|
258
|
+
"""
|
|
259
|
+
Trigger a new workflow run.
|
|
260
|
+
|
|
261
|
+
IMPORTANT: It's preferable to use `Workflow.run` (and similar) to trigger workflows if possible. This method is intended to be an escape hatch. For more details, see [the documentation](https://docs.hatchet.run/sdks/python/runnables#workflow).
|
|
262
|
+
|
|
263
|
+
:param workflow_name: The name of the workflow to trigger.
|
|
264
|
+
:param input: The input data for the workflow run.
|
|
265
|
+
:param additional_metadata: Additional metadata associated with the workflow run.
|
|
266
|
+
:param priority: The priority of the workflow run.
|
|
267
|
+
|
|
268
|
+
:return: The details of the triggered workflow run.
|
|
269
|
+
"""
|
|
198
270
|
return await asyncio.to_thread(
|
|
199
271
|
self.create, workflow_name, input, additional_metadata, priority
|
|
200
272
|
)
|
|
201
273
|
|
|
202
274
|
def replay(self, run_id: str) -> None:
|
|
275
|
+
"""
|
|
276
|
+
Replay a task or workflow run.
|
|
277
|
+
|
|
278
|
+
:param run_id: The external ID of the task or workflow run to replay.
|
|
279
|
+
:return: None
|
|
280
|
+
"""
|
|
203
281
|
self.bulk_replay(opts=BulkCancelReplayOpts(ids=[run_id]))
|
|
204
282
|
|
|
205
283
|
async def aio_replay(self, run_id: str) -> None:
|
|
284
|
+
"""
|
|
285
|
+
Replay a task or workflow run.
|
|
286
|
+
|
|
287
|
+
:param run_id: The external ID of the task or workflow run to replay.
|
|
288
|
+
:return: None
|
|
289
|
+
"""
|
|
206
290
|
return await asyncio.to_thread(self.replay, run_id)
|
|
207
291
|
|
|
208
292
|
def bulk_replay(self, opts: BulkCancelReplayOpts) -> None:
|
|
293
|
+
"""
|
|
294
|
+
Replay task or workflow runs in bulk, according to a set of filters.
|
|
295
|
+
|
|
296
|
+
:param opts: Options for bulk replay, including filters and IDs.
|
|
297
|
+
:return: None
|
|
298
|
+
"""
|
|
209
299
|
with self.client() as client:
|
|
210
300
|
self._ta(client).v1_task_replay(
|
|
211
301
|
tenant=self.client_config.tenant_id,
|
|
@@ -213,15 +303,39 @@ class RunsClient(BaseRestClient):
|
|
|
213
303
|
)
|
|
214
304
|
|
|
215
305
|
async def aio_bulk_replay(self, opts: BulkCancelReplayOpts) -> None:
|
|
306
|
+
"""
|
|
307
|
+
Replay task or workflow runs in bulk, according to a set of filters.
|
|
308
|
+
|
|
309
|
+
:param opts: Options for bulk replay, including filters and IDs.
|
|
310
|
+
:return: None
|
|
311
|
+
"""
|
|
216
312
|
return await asyncio.to_thread(self.bulk_replay, opts)
|
|
217
313
|
|
|
218
314
|
def cancel(self, run_id: str) -> None:
|
|
315
|
+
"""
|
|
316
|
+
Cancel a task or workflow run.
|
|
317
|
+
|
|
318
|
+
:param run_id: The external ID of the task or workflow run to cancel.
|
|
319
|
+
:return: None
|
|
320
|
+
"""
|
|
219
321
|
self.bulk_cancel(opts=BulkCancelReplayOpts(ids=[run_id]))
|
|
220
322
|
|
|
221
323
|
async def aio_cancel(self, run_id: str) -> None:
|
|
324
|
+
"""
|
|
325
|
+
Cancel a task or workflow run.
|
|
326
|
+
|
|
327
|
+
:param run_id: The external ID of the task or workflow run to cancel.
|
|
328
|
+
:return: None
|
|
329
|
+
"""
|
|
222
330
|
return await asyncio.to_thread(self.cancel, run_id)
|
|
223
331
|
|
|
224
332
|
def bulk_cancel(self, opts: BulkCancelReplayOpts) -> None:
|
|
333
|
+
"""
|
|
334
|
+
Cancel task or workflow runs in bulk, according to a set of filters.
|
|
335
|
+
|
|
336
|
+
:param opts: Options for bulk cancel, including filters and IDs.
|
|
337
|
+
:return: None
|
|
338
|
+
"""
|
|
225
339
|
with self.client() as client:
|
|
226
340
|
self._ta(client).v1_task_cancel(
|
|
227
341
|
tenant=self.client_config.tenant_id,
|
|
@@ -229,14 +343,43 @@ class RunsClient(BaseRestClient):
|
|
|
229
343
|
)
|
|
230
344
|
|
|
231
345
|
async def aio_bulk_cancel(self, opts: BulkCancelReplayOpts) -> None:
|
|
346
|
+
"""
|
|
347
|
+
Cancel task or workflow runs in bulk, according to a set of filters.
|
|
348
|
+
|
|
349
|
+
:param opts: Options for bulk cancel, including filters and IDs.
|
|
350
|
+
:return: None
|
|
351
|
+
"""
|
|
232
352
|
return await asyncio.to_thread(self.bulk_cancel, opts)
|
|
233
353
|
|
|
234
354
|
def get_result(self, run_id: str) -> JSONSerializableMapping:
|
|
355
|
+
"""
|
|
356
|
+
Get the result of a workflow run by its external ID.
|
|
357
|
+
|
|
358
|
+
:param run_id: The external ID of the workflow run to retrieve the result for.
|
|
359
|
+
:return: The result of the workflow run.
|
|
360
|
+
"""
|
|
235
361
|
details = self.get(run_id)
|
|
236
362
|
|
|
237
363
|
return details.run.output
|
|
238
364
|
|
|
365
|
+
async def aio_get_result(self, run_id: str) -> JSONSerializableMapping:
|
|
366
|
+
"""
|
|
367
|
+
Get the result of a workflow run by its external ID.
|
|
368
|
+
|
|
369
|
+
:param run_id: The external ID of the workflow run to retrieve the result for.
|
|
370
|
+
:return: The result of the workflow run.
|
|
371
|
+
"""
|
|
372
|
+
details = await asyncio.to_thread(self.get, run_id)
|
|
373
|
+
|
|
374
|
+
return details.run.output
|
|
375
|
+
|
|
239
376
|
def get_run_ref(self, workflow_run_id: str) -> "WorkflowRunRef":
|
|
377
|
+
"""
|
|
378
|
+
Get a reference to a workflow run.
|
|
379
|
+
|
|
380
|
+
:param workflow_run_id: The ID of the workflow run to get a reference to.
|
|
381
|
+
:return: A reference to the specified workflow run.
|
|
382
|
+
"""
|
|
240
383
|
from hatchet_sdk.workflow_run import WorkflowRunRef
|
|
241
384
|
|
|
242
385
|
return WorkflowRunRef(
|
|
@@ -245,8 +388,3 @@ class RunsClient(BaseRestClient):
|
|
|
245
388
|
workflow_run_listener=self.workflow_run_listener,
|
|
246
389
|
runs_client=self,
|
|
247
390
|
)
|
|
248
|
-
|
|
249
|
-
async def aio_get_result(self, run_id: str) -> JSONSerializableMapping:
|
|
250
|
-
details = await asyncio.to_thread(self.get, run_id)
|
|
251
|
-
|
|
252
|
-
return details.run.output
|
|
@@ -27,6 +27,10 @@ from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class ScheduledClient(BaseRestClient):
|
|
30
|
+
"""
|
|
31
|
+
The scheduled client is a client for managing scheduled workflows within Hatchet.
|
|
32
|
+
"""
|
|
33
|
+
|
|
30
34
|
def _wra(self, client: ApiClient) -> WorkflowRunApi:
|
|
31
35
|
return WorkflowRunApi(client)
|
|
32
36
|
|
|
@@ -41,16 +45,16 @@ class ScheduledClient(BaseRestClient):
|
|
|
41
45
|
additional_metadata: JSONSerializableMapping,
|
|
42
46
|
) -> ScheduledWorkflows:
|
|
43
47
|
"""
|
|
44
|
-
Creates a new scheduled workflow run
|
|
48
|
+
Creates a new scheduled workflow run.
|
|
49
|
+
|
|
50
|
+
IMPORTANT: It's preferable to use `Workflow.run` (and similar) to trigger workflows if possible. This method is intended to be an escape hatch. For more details, see [the documentation](https://docs.hatchet.run/sdks/python/runnables#workflow).
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
additional_metadata (JSONSerializableMapping): Additional metadata associated with the future run.
|
|
52
|
+
:param workflow_name: The name of the workflow to schedule.
|
|
53
|
+
:param trigger_at: The datetime when the run should be triggered.
|
|
54
|
+
:param input: The input data for the scheduled workflow.
|
|
55
|
+
:param additional_metadata: Additional metadata associated with the future run as a key-value pair.
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
ScheduledWorkflows: The created scheduled workflow instance.
|
|
57
|
+
:return: The created scheduled workflow instance.
|
|
54
58
|
"""
|
|
55
59
|
with self.client() as client:
|
|
56
60
|
return self._wra(client).scheduled_workflow_run_create(
|
|
@@ -71,16 +75,16 @@ class ScheduledClient(BaseRestClient):
|
|
|
71
75
|
additional_metadata: JSONSerializableMapping,
|
|
72
76
|
) -> ScheduledWorkflows:
|
|
73
77
|
"""
|
|
74
|
-
Creates a new scheduled workflow run
|
|
78
|
+
Creates a new scheduled workflow run.
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
workflow_name (str): The name of the scheduled workflow.
|
|
78
|
-
trigger_at (datetime.datetime): The datetime when the run should be triggered.
|
|
79
|
-
input (JSONSerializableMapping): The input data for the scheduled workflow.
|
|
80
|
-
additional_metadata (JSONSerializableMapping): Additional metadata associated with the future run as a key-value pair (e.g. {"key1": "value1", "key2": "value2"}).
|
|
80
|
+
IMPORTANT: It's preferable to use `Workflow.run` (and similar) to trigger workflows if possible. This method is intended to be an escape hatch. For more details, see [the documentation](https://docs.hatchet.run/sdks/python/runnables#workflow).
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
:param workflow_name: The name of the workflow to schedule.
|
|
83
|
+
:param trigger_at: The datetime when the run should be triggered.
|
|
84
|
+
:param input: The input data for the scheduled workflow.
|
|
85
|
+
:param additional_metadata: Additional metadata associated with the future run as a key-value pair.
|
|
86
|
+
|
|
87
|
+
:return: The created scheduled workflow instance.
|
|
84
88
|
"""
|
|
85
89
|
|
|
86
90
|
return await asyncio.to_thread(
|
|
@@ -93,10 +97,10 @@ class ScheduledClient(BaseRestClient):
|
|
|
93
97
|
|
|
94
98
|
def delete(self, scheduled_id: str) -> None:
|
|
95
99
|
"""
|
|
96
|
-
Deletes a scheduled workflow run.
|
|
100
|
+
Deletes a scheduled workflow run by its ID.
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
:param scheduled_id: The ID of the scheduled workflow run to delete.
|
|
103
|
+
:return: None
|
|
100
104
|
"""
|
|
101
105
|
with self.client() as client:
|
|
102
106
|
self._wa(client).workflow_scheduled_delete(
|
|
@@ -105,6 +109,12 @@ class ScheduledClient(BaseRestClient):
|
|
|
105
109
|
)
|
|
106
110
|
|
|
107
111
|
async def aio_delete(self, scheduled_id: str) -> None:
|
|
112
|
+
"""
|
|
113
|
+
Deletes a scheduled workflow run by its ID.
|
|
114
|
+
|
|
115
|
+
:param scheduled_id: The ID of the scheduled workflow run to delete.
|
|
116
|
+
:return: None
|
|
117
|
+
"""
|
|
108
118
|
await asyncio.to_thread(self.delete, scheduled_id)
|
|
109
119
|
|
|
110
120
|
async def aio_list(
|
|
@@ -121,18 +131,16 @@ class ScheduledClient(BaseRestClient):
|
|
|
121
131
|
"""
|
|
122
132
|
Retrieves a list of scheduled workflows based on provided filters.
|
|
123
133
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
order_by_direction (Optional[WorkflowRunOrderByDirection]): Direction to order the results.
|
|
134
|
+
:param offset: The offset to use in pagination.
|
|
135
|
+
:param limit: The maximum number of scheduled workflows to return.
|
|
136
|
+
:param workflow_id: The ID of the workflow to filter by.
|
|
137
|
+
:param parent_workflow_run_id: The ID of the parent workflow run to filter by.
|
|
138
|
+
:param statuses: A list of statuses to filter by.
|
|
139
|
+
:param additional_metadata: Additional metadata to filter by.
|
|
140
|
+
:param order_by_field: The field to order the results by.
|
|
141
|
+
:param order_by_direction: The direction to order the results by.
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
List[ScheduledWorkflows]: A list of scheduled workflows matching the criteria.
|
|
143
|
+
:return: A list of scheduled workflows matching the provided filters.
|
|
136
144
|
"""
|
|
137
145
|
return await asyncio.to_thread(
|
|
138
146
|
self.list,
|
|
@@ -160,18 +168,16 @@ class ScheduledClient(BaseRestClient):
|
|
|
160
168
|
"""
|
|
161
169
|
Retrieves a list of scheduled workflows based on provided filters.
|
|
162
170
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
order_by_direction (Optional[WorkflowRunOrderByDirection]): Direction to order the results.
|
|
171
|
+
:param offset: The offset to use in pagination.
|
|
172
|
+
:param limit: The maximum number of scheduled workflows to return.
|
|
173
|
+
:param workflow_id: The ID of the workflow to filter by.
|
|
174
|
+
:param parent_workflow_run_id: The ID of the parent workflow run to filter by.
|
|
175
|
+
:param statuses: A list of statuses to filter by.
|
|
176
|
+
:param additional_metadata: Additional metadata to filter by.
|
|
177
|
+
:param order_by_field: The field to order the results by.
|
|
178
|
+
:param order_by_direction: The direction to order the results by.
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
List[ScheduledWorkflows]: A list of scheduled workflows matching the criteria.
|
|
180
|
+
:return: A list of scheduled workflows matching the provided filters.
|
|
175
181
|
"""
|
|
176
182
|
with self.client() as client:
|
|
177
183
|
return self._wa(client).workflow_scheduled_list(
|
|
@@ -192,11 +198,8 @@ class ScheduledClient(BaseRestClient):
|
|
|
192
198
|
"""
|
|
193
199
|
Retrieves a specific scheduled workflow by scheduled run trigger ID.
|
|
194
200
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
Returns:
|
|
199
|
-
ScheduledWorkflows: The requested scheduled workflow instance.
|
|
201
|
+
:param scheduled_id: The scheduled workflow trigger ID to retrieve.
|
|
202
|
+
:return: The requested scheduled workflow instance.
|
|
200
203
|
"""
|
|
201
204
|
|
|
202
205
|
with self.client() as client:
|
|
@@ -209,10 +212,7 @@ class ScheduledClient(BaseRestClient):
|
|
|
209
212
|
"""
|
|
210
213
|
Retrieves a specific scheduled workflow by scheduled run trigger ID.
|
|
211
214
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Returns:
|
|
216
|
-
ScheduledWorkflows: The requested scheduled workflow instance.
|
|
215
|
+
:param scheduled_id: The scheduled workflow trigger ID to retrieve.
|
|
216
|
+
:return: The requested scheduled workflow instance.
|
|
217
217
|
"""
|
|
218
218
|
return await asyncio.to_thread(self.get, scheduled_id)
|
hatchet_sdk/features/workers.py
CHANGED
|
@@ -9,19 +9,40 @@ from hatchet_sdk.clients.v1.api_client import BaseRestClient
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class WorkersClient(BaseRestClient):
|
|
12
|
+
"""
|
|
13
|
+
The workers client is a client for managing workers programmatically within Hatchet.
|
|
14
|
+
"""
|
|
15
|
+
|
|
12
16
|
def _wa(self, client: ApiClient) -> WorkerApi:
|
|
13
17
|
return WorkerApi(client)
|
|
14
18
|
|
|
15
19
|
def get(self, worker_id: str) -> Worker:
|
|
20
|
+
"""
|
|
21
|
+
Get a worker by its ID.
|
|
22
|
+
|
|
23
|
+
:param worker_id: The ID of the worker to retrieve.
|
|
24
|
+
:return: The worker.
|
|
25
|
+
"""
|
|
16
26
|
with self.client() as client:
|
|
17
27
|
return self._wa(client).worker_get(worker_id)
|
|
18
28
|
|
|
19
29
|
async def aio_get(self, worker_id: str) -> Worker:
|
|
30
|
+
"""
|
|
31
|
+
Get a worker by its ID.
|
|
32
|
+
|
|
33
|
+
:param worker_id: The ID of the worker to retrieve.
|
|
34
|
+
:return: The worker.
|
|
35
|
+
"""
|
|
20
36
|
return await asyncio.to_thread(self.get, worker_id)
|
|
21
37
|
|
|
22
38
|
def list(
|
|
23
39
|
self,
|
|
24
40
|
) -> WorkerList:
|
|
41
|
+
"""
|
|
42
|
+
List all workers in the tenant determined by the client config.
|
|
43
|
+
|
|
44
|
+
:return: A list of workers.
|
|
45
|
+
"""
|
|
25
46
|
with self.client() as client:
|
|
26
47
|
return self._wa(client).worker_list(
|
|
27
48
|
tenant=self.client_config.tenant_id,
|
|
@@ -30,9 +51,21 @@ class WorkersClient(BaseRestClient):
|
|
|
30
51
|
async def aio_list(
|
|
31
52
|
self,
|
|
32
53
|
) -> WorkerList:
|
|
54
|
+
"""
|
|
55
|
+
List all workers in the tenant determined by the client config.
|
|
56
|
+
|
|
57
|
+
:return: A list of workers.
|
|
58
|
+
"""
|
|
33
59
|
return await asyncio.to_thread(self.list)
|
|
34
60
|
|
|
35
61
|
def update(self, worker_id: str, opts: UpdateWorkerRequest) -> Worker:
|
|
62
|
+
"""
|
|
63
|
+
Update a worker by its ID.
|
|
64
|
+
|
|
65
|
+
:param worker_id: The ID of the worker to update.
|
|
66
|
+
:param opts: The update options.
|
|
67
|
+
:return: The updated worker.
|
|
68
|
+
"""
|
|
36
69
|
with self.client() as client:
|
|
37
70
|
return self._wa(client).worker_update(
|
|
38
71
|
worker=worker_id,
|
|
@@ -40,4 +73,11 @@ class WorkersClient(BaseRestClient):
|
|
|
40
73
|
)
|
|
41
74
|
|
|
42
75
|
async def aio_update(self, worker_id: str, opts: UpdateWorkerRequest) -> Worker:
|
|
76
|
+
"""
|
|
77
|
+
Update a worker by its ID.
|
|
78
|
+
|
|
79
|
+
:param worker_id: The ID of the worker to update.
|
|
80
|
+
:param opts: The update options.
|
|
81
|
+
:return: The updated worker.
|
|
82
|
+
"""
|
|
43
83
|
return await asyncio.to_thread(self.update, worker_id, opts)
|
|
@@ -10,6 +10,12 @@ from hatchet_sdk.clients.v1.api_client import BaseRestClient
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class WorkflowsClient(BaseRestClient):
|
|
13
|
+
"""
|
|
14
|
+
The workflows client is a client for managing workflows programmatically within Hatchet.
|
|
15
|
+
|
|
16
|
+
Note that workflows are the declaration, _not_ the individual runs. If you're looking for runs, use the `RunsClient` instead.
|
|
17
|
+
"""
|
|
18
|
+
|
|
13
19
|
def _wra(self, client: ApiClient) -> WorkflowRunApi:
|
|
14
20
|
return WorkflowRunApi(client)
|
|
15
21
|
|
|
@@ -17,9 +23,21 @@ class WorkflowsClient(BaseRestClient):
|
|
|
17
23
|
return WorkflowApi(client)
|
|
18
24
|
|
|
19
25
|
async def aio_get(self, workflow_id: str) -> Workflow:
|
|
26
|
+
"""
|
|
27
|
+
Get a workflow by its ID.
|
|
28
|
+
|
|
29
|
+
:param workflow_id: The ID of the workflow to retrieve.
|
|
30
|
+
:return: The workflow.
|
|
31
|
+
"""
|
|
20
32
|
return await asyncio.to_thread(self.get, workflow_id)
|
|
21
33
|
|
|
22
34
|
def get(self, workflow_id: str) -> Workflow:
|
|
35
|
+
"""
|
|
36
|
+
Get a workflow by its ID.
|
|
37
|
+
|
|
38
|
+
:param workflow_id: The ID of the workflow to retrieve.
|
|
39
|
+
:return: The workflow.
|
|
40
|
+
"""
|
|
23
41
|
with self.client() as client:
|
|
24
42
|
return self._wa(client).workflow_get(workflow_id)
|
|
25
43
|
|
|
@@ -29,6 +47,15 @@ class WorkflowsClient(BaseRestClient):
|
|
|
29
47
|
limit: int | None = None,
|
|
30
48
|
offset: int | None = None,
|
|
31
49
|
) -> WorkflowList:
|
|
50
|
+
"""
|
|
51
|
+
List all workflows in the tenant determined by the client config that match optional filters.
|
|
52
|
+
|
|
53
|
+
:param workflow_name: The name of the workflow to filter by.
|
|
54
|
+
:param limit: The maximum number of items to return.
|
|
55
|
+
:param offset: The offset to start the list from.
|
|
56
|
+
|
|
57
|
+
:return: A list of workflows.
|
|
58
|
+
"""
|
|
32
59
|
with self.client() as client:
|
|
33
60
|
return self._wa(client).workflow_list(
|
|
34
61
|
tenant=self.client_config.tenant_id,
|
|
@@ -43,15 +70,38 @@ class WorkflowsClient(BaseRestClient):
|
|
|
43
70
|
limit: int | None = None,
|
|
44
71
|
offset: int | None = None,
|
|
45
72
|
) -> WorkflowList:
|
|
73
|
+
"""
|
|
74
|
+
List all workflows in the tenant determined by the client config that match optional filters.
|
|
75
|
+
|
|
76
|
+
:param workflow_name: The name of the workflow to filter by.
|
|
77
|
+
:param limit: The maximum number of items to return.
|
|
78
|
+
:param offset: The offset to start the list from.
|
|
79
|
+
|
|
80
|
+
:return: A list of workflows.
|
|
81
|
+
"""
|
|
46
82
|
return await asyncio.to_thread(self.list, workflow_name, limit, offset)
|
|
47
83
|
|
|
48
84
|
def get_version(
|
|
49
85
|
self, workflow_id: str, version: str | None = None
|
|
50
86
|
) -> WorkflowVersion:
|
|
87
|
+
"""
|
|
88
|
+
Get a workflow version by the workflow ID and an optional version.
|
|
89
|
+
|
|
90
|
+
:param workflow_id: The ID of the workflow to retrieve the version for.
|
|
91
|
+
:param version: The version of the workflow to retrieve. If None, the latest version is returned.
|
|
92
|
+
:return: The workflow version.
|
|
93
|
+
"""
|
|
51
94
|
with self.client() as client:
|
|
52
95
|
return self._wa(client).workflow_version_get(workflow_id, version)
|
|
53
96
|
|
|
54
97
|
async def aio_get_version(
|
|
55
98
|
self, workflow_id: str, version: str | None = None
|
|
56
99
|
) -> WorkflowVersion:
|
|
100
|
+
"""
|
|
101
|
+
Get a workflow version by the workflow ID and an optional version.
|
|
102
|
+
|
|
103
|
+
:param workflow_id: The ID of the workflow to retrieve the version for.
|
|
104
|
+
:param version: The version of the workflow to retrieve. If None, the latest version is returned.
|
|
105
|
+
:return: The workflow version.
|
|
106
|
+
"""
|
|
57
107
|
return await asyncio.to_thread(self.get_version, workflow_id, version)
|