hatchet-sdk 1.12.3__py3-none-any.whl → 1.13.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 +46 -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/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 +99 -1
- hatchet_sdk/features/cron.py +2 -2
- hatchet_sdk/features/filters.py +3 -3
- 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/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 +102 -92
- hatchet_sdk/worker/runner/utils/capture_logs.py +72 -31
- hatchet_sdk/worker/worker.py +29 -25
- hatchet_sdk/workflow_run.py +4 -2
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.13.0.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.13.0.dist-info}/RECORD +48 -48
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.13.0.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.12.3.dist-info → hatchet_sdk-1.13.0.dist-info}/entry_points.txt +0 -0
|
@@ -16,7 +16,7 @@ from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__
|
|
|
16
16
|
from hatchet_sdk.contracts.v1.shared import condition_pb2 as v1_dot_shared_dot_condition__pb2
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12v1/workflows.proto\x12\x02v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x19v1/shared/condition.proto\"Z\n\x12\x43\x61ncelTasksRequest\x12\x13\n\x0b\x65xternalIds\x18\x01 \x03(\t\x12$\n\x06\x66ilter\x18\x02 \x01(\x0b\x32\x0f.v1.TasksFilterH\x00\x88\x01\x01\x42\t\n\x07_filter\"Z\n\x12ReplayTasksRequest\x12\x13\n\x0b\x65xternalIds\x18\x01 \x03(\t\x12$\n\x06\x66ilter\x18\x02 \x01(\x0b\x32\x0f.v1.TasksFilterH\x00\x88\x01\x01\x42\t\n\x07_filter\"\xb7\x01\n\x0bTasksFilter\x12\x10\n\x08statuses\x18\x01 \x03(\t\x12)\n\x05since\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\x05until\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x88\x01\x01\x12\x14\n\x0cworkflow_ids\x18\x04 \x03(\t\x12\x1b\n\x13\x61\x64\x64itional_metadata\x18\x05 \x03(\tB\x08\n\x06_until\".\n\x13\x43\x61ncelTasksResponse\x12\x17\n\x0f\x63\x61ncelled_tasks\x18\x01 \x03(\t\"-\n\x13ReplayTasksResponse\x12\x16\n\x0ereplayed_tasks\x18\x01 \x03(\t\"\x82\x01\n\x19TriggerWorkflowRunRequest\x12\x15\n\rworkflow_name\x18\x01 \x01(\t\x12\r\n\x05input\x18\x02 \x01(\x0c\x12\x1b\n\x13\x61\x64\x64itional_metadata\x18\x03 \x01(\x0c\x12\x15\n\x08priority\x18\x04 \x01(\x05H\x00\x88\x01\x01\x42\x0b\n\t_priority\"1\n\x1aTriggerWorkflowRunResponse\x12\x13\n\x0b\x65xternal_id\x18\x01 \x01(\t\"\xf6\x03\n\x1c\x43reateWorkflowVersionRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x0f\n\x07version\x18\x03 \x01(\t\x12\x16\n\x0e\x65vent_triggers\x18\x04 \x03(\t\x12\x15\n\rcron_triggers\x18\x05 \x03(\t\x12!\n\x05tasks\x18\x06 \x03(\x0b\x32\x12.v1.CreateTaskOpts\x12$\n\x0b\x63oncurrency\x18\x07 \x01(\x0b\x32\x0f.v1.Concurrency\x12\x17\n\ncron_input\x18\x08 \x01(\tH\x00\x88\x01\x01\x12\x30\n\x0fon_failure_task\x18\t \x01(\x0b\x32\x12.v1.CreateTaskOptsH\x01\x88\x01\x01\x12\'\n\x06sticky\x18\n \x01(\x0e\x32\x12.v1.StickyStrategyH\x02\x88\x01\x01\x12\x1d\n\x10\x64\x65\x66\x61ult_priority\x18\x0b \x01(\x05H\x03\x88\x01\x01\x12(\n\x0f\x63oncurrency_arr\x18\x0c \x03(\x0b\x32\x0f.v1.Concurrency\x12*\n\x0f\x64\x65\x66\x61ult_filters\x18\r \x03(\x0b\x32\x11.v1.DefaultFilterB\r\n\x0b_cron_inputB\x12\n\x10_on_failure_taskB\t\n\x07_stickyB\x13\n\x11_default_priority\"T\n\rDefaultFilter\x12\x12\n\nexpression\x18\x01 \x01(\t\x12\r\n\x05scope\x18\x02 \x01(\t\x12\x14\n\x07payload\x18\x03 \x01(\
|
|
19
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12v1/workflows.proto\x12\x02v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x19v1/shared/condition.proto\"Z\n\x12\x43\x61ncelTasksRequest\x12\x13\n\x0b\x65xternalIds\x18\x01 \x03(\t\x12$\n\x06\x66ilter\x18\x02 \x01(\x0b\x32\x0f.v1.TasksFilterH\x00\x88\x01\x01\x42\t\n\x07_filter\"Z\n\x12ReplayTasksRequest\x12\x13\n\x0b\x65xternalIds\x18\x01 \x03(\t\x12$\n\x06\x66ilter\x18\x02 \x01(\x0b\x32\x0f.v1.TasksFilterH\x00\x88\x01\x01\x42\t\n\x07_filter\"\xb7\x01\n\x0bTasksFilter\x12\x10\n\x08statuses\x18\x01 \x03(\t\x12)\n\x05since\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12.\n\x05until\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x88\x01\x01\x12\x14\n\x0cworkflow_ids\x18\x04 \x03(\t\x12\x1b\n\x13\x61\x64\x64itional_metadata\x18\x05 \x03(\tB\x08\n\x06_until\".\n\x13\x43\x61ncelTasksResponse\x12\x17\n\x0f\x63\x61ncelled_tasks\x18\x01 \x03(\t\"-\n\x13ReplayTasksResponse\x12\x16\n\x0ereplayed_tasks\x18\x01 \x03(\t\"\x82\x01\n\x19TriggerWorkflowRunRequest\x12\x15\n\rworkflow_name\x18\x01 \x01(\t\x12\r\n\x05input\x18\x02 \x01(\x0c\x12\x1b\n\x13\x61\x64\x64itional_metadata\x18\x03 \x01(\x0c\x12\x15\n\x08priority\x18\x04 \x01(\x05H\x00\x88\x01\x01\x42\x0b\n\t_priority\"1\n\x1aTriggerWorkflowRunResponse\x12\x13\n\x0b\x65xternal_id\x18\x01 \x01(\t\"\xf6\x03\n\x1c\x43reateWorkflowVersionRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x0f\n\x07version\x18\x03 \x01(\t\x12\x16\n\x0e\x65vent_triggers\x18\x04 \x03(\t\x12\x15\n\rcron_triggers\x18\x05 \x03(\t\x12!\n\x05tasks\x18\x06 \x03(\x0b\x32\x12.v1.CreateTaskOpts\x12$\n\x0b\x63oncurrency\x18\x07 \x01(\x0b\x32\x0f.v1.Concurrency\x12\x17\n\ncron_input\x18\x08 \x01(\tH\x00\x88\x01\x01\x12\x30\n\x0fon_failure_task\x18\t \x01(\x0b\x32\x12.v1.CreateTaskOptsH\x01\x88\x01\x01\x12\'\n\x06sticky\x18\n \x01(\x0e\x32\x12.v1.StickyStrategyH\x02\x88\x01\x01\x12\x1d\n\x10\x64\x65\x66\x61ult_priority\x18\x0b \x01(\x05H\x03\x88\x01\x01\x12(\n\x0f\x63oncurrency_arr\x18\x0c \x03(\x0b\x32\x0f.v1.Concurrency\x12*\n\x0f\x64\x65\x66\x61ult_filters\x18\r \x03(\x0b\x32\x11.v1.DefaultFilterB\r\n\x0b_cron_inputB\x12\n\x10_on_failure_taskB\t\n\x07_stickyB\x13\n\x11_default_priority\"T\n\rDefaultFilter\x12\x12\n\nexpression\x18\x01 \x01(\t\x12\r\n\x05scope\x18\x02 \x01(\t\x12\x14\n\x07payload\x18\x03 \x01(\x0cH\x00\x88\x01\x01\x42\n\n\x08_payload\"\x93\x01\n\x0b\x43oncurrency\x12\x12\n\nexpression\x18\x01 \x01(\t\x12\x15\n\x08max_runs\x18\x02 \x01(\x05H\x00\x88\x01\x01\x12\x39\n\x0elimit_strategy\x18\x03 \x01(\x0e\x32\x1c.v1.ConcurrencyLimitStrategyH\x01\x88\x01\x01\x42\x0b\n\t_max_runsB\x11\n\x0f_limit_strategy\"\xe4\x01\n\x13\x44\x65siredWorkerLabels\x12\x15\n\x08strValue\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x15\n\x08intValue\x18\x02 \x01(\x05H\x01\x88\x01\x01\x12\x15\n\x08required\x18\x03 \x01(\x08H\x02\x88\x01\x01\x12\x32\n\ncomparator\x18\x04 \x01(\x0e\x32\x19.v1.WorkerLabelComparatorH\x03\x88\x01\x01\x12\x13\n\x06weight\x18\x05 \x01(\x05H\x04\x88\x01\x01\x42\x0b\n\t_strValueB\x0b\n\t_intValueB\x0b\n\t_requiredB\r\n\x0b_comparatorB\t\n\x07_weight\"\xb1\x04\n\x0e\x43reateTaskOpts\x12\x13\n\x0breadable_id\x18\x01 \x01(\t\x12\x0e\n\x06\x61\x63tion\x18\x02 \x01(\t\x12\x0f\n\x07timeout\x18\x03 \x01(\t\x12\x0e\n\x06inputs\x18\x04 \x01(\t\x12\x0f\n\x07parents\x18\x05 \x03(\t\x12\x0f\n\x07retries\x18\x06 \x01(\x05\x12,\n\x0brate_limits\x18\x07 \x03(\x0b\x32\x17.v1.CreateTaskRateLimit\x12;\n\rworker_labels\x18\x08 \x03(\x0b\x32$.v1.CreateTaskOpts.WorkerLabelsEntry\x12\x1b\n\x0e\x62\x61\x63koff_factor\x18\t \x01(\x02H\x00\x88\x01\x01\x12 \n\x13\x62\x61\x63koff_max_seconds\x18\n \x01(\x05H\x01\x88\x01\x01\x12$\n\x0b\x63oncurrency\x18\x0b \x03(\x0b\x32\x0f.v1.Concurrency\x12+\n\nconditions\x18\x0c \x01(\x0b\x32\x12.v1.TaskConditionsH\x02\x88\x01\x01\x12\x1d\n\x10schedule_timeout\x18\r \x01(\tH\x03\x88\x01\x01\x1aL\n\x11WorkerLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.v1.DesiredWorkerLabels:\x02\x38\x01\x42\x11\n\x0f_backoff_factorB\x16\n\x14_backoff_max_secondsB\r\n\x0b_conditionsB\x13\n\x11_schedule_timeout\"\xfd\x01\n\x13\x43reateTaskRateLimit\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x12\n\x05units\x18\x02 \x01(\x05H\x00\x88\x01\x01\x12\x15\n\x08key_expr\x18\x03 \x01(\tH\x01\x88\x01\x01\x12\x17\n\nunits_expr\x18\x04 \x01(\tH\x02\x88\x01\x01\x12\x1e\n\x11limit_values_expr\x18\x05 \x01(\tH\x03\x88\x01\x01\x12,\n\x08\x64uration\x18\x06 \x01(\x0e\x32\x15.v1.RateLimitDurationH\x04\x88\x01\x01\x42\x08\n\x06_unitsB\x0b\n\t_key_exprB\r\n\x0b_units_exprB\x14\n\x12_limit_values_exprB\x0b\n\t_duration\"@\n\x1d\x43reateWorkflowVersionResponse\x12\n\n\x02id\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t*$\n\x0eStickyStrategy\x12\x08\n\x04SOFT\x10\x00\x12\x08\n\x04HARD\x10\x01*]\n\x11RateLimitDuration\x12\n\n\x06SECOND\x10\x00\x12\n\n\x06MINUTE\x10\x01\x12\x08\n\x04HOUR\x10\x02\x12\x07\n\x03\x44\x41Y\x10\x03\x12\x08\n\x04WEEK\x10\x04\x12\t\n\x05MONTH\x10\x05\x12\x08\n\x04YEAR\x10\x06*\x7f\n\x18\x43oncurrencyLimitStrategy\x12\x16\n\x12\x43\x41NCEL_IN_PROGRESS\x10\x00\x12\x0f\n\x0b\x44ROP_NEWEST\x10\x01\x12\x10\n\x0cQUEUE_NEWEST\x10\x02\x12\x15\n\x11GROUP_ROUND_ROBIN\x10\x03\x12\x11\n\rCANCEL_NEWEST\x10\x04*\x85\x01\n\x15WorkerLabelComparator\x12\t\n\x05\x45QUAL\x10\x00\x12\r\n\tNOT_EQUAL\x10\x01\x12\x10\n\x0cGREATER_THAN\x10\x02\x12\x19\n\x15GREATER_THAN_OR_EQUAL\x10\x03\x12\r\n\tLESS_THAN\x10\x04\x12\x16\n\x12LESS_THAN_OR_EQUAL\x10\x05\x32\xb7\x02\n\x0c\x41\x64minService\x12R\n\x0bPutWorkflow\x12 .v1.CreateWorkflowVersionRequest\x1a!.v1.CreateWorkflowVersionResponse\x12>\n\x0b\x43\x61ncelTasks\x12\x16.v1.CancelTasksRequest\x1a\x17.v1.CancelTasksResponse\x12>\n\x0bReplayTasks\x12\x16.v1.ReplayTasksRequest\x1a\x17.v1.ReplayTasksResponse\x12S\n\x12TriggerWorkflowRun\x12\x1d.v1.TriggerWorkflowRunRequest\x1a\x1e.v1.TriggerWorkflowRunResponseBBZ@github.com/hatchet-dev/hatchet/internal/services/shared/proto/v1b\x06proto3')
|
|
20
20
|
|
|
21
21
|
_globals = globals()
|
|
22
22
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
@@ -157,8 +157,8 @@ class DefaultFilter(_message.Message):
|
|
|
157
157
|
PAYLOAD_FIELD_NUMBER: _ClassVar[int]
|
|
158
158
|
expression: str
|
|
159
159
|
scope: str
|
|
160
|
-
payload:
|
|
161
|
-
def __init__(self, expression: _Optional[str] = ..., scope: _Optional[str] = ..., payload: _Optional[
|
|
160
|
+
payload: bytes
|
|
161
|
+
def __init__(self, expression: _Optional[str] = ..., scope: _Optional[str] = ..., payload: _Optional[bytes] = ...) -> None: ...
|
|
162
162
|
|
|
163
163
|
class Concurrency(_message.Message):
|
|
164
164
|
__slots__ = ("expression", "max_runs", "limit_strategy")
|
hatchet_sdk/exceptions.py
CHANGED
|
@@ -1,2 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
import traceback
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class NonRetryableException(Exception): # noqa: N818
|
|
5
|
+
pass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class DedupeViolationError(Exception):
|
|
9
|
+
"""Raised by the Hatchet library to indicate that a workflow has already been run with this deduplication value."""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TaskRunError(Exception):
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
exc: str,
|
|
16
|
+
exc_type: str,
|
|
17
|
+
trace: str,
|
|
18
|
+
) -> None:
|
|
19
|
+
self.exc = exc
|
|
20
|
+
self.exc_type = exc_type
|
|
21
|
+
self.trace = trace
|
|
22
|
+
|
|
23
|
+
def __str__(self) -> str:
|
|
24
|
+
return self.serialize()
|
|
25
|
+
|
|
26
|
+
def __repr__(self) -> str:
|
|
27
|
+
return str(self)
|
|
28
|
+
|
|
29
|
+
def serialize(self) -> str:
|
|
30
|
+
if not self.exc_type or not self.exc:
|
|
31
|
+
return ""
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
self.exc_type.replace(": ", ":::")
|
|
35
|
+
+ ": "
|
|
36
|
+
+ self.exc.replace("\n", "\\\n")
|
|
37
|
+
+ "\n"
|
|
38
|
+
+ self.trace
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def deserialize(cls, serialized: str) -> "TaskRunError":
|
|
43
|
+
if not serialized:
|
|
44
|
+
return cls(
|
|
45
|
+
exc="",
|
|
46
|
+
exc_type="",
|
|
47
|
+
trace="",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
header, trace = serialized.split("\n", 1)
|
|
52
|
+
exc_type, exc = header.split(": ", 1)
|
|
53
|
+
except ValueError:
|
|
54
|
+
## If we get here, we saw an error that was not serialized how we expected,
|
|
55
|
+
## but was also not empty. So we return it as-is and use `HatchetError` as the type.
|
|
56
|
+
return cls(
|
|
57
|
+
exc=serialized,
|
|
58
|
+
exc_type="HatchetError",
|
|
59
|
+
trace="",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
exc_type = exc_type.replace(":::", ": ")
|
|
63
|
+
exc = exc.replace("\\\n", "\n")
|
|
64
|
+
|
|
65
|
+
return cls(
|
|
66
|
+
exc=exc,
|
|
67
|
+
exc_type=exc_type,
|
|
68
|
+
trace=trace,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def from_exception(cls, exc: Exception) -> "TaskRunError":
|
|
73
|
+
return cls(
|
|
74
|
+
exc=str(exc),
|
|
75
|
+
exc_type=type(exc).__name__,
|
|
76
|
+
trace="".join(
|
|
77
|
+
traceback.format_exception(type(exc), exc, exc.__traceback__)
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class FailedTaskRunExceptionGroup(Exception): # noqa: N818
|
|
83
|
+
def __init__(self, message: str, exceptions: list[TaskRunError]):
|
|
84
|
+
self.message = message
|
|
85
|
+
self.exceptions = exceptions
|
|
86
|
+
|
|
87
|
+
super().__init__(message)
|
|
88
|
+
|
|
89
|
+
def __str__(self) -> str:
|
|
90
|
+
result = [self.message.strip()]
|
|
91
|
+
|
|
92
|
+
for i, exc in enumerate(self.exceptions, 1):
|
|
93
|
+
result.append(f"\n--- Exception {i} ---")
|
|
94
|
+
result.append(str(exc))
|
|
95
|
+
|
|
96
|
+
return "\n".join(result)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class LoopAlreadyRunningError(Exception):
|
|
2
100
|
pass
|
hatchet_sdk/features/cron.py
CHANGED
|
@@ -106,8 +106,8 @@ class CronClient(BaseRestClient):
|
|
|
106
106
|
create_cron_workflow_trigger_request=CreateCronWorkflowTriggerRequest(
|
|
107
107
|
cronName=cron_name,
|
|
108
108
|
cronExpression=validated_input.expression,
|
|
109
|
-
input=
|
|
110
|
-
additionalMetadata=
|
|
109
|
+
input=validated_input.input,
|
|
110
|
+
additionalMetadata=validated_input.additional_metadata,
|
|
111
111
|
priority=priority,
|
|
112
112
|
),
|
|
113
113
|
)
|
hatchet_sdk/features/filters.py
CHANGED
|
@@ -111,7 +111,7 @@ class FiltersClient(BaseRestClient):
|
|
|
111
111
|
workflow_id: str,
|
|
112
112
|
expression: str,
|
|
113
113
|
scope: str,
|
|
114
|
-
payload: JSONSerializableMapping =
|
|
114
|
+
payload: JSONSerializableMapping | None = None,
|
|
115
115
|
) -> V1Filter:
|
|
116
116
|
"""
|
|
117
117
|
Create a new filter.
|
|
@@ -130,7 +130,7 @@ class FiltersClient(BaseRestClient):
|
|
|
130
130
|
workflowId=workflow_id,
|
|
131
131
|
expression=expression,
|
|
132
132
|
scope=scope,
|
|
133
|
-
payload=
|
|
133
|
+
payload=payload,
|
|
134
134
|
),
|
|
135
135
|
)
|
|
136
136
|
|
|
@@ -139,7 +139,7 @@ class FiltersClient(BaseRestClient):
|
|
|
139
139
|
workflow_id: str,
|
|
140
140
|
expression: str,
|
|
141
141
|
scope: str,
|
|
142
|
-
payload: JSONSerializableMapping =
|
|
142
|
+
payload: JSONSerializableMapping | None = None,
|
|
143
143
|
) -> V1Filter:
|
|
144
144
|
"""
|
|
145
145
|
Create a new filter.
|
hatchet_sdk/features/runs.py
CHANGED
|
@@ -247,7 +247,7 @@ class RunsClient(BaseRestClient):
|
|
|
247
247
|
self,
|
|
248
248
|
workflow_name: str,
|
|
249
249
|
input: JSONSerializableMapping,
|
|
250
|
-
additional_metadata: JSONSerializableMapping =
|
|
250
|
+
additional_metadata: JSONSerializableMapping | None = None,
|
|
251
251
|
priority: int | None = None,
|
|
252
252
|
) -> V1WorkflowRunDetails:
|
|
253
253
|
"""
|
|
@@ -267,8 +267,8 @@ class RunsClient(BaseRestClient):
|
|
|
267
267
|
tenant=self.client_config.tenant_id,
|
|
268
268
|
v1_trigger_workflow_run_request=V1TriggerWorkflowRunRequest(
|
|
269
269
|
workflowName=self.client_config.apply_namespace(workflow_name),
|
|
270
|
-
input=
|
|
271
|
-
additionalMetadata=
|
|
270
|
+
input=input,
|
|
271
|
+
additionalMetadata=additional_metadata,
|
|
272
272
|
priority=priority,
|
|
273
273
|
),
|
|
274
274
|
)
|
|
@@ -277,7 +277,7 @@ class RunsClient(BaseRestClient):
|
|
|
277
277
|
self,
|
|
278
278
|
workflow_name: str,
|
|
279
279
|
input: JSONSerializableMapping,
|
|
280
|
-
additional_metadata: JSONSerializableMapping =
|
|
280
|
+
additional_metadata: JSONSerializableMapping | None = None,
|
|
281
281
|
priority: int | None = None,
|
|
282
282
|
) -> V1WorkflowRunDetails:
|
|
283
283
|
"""
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import datetime
|
|
3
|
-
from typing import Optional
|
|
4
3
|
|
|
5
4
|
from hatchet_sdk.clients.rest.api.workflow_api import WorkflowApi
|
|
6
5
|
from hatchet_sdk.clients.rest.api.workflow_run_api import WorkflowRunApi
|
|
@@ -62,8 +61,8 @@ class ScheduledClient(BaseRestClient):
|
|
|
62
61
|
workflow=self.client_config.apply_namespace(workflow_name),
|
|
63
62
|
schedule_workflow_run_request=ScheduleWorkflowRunRequest(
|
|
64
63
|
triggerAt=trigger_at,
|
|
65
|
-
input=
|
|
66
|
-
additionalMetadata=
|
|
64
|
+
input=input,
|
|
65
|
+
additionalMetadata=additional_metadata,
|
|
67
66
|
),
|
|
68
67
|
)
|
|
69
68
|
|
|
@@ -124,9 +123,9 @@ class ScheduledClient(BaseRestClient):
|
|
|
124
123
|
workflow_id: str | None = None,
|
|
125
124
|
parent_workflow_run_id: str | None = None,
|
|
126
125
|
statuses: list[ScheduledRunStatus] | None = None,
|
|
127
|
-
additional_metadata:
|
|
128
|
-
order_by_field:
|
|
129
|
-
order_by_direction:
|
|
126
|
+
additional_metadata: JSONSerializableMapping | None = None,
|
|
127
|
+
order_by_field: ScheduledWorkflowsOrderByField | None = None,
|
|
128
|
+
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
130
129
|
) -> ScheduledWorkflowsList:
|
|
131
130
|
"""
|
|
132
131
|
Retrieves a list of scheduled workflows based on provided filters.
|
|
@@ -161,9 +160,9 @@ class ScheduledClient(BaseRestClient):
|
|
|
161
160
|
workflow_id: str | None = None,
|
|
162
161
|
parent_workflow_run_id: str | None = None,
|
|
163
162
|
statuses: list[ScheduledRunStatus] | None = None,
|
|
164
|
-
additional_metadata:
|
|
165
|
-
order_by_field:
|
|
166
|
-
order_by_direction:
|
|
163
|
+
additional_metadata: JSONSerializableMapping | None = None,
|
|
164
|
+
order_by_field: ScheduledWorkflowsOrderByField | None = None,
|
|
165
|
+
order_by_direction: WorkflowRunOrderByDirection | None = None,
|
|
167
166
|
) -> ScheduledWorkflowsList:
|
|
168
167
|
"""
|
|
169
168
|
Retrieves a list of scheduled workflows based on provided filters.
|
hatchet_sdk/hatchet.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import logging
|
|
3
|
+
from collections.abc import Callable
|
|
3
4
|
from datetime import timedelta
|
|
4
5
|
from functools import cached_property
|
|
5
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, cast, overload
|
|
6
7
|
|
|
7
8
|
from hatchet_sdk import Context, DurableContext
|
|
8
9
|
from hatchet_sdk.client import Client
|
|
@@ -181,8 +182,8 @@ class Hatchet:
|
|
|
181
182
|
name: str,
|
|
182
183
|
slots: int = 100,
|
|
183
184
|
durable_slots: int = 1_000,
|
|
184
|
-
labels: dict[str,
|
|
185
|
-
workflows: list[BaseWorkflow[Any]] =
|
|
185
|
+
labels: dict[str, str | int] | None = None,
|
|
186
|
+
workflows: list[BaseWorkflow[Any]] | None = None,
|
|
186
187
|
lifespan: LifespanFn | None = None,
|
|
187
188
|
) -> Worker:
|
|
188
189
|
"""
|
|
@@ -227,14 +228,14 @@ class Hatchet:
|
|
|
227
228
|
name: str,
|
|
228
229
|
description: str | None = None,
|
|
229
230
|
input_validator: None = None,
|
|
230
|
-
on_events: list[str] =
|
|
231
|
-
on_crons: list[str] =
|
|
231
|
+
on_events: list[str] | None = None,
|
|
232
|
+
on_crons: list[str] | None = None,
|
|
232
233
|
version: str | None = None,
|
|
233
234
|
sticky: StickyStrategy | None = None,
|
|
234
235
|
default_priority: int = 1,
|
|
235
236
|
concurrency: ConcurrencyExpression | list[ConcurrencyExpression] | None = None,
|
|
236
237
|
task_defaults: TaskDefaults = TaskDefaults(),
|
|
237
|
-
default_filters: list[DefaultFilter] =
|
|
238
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
238
239
|
) -> Workflow[EmptyModel]: ...
|
|
239
240
|
|
|
240
241
|
@overload
|
|
@@ -243,15 +244,15 @@ class Hatchet:
|
|
|
243
244
|
*,
|
|
244
245
|
name: str,
|
|
245
246
|
description: str | None = None,
|
|
246
|
-
input_validator:
|
|
247
|
-
on_events: list[str] =
|
|
248
|
-
on_crons: list[str] =
|
|
247
|
+
input_validator: type[TWorkflowInput],
|
|
248
|
+
on_events: list[str] | None = None,
|
|
249
|
+
on_crons: list[str] | None = None,
|
|
249
250
|
version: str | None = None,
|
|
250
251
|
sticky: StickyStrategy | None = None,
|
|
251
252
|
default_priority: int = 1,
|
|
252
253
|
concurrency: ConcurrencyExpression | list[ConcurrencyExpression] | None = None,
|
|
253
254
|
task_defaults: TaskDefaults = TaskDefaults(),
|
|
254
|
-
default_filters: list[DefaultFilter] =
|
|
255
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
255
256
|
) -> Workflow[TWorkflowInput]: ...
|
|
256
257
|
|
|
257
258
|
def workflow(
|
|
@@ -259,15 +260,15 @@ class Hatchet:
|
|
|
259
260
|
*,
|
|
260
261
|
name: str,
|
|
261
262
|
description: str | None = None,
|
|
262
|
-
input_validator:
|
|
263
|
-
on_events: list[str] =
|
|
264
|
-
on_crons: list[str] =
|
|
263
|
+
input_validator: type[TWorkflowInput] | None = None,
|
|
264
|
+
on_events: list[str] | None = None,
|
|
265
|
+
on_crons: list[str] | None = None,
|
|
265
266
|
version: str | None = None,
|
|
266
267
|
sticky: StickyStrategy | None = None,
|
|
267
268
|
default_priority: int = 1,
|
|
268
269
|
concurrency: ConcurrencyExpression | list[ConcurrencyExpression] | None = None,
|
|
269
270
|
task_defaults: TaskDefaults = TaskDefaults(),
|
|
270
|
-
default_filters: list[DefaultFilter] =
|
|
271
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
271
272
|
) -> Workflow[EmptyModel] | Workflow[TWorkflowInput]:
|
|
272
273
|
"""
|
|
273
274
|
Define a Hatchet workflow, which can then declare `task`s and be `run`, `schedule`d, and so on.
|
|
@@ -302,15 +303,15 @@ class Hatchet:
|
|
|
302
303
|
name=name,
|
|
303
304
|
version=version,
|
|
304
305
|
description=description,
|
|
305
|
-
on_events=on_events,
|
|
306
|
-
on_crons=on_crons,
|
|
306
|
+
on_events=on_events or [],
|
|
307
|
+
on_crons=on_crons or [],
|
|
307
308
|
sticky=sticky,
|
|
308
309
|
concurrency=concurrency,
|
|
309
310
|
input_validator=input_validator
|
|
310
|
-
or cast(
|
|
311
|
+
or cast(type[TWorkflowInput], EmptyModel),
|
|
311
312
|
task_defaults=task_defaults,
|
|
312
313
|
default_priority=default_priority,
|
|
313
|
-
default_filters=default_filters,
|
|
314
|
+
default_filters=default_filters or [],
|
|
314
315
|
),
|
|
315
316
|
self,
|
|
316
317
|
)
|
|
@@ -322,8 +323,8 @@ class Hatchet:
|
|
|
322
323
|
name: str | None = None,
|
|
323
324
|
description: str | None = None,
|
|
324
325
|
input_validator: None = None,
|
|
325
|
-
on_events: list[str] =
|
|
326
|
-
on_crons: list[str] =
|
|
326
|
+
on_events: list[str] | None = None,
|
|
327
|
+
on_crons: list[str] | None = None,
|
|
327
328
|
version: str | None = None,
|
|
328
329
|
sticky: StickyStrategy | None = None,
|
|
329
330
|
default_priority: int = 1,
|
|
@@ -331,11 +332,11 @@ class Hatchet:
|
|
|
331
332
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
332
333
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
333
334
|
retries: int = 0,
|
|
334
|
-
rate_limits: list[RateLimit] =
|
|
335
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
335
|
+
rate_limits: list[RateLimit] | None = None,
|
|
336
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
336
337
|
backoff_factor: float | None = None,
|
|
337
338
|
backoff_max_seconds: int | None = None,
|
|
338
|
-
default_filters: list[DefaultFilter] =
|
|
339
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
339
340
|
) -> Callable[
|
|
340
341
|
[Callable[[EmptyModel, Context], R | CoroutineLike[R]]],
|
|
341
342
|
Standalone[EmptyModel, R],
|
|
@@ -347,9 +348,9 @@ class Hatchet:
|
|
|
347
348
|
*,
|
|
348
349
|
name: str | None = None,
|
|
349
350
|
description: str | None = None,
|
|
350
|
-
input_validator:
|
|
351
|
-
on_events: list[str] =
|
|
352
|
-
on_crons: list[str] =
|
|
351
|
+
input_validator: type[TWorkflowInput],
|
|
352
|
+
on_events: list[str] | None = None,
|
|
353
|
+
on_crons: list[str] | None = None,
|
|
353
354
|
version: str | None = None,
|
|
354
355
|
sticky: StickyStrategy | None = None,
|
|
355
356
|
default_priority: int = 1,
|
|
@@ -357,11 +358,11 @@ class Hatchet:
|
|
|
357
358
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
358
359
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
359
360
|
retries: int = 0,
|
|
360
|
-
rate_limits: list[RateLimit] =
|
|
361
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
361
|
+
rate_limits: list[RateLimit] | None = None,
|
|
362
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
362
363
|
backoff_factor: float | None = None,
|
|
363
364
|
backoff_max_seconds: int | None = None,
|
|
364
|
-
default_filters: list[DefaultFilter] =
|
|
365
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
365
366
|
) -> Callable[
|
|
366
367
|
[Callable[[TWorkflowInput, Context], R | CoroutineLike[R]]],
|
|
367
368
|
Standalone[TWorkflowInput, R],
|
|
@@ -372,9 +373,9 @@ class Hatchet:
|
|
|
372
373
|
*,
|
|
373
374
|
name: str | None = None,
|
|
374
375
|
description: str | None = None,
|
|
375
|
-
input_validator:
|
|
376
|
-
on_events: list[str] =
|
|
377
|
-
on_crons: list[str] =
|
|
376
|
+
input_validator: type[TWorkflowInput] | None = None,
|
|
377
|
+
on_events: list[str] | None = None,
|
|
378
|
+
on_crons: list[str] | None = None,
|
|
378
379
|
version: str | None = None,
|
|
379
380
|
sticky: StickyStrategy | None = None,
|
|
380
381
|
default_priority: int = 1,
|
|
@@ -382,11 +383,11 @@ class Hatchet:
|
|
|
382
383
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
383
384
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
384
385
|
retries: int = 0,
|
|
385
|
-
rate_limits: list[RateLimit] =
|
|
386
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
386
|
+
rate_limits: list[RateLimit] | None = None,
|
|
387
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
387
388
|
backoff_factor: float | None = None,
|
|
388
389
|
backoff_max_seconds: int | None = None,
|
|
389
|
-
default_filters: list[DefaultFilter] =
|
|
390
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
390
391
|
) -> (
|
|
391
392
|
Callable[
|
|
392
393
|
[Callable[[EmptyModel, Context], R | CoroutineLike[R]]],
|
|
@@ -447,13 +448,13 @@ class Hatchet:
|
|
|
447
448
|
name=inferred_name,
|
|
448
449
|
version=version,
|
|
449
450
|
description=description,
|
|
450
|
-
on_events=on_events,
|
|
451
|
-
on_crons=on_crons,
|
|
451
|
+
on_events=on_events or [],
|
|
452
|
+
on_crons=on_crons or [],
|
|
452
453
|
sticky=sticky,
|
|
453
454
|
default_priority=default_priority,
|
|
454
455
|
input_validator=input_validator
|
|
455
|
-
or cast(
|
|
456
|
-
default_filters=default_filters,
|
|
456
|
+
or cast(type[TWorkflowInput], EmptyModel),
|
|
457
|
+
default_filters=default_filters or [],
|
|
457
458
|
),
|
|
458
459
|
self,
|
|
459
460
|
)
|
|
@@ -471,8 +472,8 @@ class Hatchet:
|
|
|
471
472
|
execution_timeout=execution_timeout,
|
|
472
473
|
parents=[],
|
|
473
474
|
retries=retries,
|
|
474
|
-
rate_limits=rate_limits,
|
|
475
|
-
desired_worker_labels=desired_worker_labels,
|
|
475
|
+
rate_limits=rate_limits or [],
|
|
476
|
+
desired_worker_labels=desired_worker_labels or {},
|
|
476
477
|
backoff_factor=backoff_factor,
|
|
477
478
|
backoff_max_seconds=backoff_max_seconds,
|
|
478
479
|
concurrency=_concurrency,
|
|
@@ -494,8 +495,8 @@ class Hatchet:
|
|
|
494
495
|
name: str | None = None,
|
|
495
496
|
description: str | None = None,
|
|
496
497
|
input_validator: None = None,
|
|
497
|
-
on_events: list[str] =
|
|
498
|
-
on_crons: list[str] =
|
|
498
|
+
on_events: list[str] | None = None,
|
|
499
|
+
on_crons: list[str] | None = None,
|
|
499
500
|
version: str | None = None,
|
|
500
501
|
sticky: StickyStrategy | None = None,
|
|
501
502
|
default_priority: int = 1,
|
|
@@ -503,11 +504,11 @@ class Hatchet:
|
|
|
503
504
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
504
505
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
505
506
|
retries: int = 0,
|
|
506
|
-
rate_limits: list[RateLimit] =
|
|
507
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
507
|
+
rate_limits: list[RateLimit] | None = None,
|
|
508
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
508
509
|
backoff_factor: float | None = None,
|
|
509
510
|
backoff_max_seconds: int | None = None,
|
|
510
|
-
default_filters: list[DefaultFilter] =
|
|
511
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
511
512
|
) -> Callable[
|
|
512
513
|
[Callable[[EmptyModel, DurableContext], R | CoroutineLike[R]]],
|
|
513
514
|
Standalone[EmptyModel, R],
|
|
@@ -519,9 +520,9 @@ class Hatchet:
|
|
|
519
520
|
*,
|
|
520
521
|
name: str | None = None,
|
|
521
522
|
description: str | None = None,
|
|
522
|
-
input_validator:
|
|
523
|
-
on_events: list[str] =
|
|
524
|
-
on_crons: list[str] =
|
|
523
|
+
input_validator: type[TWorkflowInput],
|
|
524
|
+
on_events: list[str] | None = None,
|
|
525
|
+
on_crons: list[str] | None = None,
|
|
525
526
|
version: str | None = None,
|
|
526
527
|
sticky: StickyStrategy | None = None,
|
|
527
528
|
default_priority: int = 1,
|
|
@@ -529,11 +530,11 @@ class Hatchet:
|
|
|
529
530
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
530
531
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
531
532
|
retries: int = 0,
|
|
532
|
-
rate_limits: list[RateLimit] =
|
|
533
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
533
|
+
rate_limits: list[RateLimit] | None = None,
|
|
534
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
534
535
|
backoff_factor: float | None = None,
|
|
535
536
|
backoff_max_seconds: int | None = None,
|
|
536
|
-
default_filters: list[DefaultFilter] =
|
|
537
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
537
538
|
) -> Callable[
|
|
538
539
|
[Callable[[TWorkflowInput, DurableContext], R | CoroutineLike[R]]],
|
|
539
540
|
Standalone[TWorkflowInput, R],
|
|
@@ -544,9 +545,9 @@ class Hatchet:
|
|
|
544
545
|
*,
|
|
545
546
|
name: str | None = None,
|
|
546
547
|
description: str | None = None,
|
|
547
|
-
input_validator:
|
|
548
|
-
on_events: list[str] =
|
|
549
|
-
on_crons: list[str] =
|
|
548
|
+
input_validator: type[TWorkflowInput] | None = None,
|
|
549
|
+
on_events: list[str] | None = None,
|
|
550
|
+
on_crons: list[str] | None = None,
|
|
550
551
|
version: str | None = None,
|
|
551
552
|
sticky: StickyStrategy | None = None,
|
|
552
553
|
default_priority: int = 1,
|
|
@@ -554,11 +555,11 @@ class Hatchet:
|
|
|
554
555
|
schedule_timeout: Duration = timedelta(minutes=5),
|
|
555
556
|
execution_timeout: Duration = timedelta(seconds=60),
|
|
556
557
|
retries: int = 0,
|
|
557
|
-
rate_limits: list[RateLimit] =
|
|
558
|
-
desired_worker_labels: dict[str, DesiredWorkerLabel] =
|
|
558
|
+
rate_limits: list[RateLimit] | None = None,
|
|
559
|
+
desired_worker_labels: dict[str, DesiredWorkerLabel] | None = None,
|
|
559
560
|
backoff_factor: float | None = None,
|
|
560
561
|
backoff_max_seconds: int | None = None,
|
|
561
|
-
default_filters: list[DefaultFilter] =
|
|
562
|
+
default_filters: list[DefaultFilter] | None = None,
|
|
562
563
|
) -> (
|
|
563
564
|
Callable[
|
|
564
565
|
[Callable[[EmptyModel, DurableContext], R | CoroutineLike[R]]],
|
|
@@ -618,13 +619,13 @@ class Hatchet:
|
|
|
618
619
|
name=inferred_name,
|
|
619
620
|
version=version,
|
|
620
621
|
description=description,
|
|
621
|
-
on_events=on_events,
|
|
622
|
-
on_crons=on_crons,
|
|
622
|
+
on_events=on_events or [],
|
|
623
|
+
on_crons=on_crons or [],
|
|
623
624
|
sticky=sticky,
|
|
624
625
|
input_validator=input_validator
|
|
625
|
-
or cast(
|
|
626
|
+
or cast(type[TWorkflowInput], EmptyModel),
|
|
626
627
|
default_priority=default_priority,
|
|
627
|
-
default_filters=default_filters,
|
|
628
|
+
default_filters=default_filters or [],
|
|
628
629
|
),
|
|
629
630
|
self,
|
|
630
631
|
)
|
|
@@ -642,8 +643,8 @@ class Hatchet:
|
|
|
642
643
|
execution_timeout=execution_timeout,
|
|
643
644
|
parents=[],
|
|
644
645
|
retries=retries,
|
|
645
|
-
rate_limits=rate_limits,
|
|
646
|
-
desired_worker_labels=desired_worker_labels,
|
|
646
|
+
rate_limits=rate_limits or [],
|
|
647
|
+
desired_worker_labels=desired_worker_labels or {},
|
|
647
648
|
backoff_factor=backoff_factor,
|
|
648
649
|
backoff_max_seconds=backoff_max_seconds,
|
|
649
650
|
concurrency=_concurrency,
|