hatchet-sdk 1.2.3__py3-none-any.whl → 1.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hatchet-sdk might be problematic. Click here for more details.
- hatchet_sdk/clients/admin.py +66 -45
- {hatchet_sdk-1.2.3.dist-info → hatchet_sdk-1.2.4.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.2.3.dist-info → hatchet_sdk-1.2.4.dist-info}/RECORD +5 -5
- {hatchet_sdk-1.2.3.dist-info → hatchet_sdk-1.2.4.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.2.3.dist-info → hatchet_sdk-1.2.4.dist-info}/entry_points.txt +0 -0
hatchet_sdk/clients/admin.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
3
|
from datetime import datetime
|
|
4
|
-
from typing import Union, cast
|
|
4
|
+
from typing import Generator, TypeVar, Union, cast
|
|
5
5
|
|
|
6
6
|
import grpc
|
|
7
7
|
from google.protobuf import timestamp_pb2
|
|
@@ -27,6 +27,10 @@ from hatchet_sdk.utils.proto_enums import convert_python_enum_to_proto
|
|
|
27
27
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
28
28
|
from hatchet_sdk.workflow_run import WorkflowRunRef
|
|
29
29
|
|
|
30
|
+
T = TypeVar("T")
|
|
31
|
+
|
|
32
|
+
MAX_BULK_WORKFLOW_RUN_BATCH_SIZE = 1000
|
|
33
|
+
|
|
30
34
|
|
|
31
35
|
class ScheduleTriggerWorkflowOptions(BaseModel):
|
|
32
36
|
parent_id: str | None = None
|
|
@@ -328,9 +332,6 @@ class AdminClient:
|
|
|
328
332
|
input: JSONSerializableMapping,
|
|
329
333
|
options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
|
|
330
334
|
) -> WorkflowRunRef:
|
|
331
|
-
## IMPORTANT: The `pooled_workflow_listener` must be created 1) lazily, and not at `init` time, and 2) on the
|
|
332
|
-
## main thread. If 1) is not followed, you'll get an error about something being attached to the wrong event
|
|
333
|
-
## loop. If 2) is not followed, you'll get an error about the event loop not being set up.
|
|
334
335
|
async with spawn_index_lock:
|
|
335
336
|
request = self._create_workflow_run_request(workflow_name, input, options)
|
|
336
337
|
|
|
@@ -353,70 +354,90 @@ class AdminClient:
|
|
|
353
354
|
config=self.config,
|
|
354
355
|
)
|
|
355
356
|
|
|
357
|
+
def chunk(self, xs: list[T], n: int) -> Generator[list[T], None, None]:
|
|
358
|
+
for i in range(0, len(xs), n):
|
|
359
|
+
yield xs[i : i + n]
|
|
360
|
+
|
|
356
361
|
## IMPORTANT: Keep this method's signature in sync with the wrapper in the OTel instrumentor
|
|
357
362
|
@tenacity_retry
|
|
358
363
|
def run_workflows(
|
|
359
364
|
self,
|
|
360
365
|
workflows: list[WorkflowRunTriggerConfig],
|
|
361
366
|
) -> list[WorkflowRunRef]:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
]
|
|
369
|
-
)
|
|
367
|
+
bulk_workflows = [
|
|
368
|
+
self._create_workflow_run_request(
|
|
369
|
+
workflow.workflow_name, workflow.input, workflow.options
|
|
370
|
+
)
|
|
371
|
+
for workflow in workflows
|
|
372
|
+
]
|
|
370
373
|
|
|
371
|
-
|
|
372
|
-
v0_workflow_protos.BulkTriggerWorkflowResponse,
|
|
373
|
-
self.v0_client.BulkTriggerWorkflow(
|
|
374
|
-
bulk_request,
|
|
375
|
-
metadata=get_metadata(self.token),
|
|
376
|
-
),
|
|
377
|
-
)
|
|
374
|
+
refs: list[WorkflowRunRef] = []
|
|
378
375
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
config=self.config,
|
|
376
|
+
for chunk in self.chunk(bulk_workflows, MAX_BULK_WORKFLOW_RUN_BATCH_SIZE):
|
|
377
|
+
bulk_request = v0_workflow_protos.BulkTriggerWorkflowRequest(
|
|
378
|
+
workflows=chunk
|
|
383
379
|
)
|
|
384
|
-
|
|
385
|
-
|
|
380
|
+
|
|
381
|
+
resp = cast(
|
|
382
|
+
v0_workflow_protos.BulkTriggerWorkflowResponse,
|
|
383
|
+
self.v0_client.BulkTriggerWorkflow(
|
|
384
|
+
bulk_request,
|
|
385
|
+
metadata=get_metadata(self.token),
|
|
386
|
+
),
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
refs.extend(
|
|
390
|
+
[
|
|
391
|
+
WorkflowRunRef(
|
|
392
|
+
workflow_run_id=workflow_run_id,
|
|
393
|
+
config=self.config,
|
|
394
|
+
)
|
|
395
|
+
for workflow_run_id in resp.workflow_run_ids
|
|
396
|
+
]
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
return refs
|
|
386
400
|
|
|
387
401
|
@tenacity_retry
|
|
388
402
|
async def aio_run_workflows(
|
|
389
403
|
self,
|
|
390
404
|
workflows: list[WorkflowRunTriggerConfig],
|
|
391
405
|
) -> list[WorkflowRunRef]:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
406
|
+
chunks = self.chunk(workflows, MAX_BULK_WORKFLOW_RUN_BATCH_SIZE)
|
|
407
|
+
refs: list[WorkflowRunRef] = []
|
|
408
|
+
|
|
409
|
+
for chunk in chunks:
|
|
410
|
+
async with spawn_index_lock:
|
|
411
|
+
bulk_workflows = [
|
|
398
412
|
self._create_workflow_run_request(
|
|
399
413
|
workflow.workflow_name, workflow.input, workflow.options
|
|
400
414
|
)
|
|
401
|
-
for workflow in
|
|
415
|
+
for workflow in chunk
|
|
402
416
|
]
|
|
417
|
+
|
|
418
|
+
bulk_request = v0_workflow_protos.BulkTriggerWorkflowRequest(
|
|
419
|
+
workflows=bulk_workflows
|
|
403
420
|
)
|
|
404
421
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
422
|
+
resp = cast(
|
|
423
|
+
v0_workflow_protos.BulkTriggerWorkflowResponse,
|
|
424
|
+
self.v0_client.BulkTriggerWorkflow(
|
|
425
|
+
bulk_request,
|
|
426
|
+
metadata=get_metadata(self.token),
|
|
427
|
+
),
|
|
428
|
+
)
|
|
412
429
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
430
|
+
refs.extend(
|
|
431
|
+
[
|
|
432
|
+
WorkflowRunRef(
|
|
433
|
+
workflow_run_id=workflow_run_id,
|
|
434
|
+
config=self.config,
|
|
435
|
+
)
|
|
436
|
+
for workflow_run_id in resp.workflow_run_ids
|
|
437
|
+
]
|
|
417
438
|
)
|
|
418
|
-
|
|
419
|
-
|
|
439
|
+
|
|
440
|
+
return refs
|
|
420
441
|
|
|
421
442
|
def get_workflow_run(self, workflow_run_id: str) -> WorkflowRunRef:
|
|
422
443
|
return WorkflowRunRef(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
hatchet_sdk/__init__.py,sha256=o_06wLLKCKRq4uQuCF62yDRb8hTQYYcqPC3FIDNHxuQ,10002
|
|
2
2
|
hatchet_sdk/client.py,sha256=lApcV1-qlvIdiHyGrQJAIlT9qzP96I0mQ2STZ1ZV_2g,1940
|
|
3
|
-
hatchet_sdk/clients/admin.py,sha256=
|
|
3
|
+
hatchet_sdk/clients/admin.py,sha256=1pY3RlJmVjFAfxX6kwVMd7jO_JHxkei6jrz8XUJUaKI,15333
|
|
4
4
|
hatchet_sdk/clients/dispatcher/action_listener.py,sha256=FogjHd6vhj4HeQs--Z-99kPwCfaETo1-EcotjdIkrig,16266
|
|
5
5
|
hatchet_sdk/clients/dispatcher/dispatcher.py,sha256=7tHEoCvL2MKklxbT43oRsQdx9JuLIVCJvFuIUqTHjis,7794
|
|
6
6
|
hatchet_sdk/clients/durable_event_listener.py,sha256=J5Tg8niikms-tEfB8wps_wgsPF7Fx-pYhYExd0lJo7Y,11791
|
|
@@ -506,7 +506,7 @@ hatchet_sdk/worker/runner/runner.py,sha256=ZocvR7dDgEvSxcHAWDDaoTasSz3Wio70TbEbB
|
|
|
506
506
|
hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=nHRPSiDBqzhObM7i2X7t03OupVFnE7kQBdR2Ckgg-2w,2709
|
|
507
507
|
hatchet_sdk/worker/worker.py,sha256=qyHs64H-grF9HR1CgH7MlnoDmTQ8mm4d8basx-ZDyWc,14490
|
|
508
508
|
hatchet_sdk/workflow_run.py,sha256=Q1nTpnWNsFfjWWpx49xXYUHsVbqTnHL6JWnSKoFM3_I,1029
|
|
509
|
-
hatchet_sdk-1.2.
|
|
510
|
-
hatchet_sdk-1.2.
|
|
511
|
-
hatchet_sdk-1.2.
|
|
512
|
-
hatchet_sdk-1.2.
|
|
509
|
+
hatchet_sdk-1.2.4.dist-info/METADATA,sha256=U6Iloh69aCy5R-Y5V47P61n_TNYHmiQPNLNKyBpmNdg,3571
|
|
510
|
+
hatchet_sdk-1.2.4.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
511
|
+
hatchet_sdk-1.2.4.dist-info/entry_points.txt,sha256=5mTp_AsCWK5raiVxP_MU9eBCgkRGl4OsN6chpHcvm7o,1235
|
|
512
|
+
hatchet_sdk-1.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|