hatchet-sdk 1.12.3__py3-none-any.whl → 1.14.0__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 +54 -40
- hatchet_sdk/clients/admin.py +18 -23
- hatchet_sdk/clients/dispatcher/action_listener.py +4 -3
- hatchet_sdk/clients/dispatcher/dispatcher.py +1 -4
- hatchet_sdk/clients/event_ts.py +2 -1
- hatchet_sdk/clients/events.py +16 -12
- hatchet_sdk/clients/listeners/durable_event_listener.py +4 -2
- hatchet_sdk/clients/listeners/pooled_listener.py +2 -2
- hatchet_sdk/clients/listeners/run_event_listener.py +7 -8
- hatchet_sdk/clients/listeners/workflow_listener.py +14 -6
- hatchet_sdk/clients/rest/api_response.py +3 -2
- hatchet_sdk/clients/rest/models/semaphore_slots.py +1 -1
- hatchet_sdk/clients/rest/models/v1_task_summary.py +5 -0
- hatchet_sdk/clients/rest/models/v1_workflow_run_details.py +11 -1
- hatchet_sdk/clients/rest/models/workflow_version.py +5 -0
- hatchet_sdk/clients/rest/tenacity_utils.py +6 -8
- hatchet_sdk/config.py +2 -0
- hatchet_sdk/connection.py +10 -4
- hatchet_sdk/context/context.py +170 -46
- hatchet_sdk/context/worker_context.py +4 -7
- hatchet_sdk/contracts/dispatcher_pb2.py +38 -38
- hatchet_sdk/contracts/dispatcher_pb2.pyi +4 -2
- hatchet_sdk/contracts/events_pb2.py +13 -13
- hatchet_sdk/contracts/events_pb2.pyi +4 -2
- hatchet_sdk/contracts/v1/workflows_pb2.py +1 -1
- hatchet_sdk/contracts/v1/workflows_pb2.pyi +2 -2
- hatchet_sdk/exceptions.py +103 -1
- hatchet_sdk/features/cron.py +2 -2
- hatchet_sdk/features/filters.py +12 -21
- hatchet_sdk/features/runs.py +4 -4
- hatchet_sdk/features/scheduled.py +8 -9
- hatchet_sdk/hatchet.py +65 -64
- hatchet_sdk/opentelemetry/instrumentor.py +20 -20
- hatchet_sdk/runnables/action.py +1 -2
- hatchet_sdk/runnables/contextvars.py +19 -0
- hatchet_sdk/runnables/task.py +37 -29
- hatchet_sdk/runnables/types.py +9 -8
- hatchet_sdk/runnables/workflow.py +57 -42
- hatchet_sdk/utils/proto_enums.py +4 -4
- hatchet_sdk/utils/timedelta_to_expression.py +2 -3
- hatchet_sdk/utils/typing.py +11 -17
- hatchet_sdk/v0/__init__.py +7 -7
- hatchet_sdk/v0/clients/admin.py +7 -7
- hatchet_sdk/v0/clients/dispatcher/action_listener.py +8 -8
- hatchet_sdk/v0/clients/dispatcher/dispatcher.py +9 -9
- hatchet_sdk/v0/clients/events.py +3 -3
- hatchet_sdk/v0/clients/rest/tenacity_utils.py +1 -1
- hatchet_sdk/v0/clients/run_event_listener.py +3 -3
- hatchet_sdk/v0/clients/workflow_listener.py +5 -5
- hatchet_sdk/v0/context/context.py +6 -6
- hatchet_sdk/v0/hatchet.py +4 -4
- hatchet_sdk/v0/opentelemetry/instrumentor.py +1 -1
- hatchet_sdk/v0/rate_limit.py +1 -1
- hatchet_sdk/v0/v2/callable.py +4 -4
- hatchet_sdk/v0/v2/concurrency.py +2 -2
- hatchet_sdk/v0/v2/hatchet.py +3 -3
- hatchet_sdk/v0/worker/action_listener_process.py +6 -6
- hatchet_sdk/v0/worker/runner/run_loop_manager.py +1 -1
- hatchet_sdk/v0/worker/runner/runner.py +10 -10
- hatchet_sdk/v0/worker/runner/utils/capture_logs.py +1 -1
- hatchet_sdk/v0/worker/worker.py +2 -2
- hatchet_sdk/v0/workflow.py +3 -3
- hatchet_sdk/waits.py +6 -5
- hatchet_sdk/worker/action_listener_process.py +33 -13
- hatchet_sdk/worker/runner/run_loop_manager.py +15 -11
- hatchet_sdk/worker/runner/runner.py +142 -80
- hatchet_sdk/worker/runner/utils/capture_logs.py +72 -31
- hatchet_sdk/worker/worker.py +30 -26
- hatchet_sdk/workflow_run.py +4 -2
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.14.0.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.14.0.dist-info}/RECORD +73 -83
- hatchet_sdk/v0/contracts/dispatcher_pb2.py +0 -102
- hatchet_sdk/v0/contracts/dispatcher_pb2.pyi +0 -387
- hatchet_sdk/v0/contracts/dispatcher_pb2_grpc.py +0 -621
- hatchet_sdk/v0/contracts/events_pb2.py +0 -46
- hatchet_sdk/v0/contracts/events_pb2.pyi +0 -87
- hatchet_sdk/v0/contracts/events_pb2_grpc.py +0 -274
- hatchet_sdk/v0/contracts/workflows_pb2.py +0 -80
- hatchet_sdk/v0/contracts/workflows_pb2.pyi +0 -312
- hatchet_sdk/v0/contracts/workflows_pb2_grpc.py +0 -277
- hatchet_sdk/v0/logger.py +0 -13
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.14.0.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.14.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from datetime import datetime, timedelta, timezone
|
|
3
4
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING, Any,
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast, get_type_hints
|
|
5
6
|
|
|
6
7
|
from google.protobuf import timestamp_pb2
|
|
7
8
|
from pydantic import BaseModel, model_validator
|
|
@@ -11,6 +12,7 @@ from hatchet_sdk.clients.admin import (
|
|
|
11
12
|
TriggerWorkflowOptions,
|
|
12
13
|
WorkflowRunTriggerConfig,
|
|
13
14
|
)
|
|
15
|
+
from hatchet_sdk.clients.listeners.run_event_listener import RunEventListener
|
|
14
16
|
from hatchet_sdk.clients.rest.models.cron_workflows import CronWorkflows
|
|
15
17
|
from hatchet_sdk.clients.rest.models.v1_filter import V1Filter
|
|
16
18
|
from hatchet_sdk.clients.rest.models.v1_task_status import V1TaskStatus
|
|
@@ -371,7 +373,7 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
371
373
|
self,
|
|
372
374
|
expression: str,
|
|
373
375
|
scope: str,
|
|
374
|
-
payload: JSONSerializableMapping =
|
|
376
|
+
payload: JSONSerializableMapping | None = None,
|
|
375
377
|
) -> V1Filter:
|
|
376
378
|
"""
|
|
377
379
|
Create a new filter.
|
|
@@ -393,7 +395,7 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
393
395
|
self,
|
|
394
396
|
expression: str,
|
|
395
397
|
scope: str,
|
|
396
|
-
payload: JSONSerializableMapping =
|
|
398
|
+
payload: JSONSerializableMapping | None = None,
|
|
397
399
|
) -> V1Filter:
|
|
398
400
|
"""
|
|
399
401
|
Create a new filter.
|
|
@@ -458,7 +460,7 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
458
460
|
cron_name: str,
|
|
459
461
|
expression: str,
|
|
460
462
|
input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
|
|
461
|
-
additional_metadata: JSONSerializableMapping =
|
|
463
|
+
additional_metadata: JSONSerializableMapping | None = None,
|
|
462
464
|
priority: int | None = None,
|
|
463
465
|
) -> CronWorkflows:
|
|
464
466
|
"""
|
|
@@ -477,7 +479,7 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
477
479
|
cron_name=cron_name,
|
|
478
480
|
expression=expression,
|
|
479
481
|
input=self._serialize_input(input),
|
|
480
|
-
additional_metadata=additional_metadata,
|
|
482
|
+
additional_metadata=additional_metadata or {},
|
|
481
483
|
priority=priority,
|
|
482
484
|
)
|
|
483
485
|
|
|
@@ -486,7 +488,7 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
486
488
|
cron_name: str,
|
|
487
489
|
expression: str,
|
|
488
490
|
input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
|
|
489
|
-
additional_metadata: JSONSerializableMapping =
|
|
491
|
+
additional_metadata: JSONSerializableMapping | None = None,
|
|
490
492
|
priority: int | None = None,
|
|
491
493
|
) -> CronWorkflows:
|
|
492
494
|
"""
|
|
@@ -505,7 +507,7 @@ class BaseWorkflow(Generic[TWorkflowInput]):
|
|
|
505
507
|
cron_name=cron_name,
|
|
506
508
|
expression=expression,
|
|
507
509
|
input=self._serialize_input(input),
|
|
508
|
-
additional_metadata=additional_metadata,
|
|
510
|
+
additional_metadata=additional_metadata or {},
|
|
509
511
|
priority=priority,
|
|
510
512
|
)
|
|
511
513
|
|
|
@@ -620,7 +622,7 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
620
622
|
"""
|
|
621
623
|
Run the workflow asynchronously and wait for it to complete.
|
|
622
624
|
|
|
623
|
-
This method triggers a workflow run,
|
|
625
|
+
This method triggers a workflow run, awaits until completion, and returns the final result.
|
|
624
626
|
|
|
625
627
|
:param input: The input data for the workflow, must match the workflow's input type.
|
|
626
628
|
:param options: Additional options for workflow execution like metadata and parent workflow ID.
|
|
@@ -716,16 +718,16 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
716
718
|
name: str | None = None,
|
|
717
719
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
718
720
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
719
|
-
parents: list[Task[TWorkflowInput, Any]] =
|
|
721
|
+
parents: list[Task[TWorkflowInput, Any]] | None = None,
|
|
720
722
|
retries: int = 0,
|
|
721
|
-
rate_limits: list[RateLimit] =
|
|
722
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
723
|
+
rate_limits: list[RateLimit] | None = None,
|
|
724
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
723
725
|
backoff_factor: float | None = None,
|
|
724
726
|
backoff_max_seconds: int | None = None,
|
|
725
|
-
concurrency: list[ConcurrencyExpression] =
|
|
726
|
-
wait_for: list[Condition | OrGroup] =
|
|
727
|
-
skip_if: list[Condition | OrGroup] =
|
|
728
|
-
cancel_if: list[Condition | OrGroup] =
|
|
727
|
+
concurrency: list[ConcurrencyExpression] | None = None,
|
|
728
|
+
wait_for: list[Condition | OrGroup] | None = None,
|
|
729
|
+
skip_if: list[Condition | OrGroup] | None = None,
|
|
730
|
+
cancel_if: list[Condition | OrGroup] | None = None,
|
|
729
731
|
) -> Callable[
|
|
730
732
|
[Callable[[TWorkflowInput, Context], R | CoroutineLike[R]]],
|
|
731
733
|
Task[TWorkflowInput, R],
|
|
@@ -784,10 +786,10 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
784
786
|
schedule_timeout=computed_params.schedule_timeout,
|
|
785
787
|
parents=parents,
|
|
786
788
|
retries=computed_params.retries,
|
|
787
|
-
rate_limits=[r.to_proto() for r in rate_limits],
|
|
789
|
+
rate_limits=[r.to_proto() for r in rate_limits or []],
|
|
788
790
|
desired_worker_labels={
|
|
789
791
|
key: transform_desired_worker_label(d)
|
|
790
|
-
for key, d in desired_worker_labels.items()
|
|
792
|
+
for key, d in (desired_worker_labels or {}).items()
|
|
791
793
|
},
|
|
792
794
|
backoff_factor=computed_params.backoff_factor,
|
|
793
795
|
backoff_max_seconds=computed_params.backoff_max_seconds,
|
|
@@ -808,16 +810,16 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
808
810
|
name: str | None = None,
|
|
809
811
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
810
812
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
811
|
-
parents: list[Task[TWorkflowInput, Any]] =
|
|
813
|
+
parents: list[Task[TWorkflowInput, Any]] | None = None,
|
|
812
814
|
retries: int = 0,
|
|
813
|
-
rate_limits: list[RateLimit] =
|
|
814
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
815
|
+
rate_limits: list[RateLimit] | None = None,
|
|
816
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
815
817
|
backoff_factor: float | None = None,
|
|
816
818
|
backoff_max_seconds: int | None = None,
|
|
817
|
-
concurrency: list[ConcurrencyExpression] =
|
|
818
|
-
wait_for: list[Condition | OrGroup] =
|
|
819
|
-
skip_if: list[Condition | OrGroup] =
|
|
820
|
-
cancel_if: list[Condition | OrGroup] =
|
|
819
|
+
concurrency: list[ConcurrencyExpression] | None = None,
|
|
820
|
+
wait_for: list[Condition | OrGroup] | None = None,
|
|
821
|
+
skip_if: list[Condition | OrGroup] | None = None,
|
|
822
|
+
cancel_if: list[Condition | OrGroup] | None = None,
|
|
821
823
|
) -> Callable[
|
|
822
824
|
[Callable[[TWorkflowInput, DurableContext], R | CoroutineLike[R]]],
|
|
823
825
|
Task[TWorkflowInput, R],
|
|
@@ -880,10 +882,10 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
880
882
|
schedule_timeout=computed_params.schedule_timeout,
|
|
881
883
|
parents=parents,
|
|
882
884
|
retries=computed_params.retries,
|
|
883
|
-
rate_limits=[r.to_proto() for r in rate_limits],
|
|
885
|
+
rate_limits=[r.to_proto() for r in rate_limits or []],
|
|
884
886
|
desired_worker_labels={
|
|
885
887
|
key: transform_desired_worker_label(d)
|
|
886
|
-
for key, d in desired_worker_labels.items()
|
|
888
|
+
for key, d in (desired_worker_labels or {}).items()
|
|
887
889
|
},
|
|
888
890
|
backoff_factor=computed_params.backoff_factor,
|
|
889
891
|
backoff_max_seconds=computed_params.backoff_max_seconds,
|
|
@@ -905,10 +907,10 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
905
907
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
906
908
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
907
909
|
retries: int = 0,
|
|
908
|
-
rate_limits: list[RateLimit] =
|
|
910
|
+
rate_limits: list[RateLimit] | None = None,
|
|
909
911
|
backoff_factor: float | None = None,
|
|
910
912
|
backoff_max_seconds: int | None = None,
|
|
911
|
-
concurrency: list[ConcurrencyExpression] =
|
|
913
|
+
concurrency: list[ConcurrencyExpression] | None = None,
|
|
912
914
|
) -> Callable[
|
|
913
915
|
[Callable[[TWorkflowInput, Context], R | CoroutineLike[R]]],
|
|
914
916
|
Task[TWorkflowInput, R],
|
|
@@ -947,10 +949,15 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
947
949
|
execution_timeout=execution_timeout,
|
|
948
950
|
schedule_timeout=schedule_timeout,
|
|
949
951
|
retries=retries,
|
|
950
|
-
rate_limits=[r.to_proto() for r in rate_limits],
|
|
952
|
+
rate_limits=[r.to_proto() for r in rate_limits or []],
|
|
951
953
|
backoff_factor=backoff_factor,
|
|
952
954
|
backoff_max_seconds=backoff_max_seconds,
|
|
953
955
|
concurrency=concurrency,
|
|
956
|
+
desired_worker_labels=None,
|
|
957
|
+
parents=None,
|
|
958
|
+
wait_for=None,
|
|
959
|
+
skip_if=None,
|
|
960
|
+
cancel_if=None,
|
|
954
961
|
)
|
|
955
962
|
|
|
956
963
|
if self._on_failure_task:
|
|
@@ -968,10 +975,10 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
968
975
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
969
976
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
970
977
|
retries: int = 0,
|
|
971
|
-
rate_limits: list[RateLimit] =
|
|
978
|
+
rate_limits: list[RateLimit] | None = None,
|
|
972
979
|
backoff_factor: float | None = None,
|
|
973
980
|
backoff_max_seconds: int | None = None,
|
|
974
|
-
concurrency: list[ConcurrencyExpression] =
|
|
981
|
+
concurrency: list[ConcurrencyExpression] | None = None,
|
|
975
982
|
) -> Callable[
|
|
976
983
|
[Callable[[TWorkflowInput, Context], R | CoroutineLike[R]]],
|
|
977
984
|
Task[TWorkflowInput, R],
|
|
@@ -1010,11 +1017,15 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
|
|
|
1010
1017
|
execution_timeout=execution_timeout,
|
|
1011
1018
|
schedule_timeout=schedule_timeout,
|
|
1012
1019
|
retries=retries,
|
|
1013
|
-
rate_limits=[r.to_proto() for r in rate_limits],
|
|
1020
|
+
rate_limits=[r.to_proto() for r in rate_limits or []],
|
|
1014
1021
|
backoff_factor=backoff_factor,
|
|
1015
1022
|
backoff_max_seconds=backoff_max_seconds,
|
|
1016
1023
|
concurrency=concurrency,
|
|
1017
|
-
parents=
|
|
1024
|
+
parents=None,
|
|
1025
|
+
desired_worker_labels=None,
|
|
1026
|
+
wait_for=None,
|
|
1027
|
+
skip_if=None,
|
|
1028
|
+
cancel_if=None,
|
|
1018
1029
|
)
|
|
1019
1030
|
|
|
1020
1031
|
if self._on_success_task:
|
|
@@ -1087,6 +1098,9 @@ class TaskRunRef(Generic[TWorkflowInput, R]):
|
|
|
1087
1098
|
|
|
1088
1099
|
return self._s._extract_result(result)
|
|
1089
1100
|
|
|
1101
|
+
def stream(self) -> RunEventListener:
|
|
1102
|
+
return self._wrr.stream()
|
|
1103
|
+
|
|
1090
1104
|
|
|
1091
1105
|
class Standalone(BaseWorkflow[TWorkflowInput], Generic[TWorkflowInput, R]):
|
|
1092
1106
|
def __init__(
|
|
@@ -1123,13 +1137,14 @@ class Standalone(BaseWorkflow[TWorkflowInput], Generic[TWorkflowInput, R]):
|
|
|
1123
1137
|
options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
|
|
1124
1138
|
) -> R:
|
|
1125
1139
|
"""
|
|
1126
|
-
|
|
1127
|
-
|
|
1140
|
+
Run the workflow synchronously and wait for it to complete.
|
|
1141
|
+
|
|
1142
|
+
This method triggers a workflow run, blocks until completion, and returns the extracted result.
|
|
1128
1143
|
|
|
1129
1144
|
:param input: The input data for the workflow.
|
|
1130
1145
|
:param options: Additional options for workflow execution.
|
|
1131
1146
|
|
|
1132
|
-
:returns:
|
|
1147
|
+
:returns: The extracted result of the workflow execution.
|
|
1133
1148
|
"""
|
|
1134
1149
|
return self._extract_result(self._workflow.run(input, options))
|
|
1135
1150
|
|
|
@@ -1141,12 +1156,12 @@ class Standalone(BaseWorkflow[TWorkflowInput], Generic[TWorkflowInput, R]):
|
|
|
1141
1156
|
"""
|
|
1142
1157
|
Run the workflow asynchronously and wait for it to complete.
|
|
1143
1158
|
|
|
1144
|
-
This method triggers a workflow run,
|
|
1159
|
+
This method triggers a workflow run, awaits until completion, and returns the extracted result.
|
|
1145
1160
|
|
|
1146
1161
|
:param input: The input data for the workflow, must match the workflow's input type.
|
|
1147
1162
|
:param options: Additional options for workflow execution like metadata and parent workflow ID.
|
|
1148
1163
|
|
|
1149
|
-
:returns: The result of the workflow execution
|
|
1164
|
+
:returns: The extracted result of the workflow execution.
|
|
1150
1165
|
"""
|
|
1151
1166
|
result = await self._workflow.aio_run(input, options)
|
|
1152
1167
|
return self._extract_result(result)
|
|
@@ -1157,14 +1172,14 @@ class Standalone(BaseWorkflow[TWorkflowInput], Generic[TWorkflowInput, R]):
|
|
|
1157
1172
|
options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
|
|
1158
1173
|
) -> TaskRunRef[TWorkflowInput, R]:
|
|
1159
1174
|
"""
|
|
1160
|
-
|
|
1175
|
+
Trigger a workflow run without waiting for it to complete.
|
|
1161
1176
|
|
|
1162
|
-
This method triggers a workflow run
|
|
1177
|
+
This method triggers a workflow run and immediately returns a reference to the run without blocking while the workflow runs.
|
|
1163
1178
|
|
|
1164
1179
|
:param input: The input data for the workflow, must match the workflow's input type.
|
|
1165
1180
|
:param options: Additional options for workflow execution like metadata and parent workflow ID.
|
|
1166
1181
|
|
|
1167
|
-
:returns:
|
|
1182
|
+
:returns: A `TaskRunRef` object representing the reference to the workflow run.
|
|
1168
1183
|
"""
|
|
1169
1184
|
ref = self._workflow.run_no_wait(input, options)
|
|
1170
1185
|
|
|
@@ -1182,7 +1197,7 @@ class Standalone(BaseWorkflow[TWorkflowInput], Generic[TWorkflowInput, R]):
|
|
|
1182
1197
|
:param input: The input data for the workflow.
|
|
1183
1198
|
:param options: Additional options for workflow execution.
|
|
1184
1199
|
|
|
1185
|
-
:returns: A `
|
|
1200
|
+
:returns: A `TaskRunRef` object representing the reference to the workflow run.
|
|
1186
1201
|
"""
|
|
1187
1202
|
ref = await self._workflow.aio_run_no_wait(input, options)
|
|
1188
1203
|
|
hatchet_sdk/utils/proto_enums.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import TypeVar, overload
|
|
3
3
|
|
|
4
4
|
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
|
|
5
5
|
|
|
@@ -26,19 +26,19 @@ def convert_python_enum_to_proto(
|
|
|
26
26
|
|
|
27
27
|
@overload
|
|
28
28
|
def convert_proto_enum_to_python(
|
|
29
|
-
value: TProtoEnumValue, python_enum_class:
|
|
29
|
+
value: TProtoEnumValue, python_enum_class: type[TPythonEnum], proto_enum: TProtoEnum
|
|
30
30
|
) -> TPythonEnum: ...
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
@overload
|
|
34
34
|
def convert_proto_enum_to_python(
|
|
35
|
-
value: None, python_enum_class:
|
|
35
|
+
value: None, python_enum_class: type[TPythonEnum], proto_enum: TProtoEnum
|
|
36
36
|
) -> None: ...
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
def convert_proto_enum_to_python(
|
|
40
40
|
value: TProtoEnumValue | None,
|
|
41
|
-
python_enum_class:
|
|
41
|
+
python_enum_class: type[TPythonEnum],
|
|
42
42
|
proto_enum: TProtoEnum,
|
|
43
43
|
) -> TPythonEnum | None:
|
|
44
44
|
if value is None:
|
|
@@ -18,7 +18,6 @@ def timedelta_to_expr(td: Duration) -> str:
|
|
|
18
18
|
## IMPORTANT: We only support hours, minutes, and seconds on the engine
|
|
19
19
|
if seconds % HOUR == 0:
|
|
20
20
|
return f"{seconds // HOUR}h"
|
|
21
|
-
|
|
21
|
+
if seconds % MINUTE == 0:
|
|
22
22
|
return f"{seconds // MINUTE}m"
|
|
23
|
-
|
|
24
|
-
return f"{seconds}s"
|
|
23
|
+
return f"{seconds}s"
|
hatchet_sdk/utils/typing.py
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
from
|
|
3
|
-
|
|
4
|
-
Awaitable,
|
|
5
|
-
Coroutine,
|
|
6
|
-
Generator,
|
|
7
|
-
Mapping,
|
|
8
|
-
Type,
|
|
9
|
-
TypeAlias,
|
|
10
|
-
TypeGuard,
|
|
11
|
-
TypeVar,
|
|
12
|
-
)
|
|
2
|
+
from collections.abc import Awaitable, Coroutine, Generator
|
|
3
|
+
from typing import Any, Literal, TypeAlias, TypeGuard, TypeVar
|
|
13
4
|
|
|
14
5
|
from pydantic import BaseModel
|
|
15
6
|
|
|
16
7
|
|
|
17
|
-
def is_basemodel_subclass(model: Any) -> TypeGuard[
|
|
8
|
+
def is_basemodel_subclass(model: Any) -> TypeGuard[type[BaseModel]]:
|
|
18
9
|
try:
|
|
19
10
|
return issubclass(model, BaseModel)
|
|
20
11
|
except TypeError:
|
|
@@ -22,18 +13,21 @@ def is_basemodel_subclass(model: Any) -> TypeGuard[Type[BaseModel]]:
|
|
|
22
13
|
|
|
23
14
|
|
|
24
15
|
class TaskIOValidator(BaseModel):
|
|
25
|
-
workflow_input:
|
|
26
|
-
step_output:
|
|
16
|
+
workflow_input: type[BaseModel] | None = None
|
|
17
|
+
step_output: type[BaseModel] | None = None
|
|
27
18
|
|
|
28
19
|
|
|
29
|
-
JSONSerializableMapping =
|
|
20
|
+
JSONSerializableMapping = dict[str, Any]
|
|
30
21
|
|
|
31
22
|
|
|
32
23
|
_T_co = TypeVar("_T_co", covariant=True)
|
|
33
24
|
|
|
34
25
|
if sys.version_info >= (3, 12):
|
|
35
|
-
AwaitableLike: TypeAlias = Awaitable[_T_co]
|
|
36
|
-
CoroutineLike: TypeAlias = Coroutine[Any, Any, _T_co]
|
|
26
|
+
AwaitableLike: TypeAlias = Awaitable[_T_co]
|
|
27
|
+
CoroutineLike: TypeAlias = Coroutine[Any, Any, _T_co]
|
|
37
28
|
else:
|
|
38
29
|
AwaitableLike: TypeAlias = Generator[Any, None, _T_co] | Awaitable[_T_co]
|
|
39
30
|
CoroutineLike: TypeAlias = Generator[Any, None, _T_co] | Coroutine[Any, Any, _T_co]
|
|
31
|
+
|
|
32
|
+
STOP_LOOP_TYPE = Literal["STOP_LOOP"]
|
|
33
|
+
STOP_LOOP: STOP_LOOP_TYPE = "STOP_LOOP" # Sentinel object to stop the loop
|
hatchet_sdk/v0/__init__.py
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
from hatchet_sdk.contracts.workflows_pb2 import (
|
|
2
|
+
ConcurrencyLimitStrategy,
|
|
3
|
+
CreateWorkflowVersionOpts,
|
|
4
|
+
RateLimitDuration,
|
|
5
|
+
StickyStrategy,
|
|
6
|
+
WorkerLabelComparator,
|
|
7
|
+
)
|
|
1
8
|
from hatchet_sdk.v0.clients.rest.models.accept_invite_request import AcceptInviteRequest
|
|
2
9
|
|
|
3
10
|
# import models into sdk package
|
|
@@ -121,13 +128,6 @@ from hatchet_sdk.v0.clients.rest.models.workflow_version_definition import (
|
|
|
121
128
|
WorkflowVersionDefinition,
|
|
122
129
|
)
|
|
123
130
|
from hatchet_sdk.v0.clients.rest.models.workflow_version_meta import WorkflowVersionMeta
|
|
124
|
-
from hatchet_sdk.v0.contracts.workflows_pb2 import (
|
|
125
|
-
ConcurrencyLimitStrategy,
|
|
126
|
-
CreateWorkflowVersionOpts,
|
|
127
|
-
RateLimitDuration,
|
|
128
|
-
StickyStrategy,
|
|
129
|
-
WorkerLabelComparator,
|
|
130
|
-
)
|
|
131
131
|
from hatchet_sdk.v0.utils.aio_utils import sync_to_async
|
|
132
132
|
|
|
133
133
|
from .client import new_client
|
hatchet_sdk/v0/clients/admin.py
CHANGED
|
@@ -5,12 +5,7 @@ from typing import Any, Callable, Dict, List, Optional, TypedDict, TypeVar, Unio
|
|
|
5
5
|
import grpc
|
|
6
6
|
from google.protobuf import timestamp_pb2
|
|
7
7
|
|
|
8
|
-
from hatchet_sdk.
|
|
9
|
-
from hatchet_sdk.v0.clients.rest.tenacity_utils import tenacity_retry
|
|
10
|
-
from hatchet_sdk.v0.clients.run_event_listener import new_listener
|
|
11
|
-
from hatchet_sdk.v0.clients.workflow_listener import PooledWorkflowRunListener
|
|
12
|
-
from hatchet_sdk.v0.connection import new_conn
|
|
13
|
-
from hatchet_sdk.v0.contracts.workflows_pb2 import (
|
|
8
|
+
from hatchet_sdk.contracts.workflows_pb2 import (
|
|
14
9
|
BulkTriggerWorkflowRequest,
|
|
15
10
|
BulkTriggerWorkflowResponse,
|
|
16
11
|
CreateWorkflowVersionOpts,
|
|
@@ -22,7 +17,12 @@ from hatchet_sdk.v0.contracts.workflows_pb2 import (
|
|
|
22
17
|
TriggerWorkflowResponse,
|
|
23
18
|
WorkflowVersion,
|
|
24
19
|
)
|
|
25
|
-
from hatchet_sdk.
|
|
20
|
+
from hatchet_sdk.contracts.workflows_pb2_grpc import WorkflowServiceStub
|
|
21
|
+
from hatchet_sdk.v0.clients.rest.models.workflow_run import WorkflowRun
|
|
22
|
+
from hatchet_sdk.v0.clients.rest.tenacity_utils import tenacity_retry
|
|
23
|
+
from hatchet_sdk.v0.clients.run_event_listener import new_listener
|
|
24
|
+
from hatchet_sdk.v0.clients.workflow_listener import PooledWorkflowRunListener
|
|
25
|
+
from hatchet_sdk.v0.connection import new_conn
|
|
26
26
|
from hatchet_sdk.v0.workflow_run import RunRef, WorkflowRunRef
|
|
27
27
|
|
|
28
28
|
from ..loader import ClientConfig
|
|
@@ -7,12 +7,7 @@ from typing import Any, AsyncGenerator, List, Optional
|
|
|
7
7
|
import grpc
|
|
8
8
|
from grpc._cython import cygrpc
|
|
9
9
|
|
|
10
|
-
from hatchet_sdk.
|
|
11
|
-
from hatchet_sdk.v0.clients.run_event_listener import (
|
|
12
|
-
DEFAULT_ACTION_LISTENER_RETRY_INTERVAL,
|
|
13
|
-
)
|
|
14
|
-
from hatchet_sdk.v0.connection import new_conn
|
|
15
|
-
from hatchet_sdk.v0.contracts.dispatcher_pb2 import (
|
|
10
|
+
from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
16
11
|
ActionType,
|
|
17
12
|
AssignedAction,
|
|
18
13
|
HeartbeatRequest,
|
|
@@ -20,8 +15,13 @@ from hatchet_sdk.v0.contracts.dispatcher_pb2 import (
|
|
|
20
15
|
WorkerListenRequest,
|
|
21
16
|
WorkerUnsubscribeRequest,
|
|
22
17
|
)
|
|
23
|
-
from hatchet_sdk.
|
|
24
|
-
from hatchet_sdk.
|
|
18
|
+
from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
19
|
+
from hatchet_sdk.logger import logger
|
|
20
|
+
from hatchet_sdk.v0.clients.event_ts import ThreadSafeEvent, read_with_interrupt
|
|
21
|
+
from hatchet_sdk.v0.clients.run_event_listener import (
|
|
22
|
+
DEFAULT_ACTION_LISTENER_RETRY_INTERVAL,
|
|
23
|
+
)
|
|
24
|
+
from hatchet_sdk.v0.connection import new_conn
|
|
25
25
|
from hatchet_sdk.v0.utils.backoff import exp_backoff_sleep
|
|
26
26
|
|
|
27
27
|
from ...loader import ClientConfig
|
|
@@ -2,14 +2,7 @@ from typing import Any, cast
|
|
|
2
2
|
|
|
3
3
|
from google.protobuf.timestamp_pb2 import Timestamp
|
|
4
4
|
|
|
5
|
-
from hatchet_sdk.
|
|
6
|
-
Action,
|
|
7
|
-
ActionListener,
|
|
8
|
-
GetActionListenerRequest,
|
|
9
|
-
)
|
|
10
|
-
from hatchet_sdk.v0.clients.rest.tenacity_utils import tenacity_retry
|
|
11
|
-
from hatchet_sdk.v0.connection import new_conn
|
|
12
|
-
from hatchet_sdk.v0.contracts.dispatcher_pb2 import (
|
|
5
|
+
from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
13
6
|
STEP_EVENT_TYPE_COMPLETED,
|
|
14
7
|
STEP_EVENT_TYPE_FAILED,
|
|
15
8
|
ActionEventResponse,
|
|
@@ -25,7 +18,14 @@ from hatchet_sdk.v0.contracts.dispatcher_pb2 import (
|
|
|
25
18
|
WorkerRegisterRequest,
|
|
26
19
|
WorkerRegisterResponse,
|
|
27
20
|
)
|
|
28
|
-
from hatchet_sdk.
|
|
21
|
+
from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
22
|
+
from hatchet_sdk.v0.clients.dispatcher.action_listener import (
|
|
23
|
+
Action,
|
|
24
|
+
ActionListener,
|
|
25
|
+
GetActionListenerRequest,
|
|
26
|
+
)
|
|
27
|
+
from hatchet_sdk.v0.clients.rest.tenacity_utils import tenacity_retry
|
|
28
|
+
from hatchet_sdk.v0.connection import new_conn
|
|
29
29
|
|
|
30
30
|
from ...loader import ClientConfig
|
|
31
31
|
from ...metadata import get_metadata
|
hatchet_sdk/v0/clients/events.py
CHANGED
|
@@ -7,15 +7,15 @@ from uuid import uuid4
|
|
|
7
7
|
import grpc
|
|
8
8
|
from google.protobuf import timestamp_pb2
|
|
9
9
|
|
|
10
|
-
from hatchet_sdk.
|
|
11
|
-
from hatchet_sdk.v0.contracts.events_pb2 import (
|
|
10
|
+
from hatchet_sdk.contracts.events_pb2 import (
|
|
12
11
|
BulkPushEventRequest,
|
|
13
12
|
Event,
|
|
14
13
|
PushEventRequest,
|
|
15
14
|
PutLogRequest,
|
|
16
15
|
PutStreamEventRequest,
|
|
17
16
|
)
|
|
18
|
-
from hatchet_sdk.
|
|
17
|
+
from hatchet_sdk.contracts.events_pb2_grpc import EventsServiceStub
|
|
18
|
+
from hatchet_sdk.v0.clients.rest.tenacity_utils import tenacity_retry
|
|
19
19
|
|
|
20
20
|
from ..loader import ClientConfig
|
|
21
21
|
from ..metadata import get_metadata
|
|
@@ -4,15 +4,15 @@ from typing import AsyncGenerator
|
|
|
4
4
|
|
|
5
5
|
import grpc
|
|
6
6
|
|
|
7
|
-
from hatchet_sdk.
|
|
8
|
-
from hatchet_sdk.v0.contracts.dispatcher_pb2 import (
|
|
7
|
+
from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
9
8
|
RESOURCE_TYPE_STEP_RUN,
|
|
10
9
|
RESOURCE_TYPE_WORKFLOW_RUN,
|
|
11
10
|
ResourceEventType,
|
|
12
11
|
SubscribeToWorkflowEventsRequest,
|
|
13
12
|
WorkflowEvent,
|
|
14
13
|
)
|
|
15
|
-
from hatchet_sdk.
|
|
14
|
+
from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
15
|
+
from hatchet_sdk.v0.connection import new_conn
|
|
16
16
|
|
|
17
17
|
from ..loader import ClientConfig
|
|
18
18
|
from ..metadata import get_metadata
|
|
@@ -6,16 +6,16 @@ from typing import AsyncGenerator
|
|
|
6
6
|
import grpc
|
|
7
7
|
from grpc._cython import cygrpc
|
|
8
8
|
|
|
9
|
-
from hatchet_sdk.
|
|
10
|
-
from hatchet_sdk.v0.connection import new_conn
|
|
11
|
-
from hatchet_sdk.v0.contracts.dispatcher_pb2 import (
|
|
9
|
+
from hatchet_sdk.contracts.dispatcher_pb2 import (
|
|
12
10
|
SubscribeToWorkflowRunsRequest,
|
|
13
11
|
WorkflowRunEvent,
|
|
14
12
|
)
|
|
15
|
-
from hatchet_sdk.
|
|
13
|
+
from hatchet_sdk.contracts.dispatcher_pb2_grpc import DispatcherStub
|
|
14
|
+
from hatchet_sdk.v0.clients.event_ts import ThreadSafeEvent, read_with_interrupt
|
|
15
|
+
from hatchet_sdk.v0.connection import new_conn
|
|
16
16
|
|
|
17
|
+
from ...logger import logger
|
|
17
18
|
from ..loader import ClientConfig
|
|
18
|
-
from ..logger import logger
|
|
19
19
|
from ..metadata import get_metadata
|
|
20
20
|
|
|
21
21
|
DEFAULT_WORKFLOW_LISTENER_RETRY_INTERVAL = 3 # seconds
|
|
@@ -7,21 +7,22 @@ from warnings import warn
|
|
|
7
7
|
|
|
8
8
|
from pydantic import BaseModel, StrictStr
|
|
9
9
|
|
|
10
|
+
from hatchet_sdk.contracts.dispatcher_pb2 import OverridesData
|
|
11
|
+
from hatchet_sdk.contracts.workflows_pb2 import (
|
|
12
|
+
BulkTriggerWorkflowRequest,
|
|
13
|
+
TriggerWorkflowRequest,
|
|
14
|
+
)
|
|
10
15
|
from hatchet_sdk.v0.clients.events import EventClient
|
|
11
16
|
from hatchet_sdk.v0.clients.rest.tenacity_utils import tenacity_retry
|
|
12
17
|
from hatchet_sdk.v0.clients.rest_client import RestApi
|
|
13
18
|
from hatchet_sdk.v0.clients.run_event_listener import RunEventListenerClient
|
|
14
19
|
from hatchet_sdk.v0.clients.workflow_listener import PooledWorkflowRunListener
|
|
15
20
|
from hatchet_sdk.v0.context.worker_context import WorkerContext
|
|
16
|
-
from hatchet_sdk.v0.contracts.dispatcher_pb2 import OverridesData
|
|
17
|
-
from hatchet_sdk.v0.contracts.workflows_pb2 import (
|
|
18
|
-
BulkTriggerWorkflowRequest,
|
|
19
|
-
TriggerWorkflowRequest,
|
|
20
|
-
)
|
|
21
21
|
from hatchet_sdk.v0.utils.types import WorkflowValidator
|
|
22
22
|
from hatchet_sdk.v0.utils.typing import is_basemodel_subclass
|
|
23
23
|
from hatchet_sdk.v0.workflow_run import WorkflowRunRef
|
|
24
24
|
|
|
25
|
+
from ...logger import logger
|
|
25
26
|
from ..clients.admin import (
|
|
26
27
|
AdminClient,
|
|
27
28
|
ChildTriggerWorkflowOptions,
|
|
@@ -33,7 +34,6 @@ from ..clients.dispatcher.dispatcher import ( # type: ignore[attr-defined]
|
|
|
33
34
|
Action,
|
|
34
35
|
DispatcherClient,
|
|
35
36
|
)
|
|
36
|
-
from ..logger import logger
|
|
37
37
|
|
|
38
38
|
DEFAULT_WORKFLOW_POLLING_INTERVAL = 5 # Seconds
|
|
39
39
|
|
hatchet_sdk/v0/hatchet.py
CHANGED
|
@@ -5,14 +5,14 @@ from typing import Any, Callable, Optional, ParamSpec, Type, TypeVar, Union
|
|
|
5
5
|
from pydantic import BaseModel
|
|
6
6
|
from typing_extensions import deprecated
|
|
7
7
|
|
|
8
|
-
from hatchet_sdk.
|
|
9
|
-
from hatchet_sdk.v0.context.context import Context
|
|
10
|
-
from hatchet_sdk.v0.contracts.workflows_pb2 import (
|
|
8
|
+
from hatchet_sdk.contracts.workflows_pb2 import (
|
|
11
9
|
ConcurrencyLimitStrategy,
|
|
12
10
|
CreateStepRateLimit,
|
|
13
11
|
DesiredWorkerLabels,
|
|
14
12
|
StickyStrategy,
|
|
15
13
|
)
|
|
14
|
+
from hatchet_sdk.v0.clients.rest_client import RestApi
|
|
15
|
+
from hatchet_sdk.v0.context.context import Context
|
|
16
16
|
from hatchet_sdk.v0.features.cron import CronClient
|
|
17
17
|
from hatchet_sdk.v0.features.scheduled import ScheduledClient
|
|
18
18
|
from hatchet_sdk.v0.labels import DesiredWorkerLabel
|
|
@@ -20,12 +20,12 @@ from hatchet_sdk.v0.loader import ClientConfig, ConfigLoader
|
|
|
20
20
|
from hatchet_sdk.v0.rate_limit import RateLimit
|
|
21
21
|
from hatchet_sdk.v0.v2.callable import HatchetCallable
|
|
22
22
|
|
|
23
|
+
from ..logger import logger
|
|
23
24
|
from .client import Client, new_client, new_client_raw
|
|
24
25
|
from .clients.admin import AdminClient
|
|
25
26
|
from .clients.dispatcher.dispatcher import DispatcherClient
|
|
26
27
|
from .clients.events import EventClient
|
|
27
28
|
from .clients.run_event_listener import RunEventListenerClient
|
|
28
|
-
from .logger import logger
|
|
29
29
|
from .worker.worker import Worker
|
|
30
30
|
from .workflow import (
|
|
31
31
|
ConcurrencyExpression,
|
|
@@ -25,6 +25,7 @@ except (RuntimeError, ImportError, ModuleNotFoundError):
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
import hatchet_sdk
|
|
28
|
+
from hatchet_sdk.contracts.events_pb2 import Event
|
|
28
29
|
from hatchet_sdk.v0.clients.admin import (
|
|
29
30
|
AdminClient,
|
|
30
31
|
TriggerWorkflowOptions,
|
|
@@ -36,7 +37,6 @@ from hatchet_sdk.v0.clients.events import (
|
|
|
36
37
|
EventClient,
|
|
37
38
|
PushEventOptions,
|
|
38
39
|
)
|
|
39
|
-
from hatchet_sdk.v0.contracts.events_pb2 import Event
|
|
40
40
|
from hatchet_sdk.v0.worker.runner.runner import Runner
|
|
41
41
|
from hatchet_sdk.v0.workflow_run import WorkflowRunRef
|
|
42
42
|
|
hatchet_sdk/v0/rate_limit.py
CHANGED
|
@@ -3,7 +3,7 @@ from typing import Union
|
|
|
3
3
|
|
|
4
4
|
from celpy import CELEvalError, Environment
|
|
5
5
|
|
|
6
|
-
from hatchet_sdk.
|
|
6
|
+
from hatchet_sdk.contracts.workflows_pb2 import CreateStepRateLimit
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def validate_cel_expression(expr: str) -> bool:
|