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
|
@@ -15,7 +15,7 @@ _sym_db = _symbol_database.Default()
|
|
|
15
15
|
from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x65vents.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xd2\x01\n\x05\x45vent\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x0f\n\x07\x65ventId\x18\x02 \x01(\t\x12\x0b\n\x03key\x18\x03 \x01(\t\x12\x0f\n\x07payload\x18\x04 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1f\n\x12\x61\x64\x64itionalMetadata\x18\x06 \x01(\tH\x00\x88\x01\x01\x12\x12\n\x05scope\x18\x07 \x01(\tH\x01\x88\x01\x01\x42\x15\n\x13_additionalMetadataB\x08\n\x06_scope\" \n\x06\x45vents\x12\x16\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x06.Event\"\xc2\x01\n\rPutLogRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12-\n\tcreatedAt\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07message\x18\x03 \x01(\t\x12\x12\n\x05level\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x10\n\x08metadata\x18\x05 \x01(\t\x12\x1b\n\x0etaskRetryCount\x18\x06 \x01(\x05H\x01\x88\x01\x01\x42\x08\n\x06_levelB\x11\n\x0f_taskRetryCount\"\x10\n\x0ePutLogResponse\"
|
|
18
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x65vents.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xd2\x01\n\x05\x45vent\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x0f\n\x07\x65ventId\x18\x02 \x01(\t\x12\x0b\n\x03key\x18\x03 \x01(\t\x12\x0f\n\x07payload\x18\x04 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1f\n\x12\x61\x64\x64itionalMetadata\x18\x06 \x01(\tH\x00\x88\x01\x01\x12\x12\n\x05scope\x18\x07 \x01(\tH\x01\x88\x01\x01\x42\x15\n\x13_additionalMetadataB\x08\n\x06_scope\" \n\x06\x45vents\x12\x16\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x06.Event\"\xc2\x01\n\rPutLogRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12-\n\tcreatedAt\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07message\x18\x03 \x01(\t\x12\x12\n\x05level\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x10\n\x08metadata\x18\x05 \x01(\t\x12\x1b\n\x0etaskRetryCount\x18\x06 \x01(\x05H\x01\x88\x01\x01\x42\x08\n\x06_levelB\x11\n\x0f_taskRetryCount\"\x10\n\x0ePutLogResponse\"\xa4\x01\n\x15PutStreamEventRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12-\n\tcreatedAt\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07message\x18\x03 \x01(\x0c\x12\x10\n\x08metadata\x18\x05 \x01(\t\x12\x17\n\neventIndex\x18\x06 \x01(\x03H\x00\x88\x01\x01\x42\r\n\x0b_eventIndex\"\x18\n\x16PutStreamEventResponse\"9\n\x14\x42ulkPushEventRequest\x12!\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x11.PushEventRequest\"\xde\x01\n\x10PushEventRequest\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x0f\n\x07payload\x18\x02 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1f\n\x12\x61\x64\x64itionalMetadata\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x15\n\x08priority\x18\x05 \x01(\x05H\x01\x88\x01\x01\x12\x12\n\x05scope\x18\x06 \x01(\tH\x02\x88\x01\x01\x42\x15\n\x13_additionalMetadataB\x0b\n\t_priorityB\x08\n\x06_scope\"%\n\x12ReplayEventRequest\x12\x0f\n\x07\x65ventId\x18\x01 \x01(\t2\x88\x02\n\rEventsService\x12#\n\x04Push\x12\x11.PushEventRequest\x1a\x06.Event\"\x00\x12,\n\x08\x42ulkPush\x12\x15.BulkPushEventRequest\x1a\x07.Events\"\x00\x12\x32\n\x11ReplaySingleEvent\x12\x13.ReplayEventRequest\x1a\x06.Event\"\x00\x12+\n\x06PutLog\x12\x0e.PutLogRequest\x1a\x0f.PutLogResponse\"\x00\x12\x43\n\x0ePutStreamEvent\x12\x16.PutStreamEventRequest\x1a\x17.PutStreamEventResponse\"\x00\x42\x45ZCgithub.com/hatchet-dev/hatchet/internal/services/ingestor/contractsb\x06proto3')
|
|
19
19
|
|
|
20
20
|
_globals = globals()
|
|
21
21
|
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
@@ -31,16 +31,16 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
|
|
31
31
|
_globals['_PUTLOGREQUEST']._serialized_end=491
|
|
32
32
|
_globals['_PUTLOGRESPONSE']._serialized_start=493
|
|
33
33
|
_globals['_PUTLOGRESPONSE']._serialized_end=509
|
|
34
|
-
_globals['_PUTSTREAMEVENTREQUEST']._serialized_start=
|
|
35
|
-
_globals['_PUTSTREAMEVENTREQUEST']._serialized_end=
|
|
36
|
-
_globals['_PUTSTREAMEVENTRESPONSE']._serialized_start=
|
|
37
|
-
_globals['_PUTSTREAMEVENTRESPONSE']._serialized_end=
|
|
38
|
-
_globals['_BULKPUSHEVENTREQUEST']._serialized_start=
|
|
39
|
-
_globals['_BULKPUSHEVENTREQUEST']._serialized_end=
|
|
40
|
-
_globals['_PUSHEVENTREQUEST']._serialized_start=
|
|
41
|
-
_globals['_PUSHEVENTREQUEST']._serialized_end=
|
|
42
|
-
_globals['_REPLAYEVENTREQUEST']._serialized_start=
|
|
43
|
-
_globals['_REPLAYEVENTREQUEST']._serialized_end=
|
|
44
|
-
_globals['_EVENTSSERVICE']._serialized_start=
|
|
45
|
-
_globals['_EVENTSSERVICE']._serialized_end=
|
|
34
|
+
_globals['_PUTSTREAMEVENTREQUEST']._serialized_start=512
|
|
35
|
+
_globals['_PUTSTREAMEVENTREQUEST']._serialized_end=676
|
|
36
|
+
_globals['_PUTSTREAMEVENTRESPONSE']._serialized_start=678
|
|
37
|
+
_globals['_PUTSTREAMEVENTRESPONSE']._serialized_end=702
|
|
38
|
+
_globals['_BULKPUSHEVENTREQUEST']._serialized_start=704
|
|
39
|
+
_globals['_BULKPUSHEVENTREQUEST']._serialized_end=761
|
|
40
|
+
_globals['_PUSHEVENTREQUEST']._serialized_start=764
|
|
41
|
+
_globals['_PUSHEVENTREQUEST']._serialized_end=986
|
|
42
|
+
_globals['_REPLAYEVENTREQUEST']._serialized_start=988
|
|
43
|
+
_globals['_REPLAYEVENTREQUEST']._serialized_end=1025
|
|
44
|
+
_globals['_EVENTSSERVICE']._serialized_start=1028
|
|
45
|
+
_globals['_EVENTSSERVICE']._serialized_end=1292
|
|
46
46
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -51,16 +51,18 @@ class PutLogResponse(_message.Message):
|
|
|
51
51
|
def __init__(self) -> None: ...
|
|
52
52
|
|
|
53
53
|
class PutStreamEventRequest(_message.Message):
|
|
54
|
-
__slots__ = ("stepRunId", "createdAt", "message", "metadata")
|
|
54
|
+
__slots__ = ("stepRunId", "createdAt", "message", "metadata", "eventIndex")
|
|
55
55
|
STEPRUNID_FIELD_NUMBER: _ClassVar[int]
|
|
56
56
|
CREATEDAT_FIELD_NUMBER: _ClassVar[int]
|
|
57
57
|
MESSAGE_FIELD_NUMBER: _ClassVar[int]
|
|
58
58
|
METADATA_FIELD_NUMBER: _ClassVar[int]
|
|
59
|
+
EVENTINDEX_FIELD_NUMBER: _ClassVar[int]
|
|
59
60
|
stepRunId: str
|
|
60
61
|
createdAt: _timestamp_pb2.Timestamp
|
|
61
62
|
message: bytes
|
|
62
63
|
metadata: str
|
|
63
|
-
|
|
64
|
+
eventIndex: int
|
|
65
|
+
def __init__(self, stepRunId: _Optional[str] = ..., createdAt: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., message: _Optional[bytes] = ..., metadata: _Optional[str] = ..., eventIndex: _Optional[int] = ...) -> None: ...
|
|
64
66
|
|
|
65
67
|
class PutStreamEventResponse(_message.Message):
|
|
66
68
|
__slots__ = ()
|
|
@@ -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,104 @@
|
|
|
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):
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class IllegalTaskOutputError(Exception):
|
|
2
104
|
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
|
@@ -26,47 +26,38 @@ class FiltersClient(BaseRestClient):
|
|
|
26
26
|
self,
|
|
27
27
|
limit: int | None = None,
|
|
28
28
|
offset: int | None = None,
|
|
29
|
-
|
|
29
|
+
workflow_ids: list[str] | None = None,
|
|
30
|
+
scopes: list[str] | None = None,
|
|
30
31
|
) -> V1FilterList:
|
|
31
32
|
"""
|
|
32
33
|
List filters for a given tenant.
|
|
33
34
|
|
|
34
35
|
:param limit: The maximum number of filters to return.
|
|
35
36
|
:param offset: The number of filters to skip before starting to collect the result set.
|
|
36
|
-
:param
|
|
37
|
+
:param workflow_ids: A list of workflow IDs to filter by.
|
|
38
|
+
:param scopes: A list of scopes to filter by.
|
|
37
39
|
|
|
38
40
|
:return: A list of filters matching the specified criteria.
|
|
39
41
|
"""
|
|
40
|
-
return await asyncio.to_thread(
|
|
41
|
-
self.list, limit, offset, workflow_id_scope_pairs
|
|
42
|
-
)
|
|
42
|
+
return await asyncio.to_thread(self.list, limit, offset, workflow_ids, scopes)
|
|
43
43
|
|
|
44
44
|
def list(
|
|
45
45
|
self,
|
|
46
46
|
limit: int | None = None,
|
|
47
47
|
offset: int | None = None,
|
|
48
|
-
|
|
48
|
+
workflow_ids: list[str] | None = None,
|
|
49
|
+
scopes: list[str] | None = None,
|
|
49
50
|
) -> V1FilterList:
|
|
50
51
|
"""
|
|
51
52
|
List filters for a given tenant.
|
|
52
53
|
|
|
53
54
|
:param limit: The maximum number of filters to return.
|
|
54
55
|
:param offset: The number of filters to skip before starting to collect the result set.
|
|
55
|
-
:param
|
|
56
|
+
:param workflow_ids: A list of workflow IDs to filter by.
|
|
57
|
+
:param scopes: A list of scopes to filter by.
|
|
56
58
|
|
|
57
59
|
:return: A list of filters matching the specified criteria.
|
|
58
60
|
"""
|
|
59
|
-
workflow_ids = (
|
|
60
|
-
[pair[0] for pair in workflow_id_scope_pairs]
|
|
61
|
-
if workflow_id_scope_pairs
|
|
62
|
-
else None
|
|
63
|
-
)
|
|
64
|
-
scopes = (
|
|
65
|
-
[pair[1] for pair in workflow_id_scope_pairs]
|
|
66
|
-
if workflow_id_scope_pairs
|
|
67
|
-
else None
|
|
68
|
-
)
|
|
69
|
-
|
|
70
61
|
with self.client() as client:
|
|
71
62
|
return self._fa(client).v1_filter_list(
|
|
72
63
|
tenant=self.tenant_id,
|
|
@@ -111,7 +102,7 @@ class FiltersClient(BaseRestClient):
|
|
|
111
102
|
workflow_id: str,
|
|
112
103
|
expression: str,
|
|
113
104
|
scope: str,
|
|
114
|
-
payload: JSONSerializableMapping =
|
|
105
|
+
payload: JSONSerializableMapping | None = None,
|
|
115
106
|
) -> V1Filter:
|
|
116
107
|
"""
|
|
117
108
|
Create a new filter.
|
|
@@ -130,7 +121,7 @@ class FiltersClient(BaseRestClient):
|
|
|
130
121
|
workflowId=workflow_id,
|
|
131
122
|
expression=expression,
|
|
132
123
|
scope=scope,
|
|
133
|
-
payload=
|
|
124
|
+
payload=payload,
|
|
134
125
|
),
|
|
135
126
|
)
|
|
136
127
|
|
|
@@ -139,7 +130,7 @@ class FiltersClient(BaseRestClient):
|
|
|
139
130
|
workflow_id: str,
|
|
140
131
|
expression: str,
|
|
141
132
|
scope: str,
|
|
142
|
-
payload: JSONSerializableMapping =
|
|
133
|
+
payload: JSONSerializableMapping | None = None,
|
|
143
134
|
) -> V1Filter:
|
|
144
135
|
"""
|
|
145
136
|
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.
|