hatchet-sdk 1.0.0__py3-none-any.whl → 1.0.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.

Files changed (73) hide show
  1. hatchet_sdk/__init__.py +32 -16
  2. hatchet_sdk/client.py +25 -63
  3. hatchet_sdk/clients/admin.py +203 -142
  4. hatchet_sdk/clients/dispatcher/action_listener.py +42 -42
  5. hatchet_sdk/clients/dispatcher/dispatcher.py +18 -16
  6. hatchet_sdk/clients/durable_event_listener.py +327 -0
  7. hatchet_sdk/clients/rest/__init__.py +12 -1
  8. hatchet_sdk/clients/rest/api/log_api.py +258 -0
  9. hatchet_sdk/clients/rest/api/task_api.py +32 -6
  10. hatchet_sdk/clients/rest/api/workflow_runs_api.py +626 -0
  11. hatchet_sdk/clients/rest/models/__init__.py +12 -1
  12. hatchet_sdk/clients/rest/models/v1_log_line.py +94 -0
  13. hatchet_sdk/clients/rest/models/v1_log_line_level.py +39 -0
  14. hatchet_sdk/clients/rest/models/v1_log_line_list.py +110 -0
  15. hatchet_sdk/clients/rest/models/v1_task_summary.py +80 -64
  16. hatchet_sdk/clients/rest/models/v1_trigger_workflow_run_request.py +95 -0
  17. hatchet_sdk/clients/rest/models/v1_workflow_run_display_name.py +98 -0
  18. hatchet_sdk/clients/rest/models/v1_workflow_run_display_name_list.py +114 -0
  19. hatchet_sdk/clients/rest/models/workflow_run_shape_item_for_workflow_run_details.py +9 -4
  20. hatchet_sdk/clients/rest/models/workflow_runs_metrics.py +5 -1
  21. hatchet_sdk/clients/run_event_listener.py +0 -1
  22. hatchet_sdk/clients/v1/api_client.py +81 -0
  23. hatchet_sdk/context/context.py +86 -159
  24. hatchet_sdk/contracts/dispatcher_pb2_grpc.py +1 -1
  25. hatchet_sdk/contracts/events_pb2.py +2 -2
  26. hatchet_sdk/contracts/events_pb2_grpc.py +1 -1
  27. hatchet_sdk/contracts/v1/dispatcher_pb2.py +36 -0
  28. hatchet_sdk/contracts/v1/dispatcher_pb2.pyi +38 -0
  29. hatchet_sdk/contracts/v1/dispatcher_pb2_grpc.py +145 -0
  30. hatchet_sdk/contracts/v1/shared/condition_pb2.py +39 -0
  31. hatchet_sdk/contracts/v1/shared/condition_pb2.pyi +72 -0
  32. hatchet_sdk/contracts/v1/shared/condition_pb2_grpc.py +29 -0
  33. hatchet_sdk/contracts/v1/workflows_pb2.py +67 -0
  34. hatchet_sdk/contracts/v1/workflows_pb2.pyi +228 -0
  35. hatchet_sdk/contracts/v1/workflows_pb2_grpc.py +234 -0
  36. hatchet_sdk/contracts/workflows_pb2_grpc.py +1 -1
  37. hatchet_sdk/features/cron.py +91 -121
  38. hatchet_sdk/features/logs.py +16 -0
  39. hatchet_sdk/features/metrics.py +75 -0
  40. hatchet_sdk/features/rate_limits.py +45 -0
  41. hatchet_sdk/features/runs.py +221 -0
  42. hatchet_sdk/features/scheduled.py +114 -131
  43. hatchet_sdk/features/workers.py +41 -0
  44. hatchet_sdk/features/workflows.py +55 -0
  45. hatchet_sdk/hatchet.py +463 -165
  46. hatchet_sdk/opentelemetry/instrumentor.py +8 -13
  47. hatchet_sdk/rate_limit.py +33 -39
  48. hatchet_sdk/runnables/contextvars.py +12 -0
  49. hatchet_sdk/runnables/standalone.py +192 -0
  50. hatchet_sdk/runnables/task.py +144 -0
  51. hatchet_sdk/runnables/types.py +138 -0
  52. hatchet_sdk/runnables/workflow.py +771 -0
  53. hatchet_sdk/utils/aio_utils.py +0 -79
  54. hatchet_sdk/utils/proto_enums.py +0 -7
  55. hatchet_sdk/utils/timedelta_to_expression.py +23 -0
  56. hatchet_sdk/utils/typing.py +2 -2
  57. hatchet_sdk/v0/clients/rest_client.py +9 -0
  58. hatchet_sdk/v0/worker/action_listener_process.py +18 -2
  59. hatchet_sdk/waits.py +120 -0
  60. hatchet_sdk/worker/action_listener_process.py +64 -30
  61. hatchet_sdk/worker/runner/run_loop_manager.py +35 -26
  62. hatchet_sdk/worker/runner/runner.py +72 -55
  63. hatchet_sdk/worker/runner/utils/capture_logs.py +3 -11
  64. hatchet_sdk/worker/worker.py +155 -118
  65. hatchet_sdk/workflow_run.py +4 -5
  66. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/METADATA +1 -2
  67. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/RECORD +69 -43
  68. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/entry_points.txt +2 -0
  69. hatchet_sdk/clients/rest_client.py +0 -636
  70. hatchet_sdk/semver.py +0 -30
  71. hatchet_sdk/worker/runner/utils/error_with_traceback.py +0 -6
  72. hatchet_sdk/workflow.py +0 -527
  73. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/WHEEL +0 -0
@@ -1,636 +0,0 @@
1
- import asyncio
2
- import atexit
3
- import datetime
4
- import threading
5
- from typing import Coroutine, TypeVar
6
-
7
- from pydantic import StrictInt
8
-
9
- from hatchet_sdk.clients.rest.api.event_api import EventApi
10
- from hatchet_sdk.clients.rest.api.log_api import LogApi
11
- from hatchet_sdk.clients.rest.api.step_run_api import StepRunApi
12
- from hatchet_sdk.clients.rest.api.workflow_api import WorkflowApi
13
- from hatchet_sdk.clients.rest.api.workflow_run_api import WorkflowRunApi
14
- from hatchet_sdk.clients.rest.api_client import ApiClient
15
- from hatchet_sdk.clients.rest.configuration import Configuration
16
- from hatchet_sdk.clients.rest.models.create_cron_workflow_trigger_request import (
17
- CreateCronWorkflowTriggerRequest,
18
- )
19
- from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows
20
- from hatchet_sdk.clients.rest.models.cron_workflows_list import CronWorkflowsList
21
- from hatchet_sdk.clients.rest.models.cron_workflows_order_by_field import (
22
- CronWorkflowsOrderByField,
23
- )
24
- from hatchet_sdk.clients.rest.models.event_list import EventList
25
- from hatchet_sdk.clients.rest.models.event_order_by_direction import (
26
- EventOrderByDirection,
27
- )
28
- from hatchet_sdk.clients.rest.models.event_order_by_field import EventOrderByField
29
- from hatchet_sdk.clients.rest.models.event_update_cancel200_response import (
30
- EventUpdateCancel200Response,
31
- )
32
- from hatchet_sdk.clients.rest.models.log_line_level import LogLineLevel
33
- from hatchet_sdk.clients.rest.models.log_line_list import LogLineList
34
- from hatchet_sdk.clients.rest.models.log_line_order_by_direction import (
35
- LogLineOrderByDirection,
36
- )
37
- from hatchet_sdk.clients.rest.models.log_line_order_by_field import LogLineOrderByField
38
- from hatchet_sdk.clients.rest.models.replay_event_request import ReplayEventRequest
39
- from hatchet_sdk.clients.rest.models.replay_workflow_runs_request import (
40
- ReplayWorkflowRunsRequest,
41
- )
42
- from hatchet_sdk.clients.rest.models.replay_workflow_runs_response import (
43
- ReplayWorkflowRunsResponse,
44
- )
45
- from hatchet_sdk.clients.rest.models.schedule_workflow_run_request import (
46
- ScheduleWorkflowRunRequest,
47
- )
48
- from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows
49
- from hatchet_sdk.clients.rest.models.scheduled_workflows_list import (
50
- ScheduledWorkflowsList,
51
- )
52
- from hatchet_sdk.clients.rest.models.scheduled_workflows_order_by_field import (
53
- ScheduledWorkflowsOrderByField,
54
- )
55
- from hatchet_sdk.clients.rest.models.trigger_workflow_run_request import (
56
- TriggerWorkflowRunRequest,
57
- )
58
- from hatchet_sdk.clients.rest.models.workflow import Workflow
59
- from hatchet_sdk.clients.rest.models.workflow_kind import WorkflowKind
60
- from hatchet_sdk.clients.rest.models.workflow_list import WorkflowList
61
- from hatchet_sdk.clients.rest.models.workflow_run import WorkflowRun
62
- from hatchet_sdk.clients.rest.models.workflow_run_list import WorkflowRunList
63
- from hatchet_sdk.clients.rest.models.workflow_run_order_by_direction import (
64
- WorkflowRunOrderByDirection,
65
- )
66
- from hatchet_sdk.clients.rest.models.workflow_run_order_by_field import (
67
- WorkflowRunOrderByField,
68
- )
69
- from hatchet_sdk.clients.rest.models.workflow_run_status import WorkflowRunStatus
70
- from hatchet_sdk.clients.rest.models.workflow_runs_cancel_request import (
71
- WorkflowRunsCancelRequest,
72
- )
73
- from hatchet_sdk.clients.rest.models.workflow_version import WorkflowVersion
74
- from hatchet_sdk.utils.typing import JSONSerializableMapping
75
-
76
- ## Type variables to use with coroutines.
77
- ## See https://stackoverflow.com/questions/73240620/the-right-way-to-type-hint-a-coroutine-function
78
- ## Return type
79
- R = TypeVar("R")
80
-
81
- ## Yield type
82
- Y = TypeVar("Y")
83
-
84
- ## Send type
85
- S = TypeVar("S")
86
-
87
-
88
- class RestApi:
89
- def __init__(self, host: str, api_key: str, tenant_id: str):
90
- self.tenant_id = tenant_id
91
-
92
- self.config = Configuration(
93
- host=host,
94
- access_token=api_key,
95
- )
96
-
97
- self._loop = asyncio.new_event_loop()
98
- self._thread = threading.Thread(target=self._run_event_loop, daemon=True)
99
- self._thread.start()
100
-
101
- # Register the cleanup method to be called on exit
102
- atexit.register(self._cleanup)
103
-
104
- ## IMPORTANT: These clients need to be instantiated lazily because they rely on
105
- ## an event loop to be running, which may not be the case when the `Hatchet` client is instantiated.
106
- self._api_client: ApiClient | None = None
107
- self._workflow_api: WorkflowApi | None = None
108
- self._workflow_run_api: WorkflowRunApi | None = None
109
- self._step_run_api: StepRunApi | None = None
110
- self._event_api: EventApi | None = None
111
- self._log_api: LogApi | None = None
112
-
113
- @property
114
- def api_client(self) -> ApiClient:
115
- ## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
116
- ## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
117
- if self._api_client is None:
118
- self._api_client = ApiClient(configuration=self.config)
119
- return self._api_client
120
-
121
- @property
122
- def workflow_api(self) -> WorkflowApi:
123
- ## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
124
- ## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
125
- if self._workflow_api is None:
126
- self._workflow_api = WorkflowApi(self.api_client)
127
- return self._workflow_api
128
-
129
- @property
130
- def workflow_run_api(self) -> WorkflowRunApi:
131
- ## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
132
- ## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
133
- if self._workflow_run_api is None:
134
- self._workflow_run_api = WorkflowRunApi(self.api_client)
135
- return self._workflow_run_api
136
-
137
- @property
138
- def step_run_api(self) -> StepRunApi:
139
- ## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
140
- ## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
141
- if self._step_run_api is None:
142
- self._step_run_api = StepRunApi(self.api_client)
143
- return self._step_run_api
144
-
145
- @property
146
- def event_api(self) -> EventApi:
147
- ## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
148
- ## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
149
- if self._event_api is None:
150
- self._event_api = EventApi(self.api_client)
151
- return self._event_api
152
-
153
- @property
154
- def log_api(self) -> LogApi:
155
- ## IMPORTANT: This client needs to be instantiated lazily because it relies on an event
156
- ## loop to be running, which may not be the case when the `Hatchet` client is instantiated.
157
- if self._log_api is None:
158
- self._log_api = LogApi(self.api_client)
159
- return self._log_api
160
-
161
- async def close(self) -> None:
162
- # Ensure the aiohttp client session is closed
163
- await self.api_client.close() # type: ignore[no-untyped-call]
164
-
165
- async def aio_list_workflows(self) -> WorkflowList:
166
- return await self.workflow_api.workflow_list(
167
- tenant=self.tenant_id,
168
- )
169
-
170
- async def aio_get_workflow(self, workflow_id: str) -> Workflow:
171
- return await self.workflow_api.workflow_get(
172
- workflow=workflow_id,
173
- )
174
-
175
- async def aio_get_workflow_version(
176
- self, workflow_id: str, version: str | None = None
177
- ) -> WorkflowVersion:
178
- return await self.workflow_api.workflow_version_get(
179
- workflow=workflow_id,
180
- version=version,
181
- )
182
-
183
- async def aio_list_workflow_runs(
184
- self,
185
- workflow_id: str | None = None,
186
- offset: int | None = None,
187
- limit: int | None = None,
188
- event_id: str | None = None,
189
- parent_workflow_run_id: str | None = None,
190
- parent_step_run_id: str | None = None,
191
- statuses: list[WorkflowRunStatus] | None = None,
192
- kinds: list[WorkflowKind] | None = None,
193
- additional_metadata: list[str] | None = None,
194
- order_by_field: WorkflowRunOrderByField | None = None,
195
- order_by_direction: WorkflowRunOrderByDirection | None = None,
196
- ) -> WorkflowRunList:
197
- return await self.workflow_api.workflow_run_list(
198
- tenant=self.tenant_id,
199
- offset=offset,
200
- limit=limit,
201
- workflow_id=workflow_id,
202
- event_id=event_id,
203
- parent_workflow_run_id=parent_workflow_run_id,
204
- parent_step_run_id=parent_step_run_id,
205
- statuses=statuses,
206
- kinds=kinds,
207
- additional_metadata=additional_metadata,
208
- order_by_field=order_by_field,
209
- order_by_direction=order_by_direction,
210
- )
211
-
212
- async def aio_get_workflow_run(self, workflow_run_id: str) -> WorkflowRun:
213
- return await self.workflow_api.workflow_run_get(
214
- tenant=self.tenant_id,
215
- workflow_run=workflow_run_id,
216
- )
217
-
218
- async def aio_replay_workflow_run(
219
- self, workflow_run_ids: list[str]
220
- ) -> ReplayWorkflowRunsResponse:
221
- return await self.workflow_run_api.workflow_run_update_replay(
222
- tenant=self.tenant_id,
223
- replay_workflow_runs_request=ReplayWorkflowRunsRequest(
224
- workflowRunIds=workflow_run_ids,
225
- ),
226
- )
227
-
228
- async def aio_cancel_workflow_run(
229
- self, workflow_run_id: str
230
- ) -> EventUpdateCancel200Response:
231
- return await self.workflow_run_api.workflow_run_cancel(
232
- tenant=self.tenant_id,
233
- workflow_runs_cancel_request=WorkflowRunsCancelRequest(
234
- workflowRunIds=[workflow_run_id],
235
- ),
236
- )
237
-
238
- async def aio_bulk_cancel_workflow_runs(
239
- self, workflow_run_ids: list[str]
240
- ) -> EventUpdateCancel200Response:
241
- return await self.workflow_run_api.workflow_run_cancel(
242
- tenant=self.tenant_id,
243
- workflow_runs_cancel_request=WorkflowRunsCancelRequest(
244
- workflowRunIds=workflow_run_ids,
245
- ),
246
- )
247
-
248
- async def aio_create_workflow_run(
249
- self,
250
- workflow_id: str,
251
- input: JSONSerializableMapping,
252
- version: str | None = None,
253
- additional_metadata: JSONSerializableMapping = {},
254
- ) -> WorkflowRun:
255
- return await self.workflow_run_api.workflow_run_create(
256
- workflow=workflow_id,
257
- version=version,
258
- trigger_workflow_run_request=TriggerWorkflowRunRequest(
259
- input=dict(input),
260
- additionalMetadata=dict(additional_metadata),
261
- ),
262
- )
263
-
264
- async def aio_create_cron(
265
- self,
266
- workflow_name: str,
267
- cron_name: str,
268
- expression: str,
269
- input: JSONSerializableMapping,
270
- additional_metadata: JSONSerializableMapping,
271
- ) -> CronWorkflows:
272
- return await self.workflow_run_api.cron_workflow_trigger_create(
273
- tenant=self.tenant_id,
274
- workflow=workflow_name,
275
- create_cron_workflow_trigger_request=CreateCronWorkflowTriggerRequest(
276
- cronName=cron_name,
277
- cronExpression=expression,
278
- input=dict(input),
279
- additionalMetadata=dict(additional_metadata),
280
- ),
281
- )
282
-
283
- async def aio_delete_cron(self, cron_trigger_id: str) -> None:
284
- await self.workflow_api.workflow_cron_delete(
285
- tenant=self.tenant_id,
286
- cron_workflow=cron_trigger_id,
287
- )
288
-
289
- async def aio_list_crons(
290
- self,
291
- offset: StrictInt | None = None,
292
- limit: StrictInt | None = None,
293
- workflow_id: str | None = None,
294
- additional_metadata: list[str] | None = None,
295
- order_by_field: CronWorkflowsOrderByField | None = None,
296
- order_by_direction: WorkflowRunOrderByDirection | None = None,
297
- ) -> CronWorkflowsList:
298
- return await self.workflow_api.cron_workflow_list(
299
- tenant=self.tenant_id,
300
- offset=offset,
301
- limit=limit,
302
- workflow_id=workflow_id,
303
- additional_metadata=additional_metadata,
304
- order_by_field=order_by_field,
305
- order_by_direction=order_by_direction,
306
- )
307
-
308
- async def aio_get_cron(self, cron_trigger_id: str) -> CronWorkflows:
309
- return await self.workflow_api.workflow_cron_get(
310
- tenant=self.tenant_id,
311
- cron_workflow=cron_trigger_id,
312
- )
313
-
314
- async def aio_create_schedule(
315
- self,
316
- name: str,
317
- trigger_at: datetime.datetime,
318
- input: JSONSerializableMapping,
319
- additional_metadata: JSONSerializableMapping,
320
- ) -> ScheduledWorkflows:
321
- return await self.workflow_run_api.scheduled_workflow_run_create(
322
- tenant=self.tenant_id,
323
- workflow=name,
324
- schedule_workflow_run_request=ScheduleWorkflowRunRequest(
325
- triggerAt=trigger_at,
326
- input=dict(input),
327
- additionalMetadata=dict(additional_metadata),
328
- ),
329
- )
330
-
331
- async def aio_delete_schedule(self, scheduled_trigger_id: str) -> None:
332
- await self.workflow_api.workflow_scheduled_delete(
333
- tenant=self.tenant_id,
334
- scheduled_workflow_run=scheduled_trigger_id,
335
- )
336
-
337
- async def aio_list_schedule(
338
- self,
339
- offset: StrictInt | None = None,
340
- limit: StrictInt | None = None,
341
- workflow_id: str | None = None,
342
- additional_metadata: list[str] | None = None,
343
- parent_workflow_run_id: str | None = None,
344
- parent_step_run_id: str | None = None,
345
- order_by_field: ScheduledWorkflowsOrderByField | None = None,
346
- order_by_direction: WorkflowRunOrderByDirection | None = None,
347
- ) -> ScheduledWorkflowsList:
348
- return await self.workflow_api.workflow_scheduled_list(
349
- tenant=self.tenant_id,
350
- offset=offset,
351
- limit=limit,
352
- workflow_id=workflow_id,
353
- parent_workflow_run_id=parent_workflow_run_id,
354
- parent_step_run_id=parent_step_run_id,
355
- additional_metadata=additional_metadata,
356
- order_by_field=order_by_field,
357
- order_by_direction=order_by_direction,
358
- )
359
-
360
- async def aio_get_schedule(self, scheduled_trigger_id: str) -> ScheduledWorkflows:
361
- return await self.workflow_api.workflow_scheduled_get(
362
- tenant=self.tenant_id,
363
- scheduled_workflow_run=scheduled_trigger_id,
364
- )
365
-
366
- async def aio_list_logs(
367
- self,
368
- step_run_id: str,
369
- offset: int | None = None,
370
- limit: int | None = None,
371
- levels: list[LogLineLevel] | None = None,
372
- search: str | None = None,
373
- order_by_field: LogLineOrderByField | None = None,
374
- order_by_direction: LogLineOrderByDirection | None = None,
375
- ) -> LogLineList:
376
- return await self.log_api.log_line_list(
377
- step_run=step_run_id,
378
- offset=offset,
379
- limit=limit,
380
- levels=levels,
381
- search=search,
382
- order_by_field=order_by_field,
383
- order_by_direction=order_by_direction,
384
- )
385
-
386
- async def aio_list_events(
387
- self,
388
- offset: int | None = None,
389
- limit: int | None = None,
390
- keys: list[str] | None = None,
391
- workflows: list[str] | None = None,
392
- statuses: list[WorkflowRunStatus] | None = None,
393
- search: str | None = None,
394
- order_by_field: EventOrderByField | None = None,
395
- order_by_direction: EventOrderByDirection | None = None,
396
- additional_metadata: list[str] | None = None,
397
- ) -> EventList:
398
- return await self.event_api.event_list(
399
- tenant=self.tenant_id,
400
- offset=offset,
401
- limit=limit,
402
- keys=keys,
403
- workflows=workflows,
404
- statuses=statuses,
405
- search=search,
406
- order_by_field=order_by_field,
407
- order_by_direction=order_by_direction,
408
- additional_metadata=additional_metadata,
409
- )
410
-
411
- async def aio_replay_events(self, event_ids: list[str] | EventList) -> EventList:
412
- if isinstance(event_ids, EventList):
413
- rows = event_ids.rows or []
414
- event_ids = [r.metadata.id for r in rows]
415
-
416
- return await self.event_api.event_update_replay(
417
- tenant=self.tenant_id,
418
- replay_event_request=ReplayEventRequest(eventIds=event_ids),
419
- )
420
-
421
- def _cleanup(self) -> None:
422
- """
423
- Stop the running thread and clean up the event loop.
424
- """
425
- self._run_coroutine(self.close())
426
- self._loop.call_soon_threadsafe(self._loop.stop)
427
- self._thread.join()
428
-
429
- def _run_event_loop(self) -> None:
430
- """
431
- Run the asyncio event loop in a separate thread.
432
- """
433
- asyncio.set_event_loop(self._loop)
434
- self._loop.run_forever()
435
-
436
- def _run_coroutine(self, coro: Coroutine[Y, S, R]) -> R:
437
- """
438
- Execute a coroutine in the event loop and return the result.
439
- """
440
- future = asyncio.run_coroutine_threadsafe(coro, self._loop)
441
- return future.result()
442
-
443
- def workflow_list(self) -> WorkflowList:
444
- return self._run_coroutine(self.aio_list_workflows())
445
-
446
- def workflow_get(self, workflow_id: str) -> Workflow:
447
- return self._run_coroutine(self.aio_get_workflow(workflow_id))
448
-
449
- def workflow_version_get(
450
- self, workflow_id: str, version: str | None = None
451
- ) -> WorkflowVersion:
452
- return self._run_coroutine(self.aio_get_workflow_version(workflow_id, version))
453
-
454
- def workflow_run_list(
455
- self,
456
- workflow_id: str | None = None,
457
- offset: int | None = None,
458
- limit: int | None = None,
459
- event_id: str | None = None,
460
- parent_workflow_run_id: str | None = None,
461
- parent_step_run_id: str | None = None,
462
- statuses: list[WorkflowRunStatus] | None = None,
463
- kinds: list[WorkflowKind] | None = None,
464
- additional_metadata: list[str] | None = None,
465
- order_by_field: WorkflowRunOrderByField | None = None,
466
- order_by_direction: WorkflowRunOrderByDirection | None = None,
467
- ) -> WorkflowRunList:
468
- return self._run_coroutine(
469
- self.aio_list_workflow_runs(
470
- workflow_id=workflow_id,
471
- offset=offset,
472
- limit=limit,
473
- event_id=event_id,
474
- parent_workflow_run_id=parent_workflow_run_id,
475
- parent_step_run_id=parent_step_run_id,
476
- statuses=statuses,
477
- kinds=kinds,
478
- additional_metadata=additional_metadata,
479
- order_by_field=order_by_field,
480
- order_by_direction=order_by_direction,
481
- )
482
- )
483
-
484
- def workflow_run_get(self, workflow_run_id: str) -> WorkflowRun:
485
- return self._run_coroutine(self.aio_get_workflow_run(workflow_run_id))
486
-
487
- def workflow_run_cancel(self, workflow_run_id: str) -> EventUpdateCancel200Response:
488
- return self._run_coroutine(self.aio_cancel_workflow_run(workflow_run_id))
489
-
490
- def workflow_run_bulk_cancel(
491
- self, workflow_run_ids: list[str]
492
- ) -> EventUpdateCancel200Response:
493
- return self._run_coroutine(self.aio_bulk_cancel_workflow_runs(workflow_run_ids))
494
-
495
- def workflow_run_create(
496
- self,
497
- workflow_id: str,
498
- input: JSONSerializableMapping,
499
- version: str | None = None,
500
- additional_metadata: JSONSerializableMapping = {},
501
- ) -> WorkflowRun:
502
- return self._run_coroutine(
503
- self.aio_create_workflow_run(
504
- workflow_id, input, version, additional_metadata
505
- )
506
- )
507
-
508
- def cron_create(
509
- self,
510
- workflow_name: str,
511
- cron_name: str,
512
- expression: str,
513
- input: JSONSerializableMapping,
514
- additional_metadata: JSONSerializableMapping,
515
- ) -> CronWorkflows:
516
- return self._run_coroutine(
517
- self.aio_create_cron(
518
- workflow_name, cron_name, expression, input, additional_metadata
519
- )
520
- )
521
-
522
- def cron_delete(self, cron_trigger_id: str) -> None:
523
- self._run_coroutine(self.aio_delete_cron(cron_trigger_id))
524
-
525
- def cron_list(
526
- self,
527
- offset: int | None = None,
528
- limit: int | None = None,
529
- workflow_id: str | None = None,
530
- additional_metadata: list[str] | None = None,
531
- order_by_field: CronWorkflowsOrderByField | None = None,
532
- order_by_direction: WorkflowRunOrderByDirection | None = None,
533
- ) -> CronWorkflowsList:
534
- return self._run_coroutine(
535
- self.aio_list_crons(
536
- offset,
537
- limit,
538
- workflow_id,
539
- additional_metadata,
540
- order_by_field,
541
- order_by_direction,
542
- )
543
- )
544
-
545
- def cron_get(self, cron_trigger_id: str) -> CronWorkflows:
546
- return self._run_coroutine(self.aio_get_cron(cron_trigger_id))
547
-
548
- def schedule_create(
549
- self,
550
- workflow_name: str,
551
- trigger_at: datetime.datetime,
552
- input: JSONSerializableMapping,
553
- additional_metadata: JSONSerializableMapping,
554
- ) -> ScheduledWorkflows:
555
- return self._run_coroutine(
556
- self.aio_create_schedule(
557
- workflow_name, trigger_at, input, additional_metadata
558
- )
559
- )
560
-
561
- def schedule_delete(self, scheduled_trigger_id: str) -> None:
562
- self._run_coroutine(self.aio_delete_schedule(scheduled_trigger_id))
563
-
564
- def schedule_list(
565
- self,
566
- offset: int | None = None,
567
- limit: int | None = None,
568
- workflow_id: str | None = None,
569
- additional_metadata: list[str] | None = None,
570
- order_by_field: CronWorkflowsOrderByField | None = None,
571
- order_by_direction: WorkflowRunOrderByDirection | None = None,
572
- ) -> ScheduledWorkflowsList:
573
- return self._run_coroutine(
574
- self.aio_list_schedule(
575
- offset,
576
- limit,
577
- workflow_id,
578
- additional_metadata,
579
- order_by_field,
580
- order_by_direction,
581
- )
582
- )
583
-
584
- def schedule_get(self, scheduled_trigger_id: str) -> ScheduledWorkflows:
585
- return self._run_coroutine(self.aio_get_schedule(scheduled_trigger_id))
586
-
587
- def list_logs(
588
- self,
589
- step_run_id: str,
590
- offset: int | None = None,
591
- limit: int | None = None,
592
- levels: list[LogLineLevel] | None = None,
593
- search: str | None = None,
594
- order_by_field: LogLineOrderByField | None = None,
595
- order_by_direction: LogLineOrderByDirection | None = None,
596
- ) -> LogLineList:
597
- return self._run_coroutine(
598
- self.aio_list_logs(
599
- step_run_id=step_run_id,
600
- offset=offset,
601
- limit=limit,
602
- levels=levels,
603
- search=search,
604
- order_by_field=order_by_field,
605
- order_by_direction=order_by_direction,
606
- )
607
- )
608
-
609
- def events_list(
610
- self,
611
- offset: int | None = None,
612
- limit: int | None = None,
613
- keys: list[str] | None = None,
614
- workflows: list[str] | None = None,
615
- statuses: list[WorkflowRunStatus] | None = None,
616
- search: str | None = None,
617
- order_by_field: EventOrderByField | None = None,
618
- order_by_direction: EventOrderByDirection | None = None,
619
- additional_metadata: list[str] | None = None,
620
- ) -> EventList:
621
- return self._run_coroutine(
622
- self.aio_list_events(
623
- offset=offset,
624
- limit=limit,
625
- keys=keys,
626
- workflows=workflows,
627
- statuses=statuses,
628
- search=search,
629
- order_by_field=order_by_field,
630
- order_by_direction=order_by_direction,
631
- additional_metadata=additional_metadata,
632
- )
633
- )
634
-
635
- def events_replay(self, event_ids: list[str] | EventList) -> EventList:
636
- return self._run_coroutine(self.aio_replay_events(event_ids))
hatchet_sdk/semver.py DELETED
@@ -1,30 +0,0 @@
1
- def bump_minor_version(version: str) -> str:
2
- """
3
- Bumps the minor version of a semantic version string. NOTE this doesn't follow full semver,
4
- missing the build metadata and pre-release version.
5
-
6
- :param version: A semantic version string in the format major.minor.patch
7
- :return: A string with the minor version bumped and patch version reset to 0
8
- :raises ValueError: If the input is not a valid semantic version string
9
- """
10
- # if it starts with a v, remove it
11
- had_v = False
12
- if version.startswith("v"):
13
- version = version[1:]
14
- had_v = True
15
-
16
- parts = version.split(".")
17
- if len(parts) != 3:
18
- raise ValueError(f"Invalid semantic version: {version}")
19
-
20
- try:
21
- major, minor, _ = map(int, parts)
22
- except ValueError:
23
- raise ValueError(f"Invalid semantic version: {version}")
24
-
25
- new_minor = minor + 1
26
- new_version = f"{major}.{new_minor}.0"
27
-
28
- if had_v:
29
- new_version = "v" + new_version
30
- return new_version
@@ -1,6 +0,0 @@
1
- import traceback
2
-
3
-
4
- def errorWithTraceback(message: str, e: Exception) -> str:
5
- trace = "".join(traceback.format_exception(type(e), e, e.__traceback__))
6
- return f"{message}\n{trace}"