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

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