hatchet-sdk 1.0.3__py3-none-any.whl → 1.2.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.

Files changed (42) hide show
  1. hatchet_sdk/__init__.py +2 -1
  2. hatchet_sdk/client.py +3 -16
  3. hatchet_sdk/clients/admin.py +7 -32
  4. hatchet_sdk/clients/dispatcher/action_listener.py +4 -10
  5. hatchet_sdk/clients/dispatcher/dispatcher.py +35 -8
  6. hatchet_sdk/clients/durable_event_listener.py +11 -12
  7. hatchet_sdk/clients/events.py +11 -15
  8. hatchet_sdk/clients/rest/models/tenant_resource.py +2 -0
  9. hatchet_sdk/clients/rest/models/workflow_runs_metrics.py +1 -5
  10. hatchet_sdk/clients/run_event_listener.py +55 -40
  11. hatchet_sdk/clients/v1/api_client.py +1 -38
  12. hatchet_sdk/clients/workflow_listener.py +9 -10
  13. hatchet_sdk/contracts/dispatcher_pb2.py +46 -46
  14. hatchet_sdk/contracts/dispatcher_pb2.pyi +4 -2
  15. hatchet_sdk/contracts/dispatcher_pb2_grpc.py +1 -1
  16. hatchet_sdk/contracts/events_pb2_grpc.py +1 -1
  17. hatchet_sdk/contracts/v1/dispatcher_pb2_grpc.py +1 -1
  18. hatchet_sdk/contracts/v1/workflows_pb2_grpc.py +1 -1
  19. hatchet_sdk/contracts/workflows_pb2_grpc.py +1 -1
  20. hatchet_sdk/features/cron.py +5 -4
  21. hatchet_sdk/features/logs.py +2 -1
  22. hatchet_sdk/features/metrics.py +4 -3
  23. hatchet_sdk/features/rate_limits.py +1 -1
  24. hatchet_sdk/features/runs.py +8 -7
  25. hatchet_sdk/features/scheduled.py +5 -4
  26. hatchet_sdk/features/workers.py +4 -3
  27. hatchet_sdk/features/workflows.py +4 -3
  28. hatchet_sdk/metadata.py +2 -2
  29. hatchet_sdk/runnables/standalone.py +3 -18
  30. hatchet_sdk/runnables/task.py +4 -0
  31. hatchet_sdk/runnables/workflow.py +28 -0
  32. hatchet_sdk/utils/aio.py +43 -0
  33. hatchet_sdk/worker/action_listener_process.py +7 -1
  34. hatchet_sdk/worker/runner/run_loop_manager.py +1 -1
  35. hatchet_sdk/worker/runner/runner.py +21 -5
  36. hatchet_sdk/workflow_run.py +7 -20
  37. hatchet_sdk-1.2.0.dist-info/METADATA +109 -0
  38. {hatchet_sdk-1.0.3.dist-info → hatchet_sdk-1.2.0.dist-info}/RECORD +40 -40
  39. hatchet_sdk/utils/aio_utils.py +0 -18
  40. hatchet_sdk-1.0.3.dist-info/METADATA +0 -42
  41. {hatchet_sdk-1.0.3.dist-info → hatchet_sdk-1.2.0.dist-info}/WHEEL +0 -0
  42. {hatchet_sdk-1.0.3.dist-info → hatchet_sdk-1.2.0.dist-info}/entry_points.txt +0 -0
@@ -54,14 +54,6 @@ class _Subscription:
54
54
 
55
55
  class PooledWorkflowRunListener:
56
56
  def __init__(self, config: ClientConfig):
57
- try:
58
- asyncio.get_running_loop()
59
- except RuntimeError:
60
- loop = asyncio.new_event_loop()
61
- asyncio.set_event_loop(loop)
62
-
63
- conn = new_conn(config, True)
64
- self.client = DispatcherStub(conn) # type: ignore[no-untyped-call]
65
57
  self.token = config.token
66
58
  self.config = config
67
59
 
@@ -91,6 +83,10 @@ class PooledWorkflowRunListener:
91
83
 
92
84
  self.interrupter: asyncio.Task[None] | None = None
93
85
 
86
+ ## IMPORTANT: This needs to be created lazily so we don't require
87
+ ## an event loop to instantiate the client.
88
+ self.client: DispatcherStub | None = None
89
+
94
90
  async def _interrupter(self) -> None:
95
91
  """
96
92
  _interrupter runs in a separate thread and interrupts the listener according to a configurable duration.
@@ -239,7 +235,7 @@ class PooledWorkflowRunListener:
239
235
  if subscription_id:
240
236
  self.cleanup_subscription(subscription_id)
241
237
 
242
- async def result(self, workflow_run_id: str) -> dict[str, Any]:
238
+ async def aio_result(self, workflow_run_id: str) -> dict[str, Any]:
243
239
  from hatchet_sdk.clients.admin import DedupeViolationErr
244
240
 
245
241
  event = await self.subscribe(workflow_run_id)
@@ -261,6 +257,9 @@ class PooledWorkflowRunListener:
261
257
  self,
262
258
  ) -> grpc.aio.UnaryStreamCall[SubscribeToWorkflowRunsRequest, WorkflowRunEvent]:
263
259
  retries = 0
260
+ if self.client is None:
261
+ conn = new_conn(self.config, True)
262
+ self.client = DispatcherStub(conn)
264
263
 
265
264
  while retries < DEFAULT_WORKFLOW_LISTENER_RETRY_COUNT:
266
265
  try:
@@ -276,7 +275,7 @@ class PooledWorkflowRunListener:
276
275
  SubscribeToWorkflowRunsRequest, WorkflowRunEvent
277
276
  ],
278
277
  self.client.SubscribeToWorkflowRuns(
279
- self._request(),
278
+ self._request(), # type: ignore[arg-type]
280
279
  metadata=get_metadata(self.token),
281
280
  ),
282
281
  )
@@ -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\x10\x64ispatcher.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"V\n\x0cWorkerLabels\x12\x15\n\x08strValue\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x15\n\x08intValue\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\x0b\n\t_strValueB\x0b\n\t_intValue\"\xc8\x01\n\x0bRuntimeInfo\x12\x17\n\nsdkVersion\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x1c\n\x08language\x18\x02 \x01(\x0e\x32\x05.SDKSH\x01\x88\x01\x01\x12\x1c\n\x0flanguageVersion\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x0f\n\x02os\x18\x04 \x01(\tH\x03\x88\x01\x01\x12\x12\n\x05\x65xtra\x18\x05 \x01(\tH\x04\x88\x01\x01\x42\r\n\x0b_sdkVersionB\x0b\n\t_languageB\x12\n\x10_languageVersionB\x05\n\x03_osB\x08\n\x06_extra\"\xc0\x02\n\x15WorkerRegisterRequest\x12\x12\n\nworkerName\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x63tions\x18\x02 \x03(\t\x12\x10\n\x08services\x18\x03 \x03(\t\x12\x14\n\x07maxRuns\x18\x04 \x01(\x05H\x00\x88\x01\x01\x12\x32\n\x06labels\x18\x05 \x03(\x0b\x32\".WorkerRegisterRequest.LabelsEntry\x12\x16\n\twebhookId\x18\x06 \x01(\tH\x01\x88\x01\x01\x12&\n\x0bruntimeInfo\x18\x07 \x01(\x0b\x32\x0c.RuntimeInfoH\x02\x88\x01\x01\x1a<\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1c\n\x05value\x18\x02 \x01(\x0b\x32\r.WorkerLabels:\x02\x38\x01\x42\n\n\x08_maxRunsB\x0c\n\n_webhookIdB\x0e\n\x0c_runtimeInfo\"P\n\x16WorkerRegisterResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\x12\x12\n\nworkerName\x18\x03 \x01(\t\"\xa3\x01\n\x19UpsertWorkerLabelsRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12\x36\n\x06labels\x18\x02 \x03(\x0b\x32&.UpsertWorkerLabelsRequest.LabelsEntry\x1a<\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1c\n\x05value\x18\x02 \x01(\x0b\x32\r.WorkerLabels:\x02\x38\x01\"@\n\x1aUpsertWorkerLabelsResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\"\x86\x04\n\x0e\x41ssignedAction\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x15\n\rworkflowRunId\x18\x02 \x01(\t\x12\x18\n\x10getGroupKeyRunId\x18\x03 \x01(\t\x12\r\n\x05jobId\x18\x04 \x01(\t\x12\x0f\n\x07jobName\x18\x05 \x01(\t\x12\x10\n\x08jobRunId\x18\x06 \x01(\t\x12\x0e\n\x06stepId\x18\x07 \x01(\t\x12\x11\n\tstepRunId\x18\x08 \x01(\t\x12\x10\n\x08\x61\x63tionId\x18\t \x01(\t\x12\x1f\n\nactionType\x18\n \x01(\x0e\x32\x0b.ActionType\x12\x15\n\ractionPayload\x18\x0b \x01(\t\x12\x10\n\x08stepName\x18\x0c \x01(\t\x12\x12\n\nretryCount\x18\r \x01(\x05\x12 \n\x13\x61\x64\x64itional_metadata\x18\x0e \x01(\tH\x00\x88\x01\x01\x12!\n\x14\x63hild_workflow_index\x18\x0f \x01(\x05H\x01\x88\x01\x01\x12\x1f\n\x12\x63hild_workflow_key\x18\x10 \x01(\tH\x02\x88\x01\x01\x12#\n\x16parent_workflow_run_id\x18\x11 \x01(\tH\x03\x88\x01\x01\x42\x16\n\x14_additional_metadataB\x17\n\x15_child_workflow_indexB\x15\n\x13_child_workflow_keyB\x19\n\x17_parent_workflow_run_id\"\'\n\x13WorkerListenRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\",\n\x18WorkerUnsubscribeRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\"?\n\x19WorkerUnsubscribeResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\"\xe1\x01\n\x13GroupKeyActionEvent\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12\x15\n\rworkflowRunId\x18\x02 \x01(\t\x12\x18\n\x10getGroupKeyRunId\x18\x03 \x01(\t\x12\x10\n\x08\x61\x63tionId\x18\x04 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\teventType\x18\x06 \x01(\x0e\x32\x18.GroupKeyActionEventType\x12\x14\n\x0c\x65ventPayload\x18\x07 \x01(\t\"\x94\x02\n\x0fStepActionEvent\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12\r\n\x05jobId\x18\x02 \x01(\t\x12\x10\n\x08jobRunId\x18\x03 \x01(\t\x12\x0e\n\x06stepId\x18\x04 \x01(\t\x12\x11\n\tstepRunId\x18\x05 \x01(\t\x12\x10\n\x08\x61\x63tionId\x18\x06 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\'\n\teventType\x18\x08 \x01(\x0e\x32\x14.StepActionEventType\x12\x14\n\x0c\x65ventPayload\x18\t \x01(\t\x12\x17\n\nretryCount\x18\n \x01(\x05H\x00\x88\x01\x01\x42\r\n\x0b_retryCount\"9\n\x13\x41\x63tionEventResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\"\xc0\x01\n SubscribeToWorkflowEventsRequest\x12\x1a\n\rworkflowRunId\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x1e\n\x11\x61\x64\x64itionalMetaKey\x18\x02 \x01(\tH\x01\x88\x01\x01\x12 \n\x13\x61\x64\x64itionalMetaValue\x18\x03 \x01(\tH\x02\x88\x01\x01\x42\x10\n\x0e_workflowRunIdB\x14\n\x12_additionalMetaKeyB\x16\n\x14_additionalMetaValue\"7\n\x1eSubscribeToWorkflowRunsRequest\x12\x15\n\rworkflowRunId\x18\x01 \x01(\t\"\xb2\x02\n\rWorkflowEvent\x12\x15\n\rworkflowRunId\x18\x01 \x01(\t\x12#\n\x0cresourceType\x18\x02 \x01(\x0e\x32\r.ResourceType\x12%\n\teventType\x18\x03 \x01(\x0e\x32\x12.ResourceEventType\x12\x12\n\nresourceId\x18\x04 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0c\x65ventPayload\x18\x06 \x01(\t\x12\x0e\n\x06hangup\x18\x07 \x01(\x08\x12\x18\n\x0bstepRetries\x18\x08 \x01(\x05H\x00\x88\x01\x01\x12\x17\n\nretryCount\x18\t \x01(\x05H\x01\x88\x01\x01\x42\x0e\n\x0c_stepRetriesB\r\n\x0b_retryCount\"\xa8\x01\n\x10WorkflowRunEvent\x12\x15\n\rworkflowRunId\x18\x01 \x01(\t\x12(\n\teventType\x18\x02 \x01(\x0e\x32\x15.WorkflowRunEventType\x12\x32\n\x0e\x65ventTimestamp\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1f\n\x07results\x18\x04 \x03(\x0b\x32\x0e.StepRunResult\"\x8a\x01\n\rStepRunResult\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12\x16\n\x0estepReadableId\x18\x02 \x01(\t\x12\x10\n\x08jobRunId\x18\x03 \x01(\t\x12\x12\n\x05\x65rror\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x13\n\x06output\x18\x05 \x01(\tH\x01\x88\x01\x01\x42\x08\n\x06_errorB\t\n\x07_output\"W\n\rOverridesData\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\x12\r\n\x05value\x18\x03 \x01(\t\x12\x16\n\x0e\x63\x61llerFilename\x18\x04 \x01(\t\"\x17\n\x15OverridesDataResponse\"U\n\x10HeartbeatRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12/\n\x0bheartbeatAt\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x13\n\x11HeartbeatResponse\"F\n\x15RefreshTimeoutRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12\x1a\n\x12incrementTimeoutBy\x18\x02 \x01(\t\"G\n\x16RefreshTimeoutResponse\x12-\n\ttimeoutAt\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\'\n\x12ReleaseSlotRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\"\x15\n\x13ReleaseSlotResponse*7\n\x04SDKS\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x06\n\x02GO\x10\x01\x12\n\n\x06PYTHON\x10\x02\x12\x0e\n\nTYPESCRIPT\x10\x03*N\n\nActionType\x12\x12\n\x0eSTART_STEP_RUN\x10\x00\x12\x13\n\x0f\x43\x41NCEL_STEP_RUN\x10\x01\x12\x17\n\x13START_GET_GROUP_KEY\x10\x02*\xa2\x01\n\x17GroupKeyActionEventType\x12 \n\x1cGROUP_KEY_EVENT_TYPE_UNKNOWN\x10\x00\x12 \n\x1cGROUP_KEY_EVENT_TYPE_STARTED\x10\x01\x12\"\n\x1eGROUP_KEY_EVENT_TYPE_COMPLETED\x10\x02\x12\x1f\n\x1bGROUP_KEY_EVENT_TYPE_FAILED\x10\x03*\xac\x01\n\x13StepActionEventType\x12\x1b\n\x17STEP_EVENT_TYPE_UNKNOWN\x10\x00\x12\x1b\n\x17STEP_EVENT_TYPE_STARTED\x10\x01\x12\x1d\n\x19STEP_EVENT_TYPE_COMPLETED\x10\x02\x12\x1a\n\x16STEP_EVENT_TYPE_FAILED\x10\x03\x12 \n\x1cSTEP_EVENT_TYPE_ACKNOWLEDGED\x10\x04*e\n\x0cResourceType\x12\x19\n\x15RESOURCE_TYPE_UNKNOWN\x10\x00\x12\x1a\n\x16RESOURCE_TYPE_STEP_RUN\x10\x01\x12\x1e\n\x1aRESOURCE_TYPE_WORKFLOW_RUN\x10\x02*\xfe\x01\n\x11ResourceEventType\x12\x1f\n\x1bRESOURCE_EVENT_TYPE_UNKNOWN\x10\x00\x12\x1f\n\x1bRESOURCE_EVENT_TYPE_STARTED\x10\x01\x12!\n\x1dRESOURCE_EVENT_TYPE_COMPLETED\x10\x02\x12\x1e\n\x1aRESOURCE_EVENT_TYPE_FAILED\x10\x03\x12!\n\x1dRESOURCE_EVENT_TYPE_CANCELLED\x10\x04\x12!\n\x1dRESOURCE_EVENT_TYPE_TIMED_OUT\x10\x05\x12\x1e\n\x1aRESOURCE_EVENT_TYPE_STREAM\x10\x06*<\n\x14WorkflowRunEventType\x12$\n WORKFLOW_RUN_EVENT_TYPE_FINISHED\x10\x00\x32\xf8\x06\n\nDispatcher\x12=\n\x08Register\x12\x16.WorkerRegisterRequest\x1a\x17.WorkerRegisterResponse\"\x00\x12\x33\n\x06Listen\x12\x14.WorkerListenRequest\x1a\x0f.AssignedAction\"\x00\x30\x01\x12\x35\n\x08ListenV2\x12\x14.WorkerListenRequest\x1a\x0f.AssignedAction\"\x00\x30\x01\x12\x34\n\tHeartbeat\x12\x11.HeartbeatRequest\x1a\x12.HeartbeatResponse\"\x00\x12R\n\x19SubscribeToWorkflowEvents\x12!.SubscribeToWorkflowEventsRequest\x1a\x0e.WorkflowEvent\"\x00\x30\x01\x12S\n\x17SubscribeToWorkflowRuns\x12\x1f.SubscribeToWorkflowRunsRequest\x1a\x11.WorkflowRunEvent\"\x00(\x01\x30\x01\x12?\n\x13SendStepActionEvent\x12\x10.StepActionEvent\x1a\x14.ActionEventResponse\"\x00\x12G\n\x17SendGroupKeyActionEvent\x12\x14.GroupKeyActionEvent\x1a\x14.ActionEventResponse\"\x00\x12<\n\x10PutOverridesData\x12\x0e.OverridesData\x1a\x16.OverridesDataResponse\"\x00\x12\x46\n\x0bUnsubscribe\x12\x19.WorkerUnsubscribeRequest\x1a\x1a.WorkerUnsubscribeResponse\"\x00\x12\x43\n\x0eRefreshTimeout\x12\x16.RefreshTimeoutRequest\x1a\x17.RefreshTimeoutResponse\"\x00\x12:\n\x0bReleaseSlot\x12\x13.ReleaseSlotRequest\x1a\x14.ReleaseSlotResponse\"\x00\x12O\n\x12UpsertWorkerLabels\x12\x1a.UpsertWorkerLabelsRequest\x1a\x1b.UpsertWorkerLabelsResponse\"\x00\x42GZEgithub.com/hatchet-dev/hatchet/internal/services/dispatcher/contractsb\x06proto3')
18
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10\x64ispatcher.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"V\n\x0cWorkerLabels\x12\x15\n\x08strValue\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x15\n\x08intValue\x18\x02 \x01(\x05H\x01\x88\x01\x01\x42\x0b\n\t_strValueB\x0b\n\t_intValue\"\xc8\x01\n\x0bRuntimeInfo\x12\x17\n\nsdkVersion\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x1c\n\x08language\x18\x02 \x01(\x0e\x32\x05.SDKSH\x01\x88\x01\x01\x12\x1c\n\x0flanguageVersion\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x0f\n\x02os\x18\x04 \x01(\tH\x03\x88\x01\x01\x12\x12\n\x05\x65xtra\x18\x05 \x01(\tH\x04\x88\x01\x01\x42\r\n\x0b_sdkVersionB\x0b\n\t_languageB\x12\n\x10_languageVersionB\x05\n\x03_osB\x08\n\x06_extra\"\xc0\x02\n\x15WorkerRegisterRequest\x12\x12\n\nworkerName\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x63tions\x18\x02 \x03(\t\x12\x10\n\x08services\x18\x03 \x03(\t\x12\x14\n\x07maxRuns\x18\x04 \x01(\x05H\x00\x88\x01\x01\x12\x32\n\x06labels\x18\x05 \x03(\x0b\x32\".WorkerRegisterRequest.LabelsEntry\x12\x16\n\twebhookId\x18\x06 \x01(\tH\x01\x88\x01\x01\x12&\n\x0bruntimeInfo\x18\x07 \x01(\x0b\x32\x0c.RuntimeInfoH\x02\x88\x01\x01\x1a<\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1c\n\x05value\x18\x02 \x01(\x0b\x32\r.WorkerLabels:\x02\x38\x01\x42\n\n\x08_maxRunsB\x0c\n\n_webhookIdB\x0e\n\x0c_runtimeInfo\"P\n\x16WorkerRegisterResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\x12\x12\n\nworkerName\x18\x03 \x01(\t\"\xa3\x01\n\x19UpsertWorkerLabelsRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12\x36\n\x06labels\x18\x02 \x03(\x0b\x32&.UpsertWorkerLabelsRequest.LabelsEntry\x1a<\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1c\n\x05value\x18\x02 \x01(\x0b\x32\r.WorkerLabels:\x02\x38\x01\"@\n\x1aUpsertWorkerLabelsResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\"\x86\x04\n\x0e\x41ssignedAction\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x15\n\rworkflowRunId\x18\x02 \x01(\t\x12\x18\n\x10getGroupKeyRunId\x18\x03 \x01(\t\x12\r\n\x05jobId\x18\x04 \x01(\t\x12\x0f\n\x07jobName\x18\x05 \x01(\t\x12\x10\n\x08jobRunId\x18\x06 \x01(\t\x12\x0e\n\x06stepId\x18\x07 \x01(\t\x12\x11\n\tstepRunId\x18\x08 \x01(\t\x12\x10\n\x08\x61\x63tionId\x18\t \x01(\t\x12\x1f\n\nactionType\x18\n \x01(\x0e\x32\x0b.ActionType\x12\x15\n\ractionPayload\x18\x0b \x01(\t\x12\x10\n\x08stepName\x18\x0c \x01(\t\x12\x12\n\nretryCount\x18\r \x01(\x05\x12 \n\x13\x61\x64\x64itional_metadata\x18\x0e \x01(\tH\x00\x88\x01\x01\x12!\n\x14\x63hild_workflow_index\x18\x0f \x01(\x05H\x01\x88\x01\x01\x12\x1f\n\x12\x63hild_workflow_key\x18\x10 \x01(\tH\x02\x88\x01\x01\x12#\n\x16parent_workflow_run_id\x18\x11 \x01(\tH\x03\x88\x01\x01\x42\x16\n\x14_additional_metadataB\x17\n\x15_child_workflow_indexB\x15\n\x13_child_workflow_keyB\x19\n\x17_parent_workflow_run_id\"\'\n\x13WorkerListenRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\",\n\x18WorkerUnsubscribeRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\"?\n\x19WorkerUnsubscribeResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\"\xe1\x01\n\x13GroupKeyActionEvent\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12\x15\n\rworkflowRunId\x18\x02 \x01(\t\x12\x18\n\x10getGroupKeyRunId\x18\x03 \x01(\t\x12\x10\n\x08\x61\x63tionId\x18\x04 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\teventType\x18\x06 \x01(\x0e\x32\x18.GroupKeyActionEventType\x12\x14\n\x0c\x65ventPayload\x18\x07 \x01(\t\"\xc4\x02\n\x0fStepActionEvent\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12\r\n\x05jobId\x18\x02 \x01(\t\x12\x10\n\x08jobRunId\x18\x03 \x01(\t\x12\x0e\n\x06stepId\x18\x04 \x01(\t\x12\x11\n\tstepRunId\x18\x05 \x01(\t\x12\x10\n\x08\x61\x63tionId\x18\x06 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\'\n\teventType\x18\x08 \x01(\x0e\x32\x14.StepActionEventType\x12\x14\n\x0c\x65ventPayload\x18\t \x01(\t\x12\x17\n\nretryCount\x18\n \x01(\x05H\x00\x88\x01\x01\x12\x1b\n\x0eshouldNotRetry\x18\x0b \x01(\x08H\x01\x88\x01\x01\x42\r\n\x0b_retryCountB\x11\n\x0f_shouldNotRetry\"9\n\x13\x41\x63tionEventResponse\x12\x10\n\x08tenantId\x18\x01 \x01(\t\x12\x10\n\x08workerId\x18\x02 \x01(\t\"\xc0\x01\n SubscribeToWorkflowEventsRequest\x12\x1a\n\rworkflowRunId\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x1e\n\x11\x61\x64\x64itionalMetaKey\x18\x02 \x01(\tH\x01\x88\x01\x01\x12 \n\x13\x61\x64\x64itionalMetaValue\x18\x03 \x01(\tH\x02\x88\x01\x01\x42\x10\n\x0e_workflowRunIdB\x14\n\x12_additionalMetaKeyB\x16\n\x14_additionalMetaValue\"7\n\x1eSubscribeToWorkflowRunsRequest\x12\x15\n\rworkflowRunId\x18\x01 \x01(\t\"\xb2\x02\n\rWorkflowEvent\x12\x15\n\rworkflowRunId\x18\x01 \x01(\t\x12#\n\x0cresourceType\x18\x02 \x01(\x0e\x32\r.ResourceType\x12%\n\teventType\x18\x03 \x01(\x0e\x32\x12.ResourceEventType\x12\x12\n\nresourceId\x18\x04 \x01(\t\x12\x32\n\x0e\x65ventTimestamp\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0c\x65ventPayload\x18\x06 \x01(\t\x12\x0e\n\x06hangup\x18\x07 \x01(\x08\x12\x18\n\x0bstepRetries\x18\x08 \x01(\x05H\x00\x88\x01\x01\x12\x17\n\nretryCount\x18\t \x01(\x05H\x01\x88\x01\x01\x42\x0e\n\x0c_stepRetriesB\r\n\x0b_retryCount\"\xa8\x01\n\x10WorkflowRunEvent\x12\x15\n\rworkflowRunId\x18\x01 \x01(\t\x12(\n\teventType\x18\x02 \x01(\x0e\x32\x15.WorkflowRunEventType\x12\x32\n\x0e\x65ventTimestamp\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1f\n\x07results\x18\x04 \x03(\x0b\x32\x0e.StepRunResult\"\x8a\x01\n\rStepRunResult\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12\x16\n\x0estepReadableId\x18\x02 \x01(\t\x12\x10\n\x08jobRunId\x18\x03 \x01(\t\x12\x12\n\x05\x65rror\x18\x04 \x01(\tH\x00\x88\x01\x01\x12\x13\n\x06output\x18\x05 \x01(\tH\x01\x88\x01\x01\x42\x08\n\x06_errorB\t\n\x07_output\"W\n\rOverridesData\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\x12\r\n\x05value\x18\x03 \x01(\t\x12\x16\n\x0e\x63\x61llerFilename\x18\x04 \x01(\t\"\x17\n\x15OverridesDataResponse\"U\n\x10HeartbeatRequest\x12\x10\n\x08workerId\x18\x01 \x01(\t\x12/\n\x0bheartbeatAt\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x13\n\x11HeartbeatResponse\"F\n\x15RefreshTimeoutRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\x12\x1a\n\x12incrementTimeoutBy\x18\x02 \x01(\t\"G\n\x16RefreshTimeoutResponse\x12-\n\ttimeoutAt\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\'\n\x12ReleaseSlotRequest\x12\x11\n\tstepRunId\x18\x01 \x01(\t\"\x15\n\x13ReleaseSlotResponse*7\n\x04SDKS\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x06\n\x02GO\x10\x01\x12\n\n\x06PYTHON\x10\x02\x12\x0e\n\nTYPESCRIPT\x10\x03*N\n\nActionType\x12\x12\n\x0eSTART_STEP_RUN\x10\x00\x12\x13\n\x0f\x43\x41NCEL_STEP_RUN\x10\x01\x12\x17\n\x13START_GET_GROUP_KEY\x10\x02*\xa2\x01\n\x17GroupKeyActionEventType\x12 \n\x1cGROUP_KEY_EVENT_TYPE_UNKNOWN\x10\x00\x12 \n\x1cGROUP_KEY_EVENT_TYPE_STARTED\x10\x01\x12\"\n\x1eGROUP_KEY_EVENT_TYPE_COMPLETED\x10\x02\x12\x1f\n\x1bGROUP_KEY_EVENT_TYPE_FAILED\x10\x03*\xac\x01\n\x13StepActionEventType\x12\x1b\n\x17STEP_EVENT_TYPE_UNKNOWN\x10\x00\x12\x1b\n\x17STEP_EVENT_TYPE_STARTED\x10\x01\x12\x1d\n\x19STEP_EVENT_TYPE_COMPLETED\x10\x02\x12\x1a\n\x16STEP_EVENT_TYPE_FAILED\x10\x03\x12 \n\x1cSTEP_EVENT_TYPE_ACKNOWLEDGED\x10\x04*e\n\x0cResourceType\x12\x19\n\x15RESOURCE_TYPE_UNKNOWN\x10\x00\x12\x1a\n\x16RESOURCE_TYPE_STEP_RUN\x10\x01\x12\x1e\n\x1aRESOURCE_TYPE_WORKFLOW_RUN\x10\x02*\xfe\x01\n\x11ResourceEventType\x12\x1f\n\x1bRESOURCE_EVENT_TYPE_UNKNOWN\x10\x00\x12\x1f\n\x1bRESOURCE_EVENT_TYPE_STARTED\x10\x01\x12!\n\x1dRESOURCE_EVENT_TYPE_COMPLETED\x10\x02\x12\x1e\n\x1aRESOURCE_EVENT_TYPE_FAILED\x10\x03\x12!\n\x1dRESOURCE_EVENT_TYPE_CANCELLED\x10\x04\x12!\n\x1dRESOURCE_EVENT_TYPE_TIMED_OUT\x10\x05\x12\x1e\n\x1aRESOURCE_EVENT_TYPE_STREAM\x10\x06*<\n\x14WorkflowRunEventType\x12$\n WORKFLOW_RUN_EVENT_TYPE_FINISHED\x10\x00\x32\xf8\x06\n\nDispatcher\x12=\n\x08Register\x12\x16.WorkerRegisterRequest\x1a\x17.WorkerRegisterResponse\"\x00\x12\x33\n\x06Listen\x12\x14.WorkerListenRequest\x1a\x0f.AssignedAction\"\x00\x30\x01\x12\x35\n\x08ListenV2\x12\x14.WorkerListenRequest\x1a\x0f.AssignedAction\"\x00\x30\x01\x12\x34\n\tHeartbeat\x12\x11.HeartbeatRequest\x1a\x12.HeartbeatResponse\"\x00\x12R\n\x19SubscribeToWorkflowEvents\x12!.SubscribeToWorkflowEventsRequest\x1a\x0e.WorkflowEvent\"\x00\x30\x01\x12S\n\x17SubscribeToWorkflowRuns\x12\x1f.SubscribeToWorkflowRunsRequest\x1a\x11.WorkflowRunEvent\"\x00(\x01\x30\x01\x12?\n\x13SendStepActionEvent\x12\x10.StepActionEvent\x1a\x14.ActionEventResponse\"\x00\x12G\n\x17SendGroupKeyActionEvent\x12\x14.GroupKeyActionEvent\x1a\x14.ActionEventResponse\"\x00\x12<\n\x10PutOverridesData\x12\x0e.OverridesData\x1a\x16.OverridesDataResponse\"\x00\x12\x46\n\x0bUnsubscribe\x12\x19.WorkerUnsubscribeRequest\x1a\x1a.WorkerUnsubscribeResponse\"\x00\x12\x43\n\x0eRefreshTimeout\x12\x16.RefreshTimeoutRequest\x1a\x17.RefreshTimeoutResponse\"\x00\x12:\n\x0bReleaseSlot\x12\x13.ReleaseSlotRequest\x1a\x14.ReleaseSlotResponse\"\x00\x12O\n\x12UpsertWorkerLabels\x12\x1a.UpsertWorkerLabelsRequest\x1a\x1b.UpsertWorkerLabelsResponse\"\x00\x42GZEgithub.com/hatchet-dev/hatchet/internal/services/dispatcher/contractsb\x06proto3')
19
19
 
20
20
  _globals = globals()
21
21
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
@@ -27,20 +27,20 @@ if not _descriptor._USE_C_DESCRIPTORS:
27
27
  _globals['_WORKERREGISTERREQUEST_LABELSENTRY']._serialized_options = b'8\001'
28
28
  _globals['_UPSERTWORKERLABELSREQUEST_LABELSENTRY']._loaded_options = None
29
29
  _globals['_UPSERTWORKERLABELSREQUEST_LABELSENTRY']._serialized_options = b'8\001'
30
- _globals['_SDKS']._serialized_start=3524
31
- _globals['_SDKS']._serialized_end=3579
32
- _globals['_ACTIONTYPE']._serialized_start=3581
33
- _globals['_ACTIONTYPE']._serialized_end=3659
34
- _globals['_GROUPKEYACTIONEVENTTYPE']._serialized_start=3662
35
- _globals['_GROUPKEYACTIONEVENTTYPE']._serialized_end=3824
36
- _globals['_STEPACTIONEVENTTYPE']._serialized_start=3827
37
- _globals['_STEPACTIONEVENTTYPE']._serialized_end=3999
38
- _globals['_RESOURCETYPE']._serialized_start=4001
39
- _globals['_RESOURCETYPE']._serialized_end=4102
40
- _globals['_RESOURCEEVENTTYPE']._serialized_start=4105
41
- _globals['_RESOURCEEVENTTYPE']._serialized_end=4359
42
- _globals['_WORKFLOWRUNEVENTTYPE']._serialized_start=4361
43
- _globals['_WORKFLOWRUNEVENTTYPE']._serialized_end=4421
30
+ _globals['_SDKS']._serialized_start=3572
31
+ _globals['_SDKS']._serialized_end=3627
32
+ _globals['_ACTIONTYPE']._serialized_start=3629
33
+ _globals['_ACTIONTYPE']._serialized_end=3707
34
+ _globals['_GROUPKEYACTIONEVENTTYPE']._serialized_start=3710
35
+ _globals['_GROUPKEYACTIONEVENTTYPE']._serialized_end=3872
36
+ _globals['_STEPACTIONEVENTTYPE']._serialized_start=3875
37
+ _globals['_STEPACTIONEVENTTYPE']._serialized_end=4047
38
+ _globals['_RESOURCETYPE']._serialized_start=4049
39
+ _globals['_RESOURCETYPE']._serialized_end=4150
40
+ _globals['_RESOURCEEVENTTYPE']._serialized_start=4153
41
+ _globals['_RESOURCEEVENTTYPE']._serialized_end=4407
42
+ _globals['_WORKFLOWRUNEVENTTYPE']._serialized_start=4409
43
+ _globals['_WORKFLOWRUNEVENTTYPE']._serialized_end=4469
44
44
  _globals['_WORKERLABELS']._serialized_start=53
45
45
  _globals['_WORKERLABELS']._serialized_end=139
46
46
  _globals['_RUNTIMEINFO']._serialized_start=142
@@ -68,35 +68,35 @@ if not _descriptor._USE_C_DESCRIPTORS:
68
68
  _globals['_GROUPKEYACTIONEVENT']._serialized_start=1655
69
69
  _globals['_GROUPKEYACTIONEVENT']._serialized_end=1880
70
70
  _globals['_STEPACTIONEVENT']._serialized_start=1883
71
- _globals['_STEPACTIONEVENT']._serialized_end=2159
72
- _globals['_ACTIONEVENTRESPONSE']._serialized_start=2161
73
- _globals['_ACTIONEVENTRESPONSE']._serialized_end=2218
74
- _globals['_SUBSCRIBETOWORKFLOWEVENTSREQUEST']._serialized_start=2221
75
- _globals['_SUBSCRIBETOWORKFLOWEVENTSREQUEST']._serialized_end=2413
76
- _globals['_SUBSCRIBETOWORKFLOWRUNSREQUEST']._serialized_start=2415
77
- _globals['_SUBSCRIBETOWORKFLOWRUNSREQUEST']._serialized_end=2470
78
- _globals['_WORKFLOWEVENT']._serialized_start=2473
79
- _globals['_WORKFLOWEVENT']._serialized_end=2779
80
- _globals['_WORKFLOWRUNEVENT']._serialized_start=2782
81
- _globals['_WORKFLOWRUNEVENT']._serialized_end=2950
82
- _globals['_STEPRUNRESULT']._serialized_start=2953
83
- _globals['_STEPRUNRESULT']._serialized_end=3091
84
- _globals['_OVERRIDESDATA']._serialized_start=3093
85
- _globals['_OVERRIDESDATA']._serialized_end=3180
86
- _globals['_OVERRIDESDATARESPONSE']._serialized_start=3182
87
- _globals['_OVERRIDESDATARESPONSE']._serialized_end=3205
88
- _globals['_HEARTBEATREQUEST']._serialized_start=3207
89
- _globals['_HEARTBEATREQUEST']._serialized_end=3292
90
- _globals['_HEARTBEATRESPONSE']._serialized_start=3294
91
- _globals['_HEARTBEATRESPONSE']._serialized_end=3313
92
- _globals['_REFRESHTIMEOUTREQUEST']._serialized_start=3315
93
- _globals['_REFRESHTIMEOUTREQUEST']._serialized_end=3385
94
- _globals['_REFRESHTIMEOUTRESPONSE']._serialized_start=3387
95
- _globals['_REFRESHTIMEOUTRESPONSE']._serialized_end=3458
96
- _globals['_RELEASESLOTREQUEST']._serialized_start=3460
97
- _globals['_RELEASESLOTREQUEST']._serialized_end=3499
98
- _globals['_RELEASESLOTRESPONSE']._serialized_start=3501
99
- _globals['_RELEASESLOTRESPONSE']._serialized_end=3522
100
- _globals['_DISPATCHER']._serialized_start=4424
101
- _globals['_DISPATCHER']._serialized_end=5312
71
+ _globals['_STEPACTIONEVENT']._serialized_end=2207
72
+ _globals['_ACTIONEVENTRESPONSE']._serialized_start=2209
73
+ _globals['_ACTIONEVENTRESPONSE']._serialized_end=2266
74
+ _globals['_SUBSCRIBETOWORKFLOWEVENTSREQUEST']._serialized_start=2269
75
+ _globals['_SUBSCRIBETOWORKFLOWEVENTSREQUEST']._serialized_end=2461
76
+ _globals['_SUBSCRIBETOWORKFLOWRUNSREQUEST']._serialized_start=2463
77
+ _globals['_SUBSCRIBETOWORKFLOWRUNSREQUEST']._serialized_end=2518
78
+ _globals['_WORKFLOWEVENT']._serialized_start=2521
79
+ _globals['_WORKFLOWEVENT']._serialized_end=2827
80
+ _globals['_WORKFLOWRUNEVENT']._serialized_start=2830
81
+ _globals['_WORKFLOWRUNEVENT']._serialized_end=2998
82
+ _globals['_STEPRUNRESULT']._serialized_start=3001
83
+ _globals['_STEPRUNRESULT']._serialized_end=3139
84
+ _globals['_OVERRIDESDATA']._serialized_start=3141
85
+ _globals['_OVERRIDESDATA']._serialized_end=3228
86
+ _globals['_OVERRIDESDATARESPONSE']._serialized_start=3230
87
+ _globals['_OVERRIDESDATARESPONSE']._serialized_end=3253
88
+ _globals['_HEARTBEATREQUEST']._serialized_start=3255
89
+ _globals['_HEARTBEATREQUEST']._serialized_end=3340
90
+ _globals['_HEARTBEATRESPONSE']._serialized_start=3342
91
+ _globals['_HEARTBEATRESPONSE']._serialized_end=3361
92
+ _globals['_REFRESHTIMEOUTREQUEST']._serialized_start=3363
93
+ _globals['_REFRESHTIMEOUTREQUEST']._serialized_end=3433
94
+ _globals['_REFRESHTIMEOUTRESPONSE']._serialized_start=3435
95
+ _globals['_REFRESHTIMEOUTRESPONSE']._serialized_end=3506
96
+ _globals['_RELEASESLOTREQUEST']._serialized_start=3508
97
+ _globals['_RELEASESLOTREQUEST']._serialized_end=3547
98
+ _globals['_RELEASESLOTRESPONSE']._serialized_start=3549
99
+ _globals['_RELEASESLOTRESPONSE']._serialized_end=3570
100
+ _globals['_DISPATCHER']._serialized_start=4472
101
+ _globals['_DISPATCHER']._serialized_end=5360
102
102
  # @@protoc_insertion_point(module_scope)
@@ -239,7 +239,7 @@ class GroupKeyActionEvent(_message.Message):
239
239
  def __init__(self, workerId: _Optional[str] = ..., workflowRunId: _Optional[str] = ..., getGroupKeyRunId: _Optional[str] = ..., actionId: _Optional[str] = ..., eventTimestamp: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., eventType: _Optional[_Union[GroupKeyActionEventType, str]] = ..., eventPayload: _Optional[str] = ...) -> None: ...
240
240
 
241
241
  class StepActionEvent(_message.Message):
242
- __slots__ = ("workerId", "jobId", "jobRunId", "stepId", "stepRunId", "actionId", "eventTimestamp", "eventType", "eventPayload", "retryCount")
242
+ __slots__ = ("workerId", "jobId", "jobRunId", "stepId", "stepRunId", "actionId", "eventTimestamp", "eventType", "eventPayload", "retryCount", "shouldNotRetry")
243
243
  WORKERID_FIELD_NUMBER: _ClassVar[int]
244
244
  JOBID_FIELD_NUMBER: _ClassVar[int]
245
245
  JOBRUNID_FIELD_NUMBER: _ClassVar[int]
@@ -250,6 +250,7 @@ class StepActionEvent(_message.Message):
250
250
  EVENTTYPE_FIELD_NUMBER: _ClassVar[int]
251
251
  EVENTPAYLOAD_FIELD_NUMBER: _ClassVar[int]
252
252
  RETRYCOUNT_FIELD_NUMBER: _ClassVar[int]
253
+ SHOULDNOTRETRY_FIELD_NUMBER: _ClassVar[int]
253
254
  workerId: str
254
255
  jobId: str
255
256
  jobRunId: str
@@ -260,7 +261,8 @@ class StepActionEvent(_message.Message):
260
261
  eventType: StepActionEventType
261
262
  eventPayload: str
262
263
  retryCount: int
263
- def __init__(self, workerId: _Optional[str] = ..., jobId: _Optional[str] = ..., jobRunId: _Optional[str] = ..., stepId: _Optional[str] = ..., stepRunId: _Optional[str] = ..., actionId: _Optional[str] = ..., eventTimestamp: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., eventType: _Optional[_Union[StepActionEventType, str]] = ..., eventPayload: _Optional[str] = ..., retryCount: _Optional[int] = ...) -> None: ...
264
+ shouldNotRetry: bool
265
+ def __init__(self, workerId: _Optional[str] = ..., jobId: _Optional[str] = ..., jobRunId: _Optional[str] = ..., stepId: _Optional[str] = ..., stepRunId: _Optional[str] = ..., actionId: _Optional[str] = ..., eventTimestamp: _Optional[_Union[_timestamp_pb2.Timestamp, _Mapping]] = ..., eventType: _Optional[_Union[StepActionEventType, str]] = ..., eventPayload: _Optional[str] = ..., retryCount: _Optional[int] = ..., shouldNotRetry: bool = ...) -> None: ...
264
266
 
265
267
  class ActionEventResponse(_message.Message):
266
268
  __slots__ = ("tenantId", "workerId")
@@ -33,7 +33,7 @@ if _version_not_supported:
33
33
  class DispatcherStub(object):
34
34
  """Missing associated documentation comment in .proto file."""
35
35
 
36
- def __init__(self, channel):
36
+ def __init__(self, channel: grpc.Channel | grpc.aio.Channel) -> None:
37
37
  """Constructor.
38
38
 
39
39
  Args:
@@ -33,7 +33,7 @@ if _version_not_supported:
33
33
  class EventsServiceStub(object):
34
34
  """Missing associated documentation comment in .proto file."""
35
35
 
36
- def __init__(self, channel):
36
+ def __init__(self, channel: grpc.Channel | grpc.aio.Channel) -> None:
37
37
  """Constructor.
38
38
 
39
39
  Args:
@@ -33,7 +33,7 @@ if _version_not_supported:
33
33
  class V1DispatcherStub(object):
34
34
  """Missing associated documentation comment in .proto file."""
35
35
 
36
- def __init__(self, channel):
36
+ def __init__(self, channel: grpc.Channel | grpc.aio.Channel) -> None:
37
37
  """Constructor.
38
38
 
39
39
  Args:
@@ -34,7 +34,7 @@ class AdminServiceStub(object):
34
34
  """AdminService represents a set of RPCs for admin management of tasks, workflows, etc.
35
35
  """
36
36
 
37
- def __init__(self, channel):
37
+ def __init__(self, channel: grpc.Channel | grpc.aio.Channel) -> None:
38
38
  """Constructor.
39
39
 
40
40
  Args:
@@ -34,7 +34,7 @@ class WorkflowServiceStub(object):
34
34
  """WorkflowService represents a set of RPCs for managing workflows.
35
35
  """
36
36
 
37
- def __init__(self, channel):
37
+ def __init__(self, channel: grpc.Channel | grpc.aio.Channel) -> None:
38
38
  """Constructor.
39
39
 
40
40
  Args:
@@ -18,6 +18,7 @@ from hatchet_sdk.clients.v1.api_client import (
18
18
  BaseRestClient,
19
19
  maybe_additional_metadata_to_kv,
20
20
  )
21
+ from hatchet_sdk.utils.aio import run_async_from_sync
21
22
  from hatchet_sdk.utils.typing import JSONSerializableMapping
22
23
 
23
24
 
@@ -121,7 +122,7 @@ class CronClient(BaseRestClient):
121
122
  input: JSONSerializableMapping,
122
123
  additional_metadata: JSONSerializableMapping,
123
124
  ) -> CronWorkflows:
124
- return self._run_async_from_sync(
125
+ return run_async_from_sync(
125
126
  self.aio_create,
126
127
  workflow_name,
127
128
  cron_name,
@@ -143,7 +144,7 @@ class CronClient(BaseRestClient):
143
144
  )
144
145
 
145
146
  def delete(self, cron_id: str) -> None:
146
- return self._run_async_from_sync(self.aio_delete, cron_id)
147
+ return run_async_from_sync(self.aio_delete, cron_id)
147
148
 
148
149
  async def aio_list(
149
150
  self,
@@ -204,7 +205,7 @@ class CronClient(BaseRestClient):
204
205
  Returns:
205
206
  CronWorkflowsList: A list of cron workflows.
206
207
  """
207
- return self._run_async_from_sync(
208
+ return run_async_from_sync(
208
209
  self.aio_list,
209
210
  offset=offset,
210
211
  limit=limit,
@@ -239,4 +240,4 @@ class CronClient(BaseRestClient):
239
240
  Returns:
240
241
  CronWorkflows: The requested cron workflow instance.
241
242
  """
242
- return self._run_async_from_sync(self.aio_get, cron_id)
243
+ return run_async_from_sync(self.aio_get, cron_id)
@@ -2,6 +2,7 @@ from hatchet_sdk.clients.rest.api.log_api import LogApi
2
2
  from hatchet_sdk.clients.rest.api_client import ApiClient
3
3
  from hatchet_sdk.clients.rest.models.v1_log_line_list import V1LogLineList
4
4
  from hatchet_sdk.clients.v1.api_client import BaseRestClient
5
+ from hatchet_sdk.utils.aio import run_async_from_sync
5
6
 
6
7
 
7
8
  class LogsClient(BaseRestClient):
@@ -13,4 +14,4 @@ class LogsClient(BaseRestClient):
13
14
  return await self._la(client).v1_log_line_list(task=task_run_id)
14
15
 
15
16
  def list(self, task_run_id: str) -> V1LogLineList:
16
- return self._run_async_from_sync(self.aio_list, task_run_id)
17
+ return run_async_from_sync(self.aio_list, task_run_id)
@@ -11,6 +11,7 @@ from hatchet_sdk.clients.v1.api_client import (
11
11
  BaseRestClient,
12
12
  maybe_additional_metadata_to_kv,
13
13
  )
14
+ from hatchet_sdk.utils.aio import run_async_from_sync
14
15
  from hatchet_sdk.utils.typing import JSONSerializableMapping
15
16
 
16
17
 
@@ -38,7 +39,7 @@ class MetricsClient(BaseRestClient):
38
39
  status: WorkflowRunStatus | None = None,
39
40
  group_key: str | None = None,
40
41
  ) -> WorkflowMetrics:
41
- return self._run_async_from_sync(
42
+ return run_async_from_sync(
42
43
  self.aio_get_workflow_metrics, workflow_id, status, group_key
43
44
  )
44
45
 
@@ -61,7 +62,7 @@ class MetricsClient(BaseRestClient):
61
62
  workflow_ids: list[str] | None = None,
62
63
  additional_metadata: JSONSerializableMapping | None = None,
63
64
  ) -> TenantQueueMetrics:
64
- return self._run_async_from_sync(
65
+ return run_async_from_sync(
65
66
  self.aio_get_queue_metrics, workflow_ids, additional_metadata
66
67
  )
67
68
 
@@ -72,4 +73,4 @@ class MetricsClient(BaseRestClient):
72
73
  )
73
74
 
74
75
  def get_task_metrics(self) -> TenantStepRunQueueMetrics:
75
- return self._run_async_from_sync(self.aio_get_task_metrics)
76
+ return run_async_from_sync(self.aio_get_task_metrics)
@@ -24,7 +24,7 @@ class RateLimitsClient(BaseRestClient):
24
24
  )
25
25
 
26
26
  conn = new_conn(self.client_config, False)
27
- client = WorkflowServiceStub(conn) # type: ignore[no-untyped-call]
27
+ client = WorkflowServiceStub(conn)
28
28
 
29
29
  client.PutRateLimit(
30
30
  v0_workflow_protos.PutRateLimitRequest(
@@ -19,6 +19,7 @@ from hatchet_sdk.clients.v1.api_client import (
19
19
  BaseRestClient,
20
20
  maybe_additional_metadata_to_kv,
21
21
  )
22
+ from hatchet_sdk.utils.aio import run_async_from_sync
22
23
  from hatchet_sdk.utils.typing import JSONSerializableMapping
23
24
 
24
25
 
@@ -93,7 +94,7 @@ class RunsClient(BaseRestClient):
93
94
  return await self._wra(client).v1_workflow_run_get(str(workflow_run_id))
94
95
 
95
96
  def get(self, workflow_run_id: str) -> V1WorkflowRunDetails:
96
- return self._run_async_from_sync(self.aio_get, workflow_run_id)
97
+ return run_async_from_sync(self.aio_get, workflow_run_id)
97
98
 
98
99
  async def aio_list(
99
100
  self,
@@ -138,7 +139,7 @@ class RunsClient(BaseRestClient):
138
139
  worker_id: str | None = None,
139
140
  parent_task_external_id: str | None = None,
140
141
  ) -> V1TaskSummaryList:
141
- return self._run_async_from_sync(
142
+ return run_async_from_sync(
142
143
  self.aio_list,
143
144
  since=since,
144
145
  only_tasks=only_tasks,
@@ -174,7 +175,7 @@ class RunsClient(BaseRestClient):
174
175
  input: JSONSerializableMapping,
175
176
  additional_metadata: JSONSerializableMapping = {},
176
177
  ) -> V1WorkflowRunDetails:
177
- return self._run_async_from_sync(
178
+ return run_async_from_sync(
178
179
  self.aio_create, workflow_name, input, additional_metadata
179
180
  )
180
181
 
@@ -182,7 +183,7 @@ class RunsClient(BaseRestClient):
182
183
  await self.aio_bulk_replay(opts=BulkCancelReplayOpts(ids=[run_id]))
183
184
 
184
185
  def replay(self, run_id: str) -> None:
185
- return self._run_async_from_sync(self.aio_replay, run_id)
186
+ return run_async_from_sync(self.aio_replay, run_id)
186
187
 
187
188
  async def aio_bulk_replay(self, opts: BulkCancelReplayOpts) -> None:
188
189
  async with self.client() as client:
@@ -192,13 +193,13 @@ class RunsClient(BaseRestClient):
192
193
  )
193
194
 
194
195
  def bulk_replay(self, opts: BulkCancelReplayOpts) -> None:
195
- return self._run_async_from_sync(self.aio_bulk_replay, opts)
196
+ return run_async_from_sync(self.aio_bulk_replay, opts)
196
197
 
197
198
  async def aio_cancel(self, run_id: str) -> None:
198
199
  await self.aio_bulk_cancel(opts=BulkCancelReplayOpts(ids=[run_id]))
199
200
 
200
201
  def cancel(self, run_id: str) -> None:
201
- return self._run_async_from_sync(self.aio_cancel, run_id)
202
+ return run_async_from_sync(self.aio_cancel, run_id)
202
203
 
203
204
  async def aio_bulk_cancel(self, opts: BulkCancelReplayOpts) -> None:
204
205
  async with self.client() as client:
@@ -208,7 +209,7 @@ class RunsClient(BaseRestClient):
208
209
  )
209
210
 
210
211
  def bulk_cancel(self, opts: BulkCancelReplayOpts) -> None:
211
- return self._run_async_from_sync(self.aio_bulk_cancel, opts)
212
+ return run_async_from_sync(self.aio_bulk_cancel, opts)
212
213
 
213
214
  async def aio_get_result(self, run_id: str) -> JSONSerializableMapping:
214
215
  details = await self.aio_get(run_id)
@@ -22,6 +22,7 @@ from hatchet_sdk.clients.v1.api_client import (
22
22
  BaseRestClient,
23
23
  maybe_additional_metadata_to_kv,
24
24
  )
25
+ from hatchet_sdk.utils.aio import run_async_from_sync
25
26
  from hatchet_sdk.utils.typing import JSONSerializableMapping
26
27
 
27
28
 
@@ -82,7 +83,7 @@ class ScheduledClient(BaseRestClient):
82
83
  ScheduledWorkflows: The created scheduled workflow instance.
83
84
  """
84
85
 
85
- return self._run_async_from_sync(
86
+ return run_async_from_sync(
86
87
  self.aio_create,
87
88
  workflow_name,
88
89
  trigger_at,
@@ -104,7 +105,7 @@ class ScheduledClient(BaseRestClient):
104
105
  )
105
106
 
106
107
  def delete(self, scheduled_id: str) -> None:
107
- self._run_async_from_sync(self.aio_delete, scheduled_id)
108
+ run_async_from_sync(self.aio_delete, scheduled_id)
108
109
 
109
110
  async def aio_list(
110
111
  self,
@@ -175,7 +176,7 @@ class ScheduledClient(BaseRestClient):
175
176
  Returns:
176
177
  List[ScheduledWorkflows]: A list of scheduled workflows matching the criteria.
177
178
  """
178
- return self._run_async_from_sync(
179
+ return run_async_from_sync(
179
180
  self.aio_list,
180
181
  offset=offset,
181
182
  limit=limit,
@@ -214,4 +215,4 @@ class ScheduledClient(BaseRestClient):
214
215
  Returns:
215
216
  ScheduledWorkflows: The requested scheduled workflow instance.
216
217
  """
217
- return self._run_async_from_sync(self.aio_get, scheduled_id)
218
+ return run_async_from_sync(self.aio_get, scheduled_id)
@@ -4,6 +4,7 @@ from hatchet_sdk.clients.rest.models.update_worker_request import UpdateWorkerRe
4
4
  from hatchet_sdk.clients.rest.models.worker import Worker
5
5
  from hatchet_sdk.clients.rest.models.worker_list import WorkerList
6
6
  from hatchet_sdk.clients.v1.api_client import BaseRestClient
7
+ from hatchet_sdk.utils.aio import run_async_from_sync
7
8
 
8
9
 
9
10
  class WorkersClient(BaseRestClient):
@@ -15,7 +16,7 @@ class WorkersClient(BaseRestClient):
15
16
  return await self._wa(client).worker_get(worker_id)
16
17
 
17
18
  def get(self, worker_id: str) -> Worker:
18
- return self._run_async_from_sync(self.aio_get, worker_id)
19
+ return run_async_from_sync(self.aio_get, worker_id)
19
20
 
20
21
  async def aio_list(
21
22
  self,
@@ -28,7 +29,7 @@ class WorkersClient(BaseRestClient):
28
29
  def list(
29
30
  self,
30
31
  ) -> WorkerList:
31
- return self._run_async_from_sync(self.aio_list)
32
+ return run_async_from_sync(self.aio_list)
32
33
 
33
34
  async def aio_update(self, worker_id: str, opts: UpdateWorkerRequest) -> Worker:
34
35
  async with self.client() as client:
@@ -38,4 +39,4 @@ class WorkersClient(BaseRestClient):
38
39
  )
39
40
 
40
41
  def update(self, worker_id: str, opts: UpdateWorkerRequest) -> Worker:
41
- return self._run_async_from_sync(self.aio_update, worker_id, opts)
42
+ return run_async_from_sync(self.aio_update, worker_id, opts)
@@ -5,6 +5,7 @@ from hatchet_sdk.clients.rest.models.workflow import Workflow
5
5
  from hatchet_sdk.clients.rest.models.workflow_list import WorkflowList
6
6
  from hatchet_sdk.clients.rest.models.workflow_version import WorkflowVersion
7
7
  from hatchet_sdk.clients.v1.api_client import BaseRestClient
8
+ from hatchet_sdk.utils.aio import run_async_from_sync
8
9
 
9
10
 
10
11
  class WorkflowsClient(BaseRestClient):
@@ -19,7 +20,7 @@ class WorkflowsClient(BaseRestClient):
19
20
  return await self._wa(client).workflow_get(workflow_id)
20
21
 
21
22
  def get(self, workflow_id: str) -> Workflow:
22
- return self._run_async_from_sync(self.aio_get, workflow_id)
23
+ return run_async_from_sync(self.aio_get, workflow_id)
23
24
 
24
25
  async def aio_list(
25
26
  self,
@@ -41,7 +42,7 @@ class WorkflowsClient(BaseRestClient):
41
42
  limit: int | None = None,
42
43
  offset: int | None = None,
43
44
  ) -> WorkflowList:
44
- return self._run_async_from_sync(self.aio_list, workflow_name, limit, offset)
45
+ return run_async_from_sync(self.aio_list, workflow_name, limit, offset)
45
46
 
46
47
  async def aio_get_version(
47
48
  self, workflow_id: str, version: str | None = None
@@ -52,4 +53,4 @@ class WorkflowsClient(BaseRestClient):
52
53
  def get_version(
53
54
  self, workflow_id: str, version: str | None = None
54
55
  ) -> WorkflowVersion:
55
- return self._run_async_from_sync(self.aio_get_version, workflow_id, version)
56
+ return run_async_from_sync(self.aio_get_version, workflow_id, version)
hatchet_sdk/metadata.py CHANGED
@@ -1,2 +1,2 @@
1
- def get_metadata(token: str) -> list[tuple[str, str]]:
2
- return [("authorization", "bearer " + token)]
1
+ def get_metadata(token: str) -> tuple[tuple[str, str]]:
2
+ return (("authorization", "bearer " + token),)
@@ -1,4 +1,3 @@
1
- import asyncio
2
1
  from datetime import datetime
3
2
  from typing import Any, Generic, cast, get_type_hints
4
3
 
@@ -12,7 +11,7 @@ from hatchet_sdk.contracts.workflows_pb2 import WorkflowVersion
12
11
  from hatchet_sdk.runnables.task import Task
13
12
  from hatchet_sdk.runnables.types import EmptyModel, R, TWorkflowInput
14
13
  from hatchet_sdk.runnables.workflow import BaseWorkflow, Workflow
15
- from hatchet_sdk.utils.aio_utils import get_active_event_loop
14
+ from hatchet_sdk.utils.aio import run_async_from_sync
16
15
  from hatchet_sdk.utils.typing import JSONSerializableMapping, is_basemodel_subclass
17
16
  from hatchet_sdk.workflow_run import WorkflowRunRef
18
17
 
@@ -27,25 +26,11 @@ class TaskRunRef(Generic[TWorkflowInput, R]):
27
26
  self._wrr = workflow_run_ref
28
27
 
29
28
  async def aio_result(self) -> R:
30
- result = await self._wrr.workflow_listener.result(self._wrr.workflow_run_id)
29
+ result = await self._wrr.workflow_listener.aio_result(self._wrr.workflow_run_id)
31
30
  return self._s._extract_result(result)
32
31
 
33
32
  def result(self) -> R:
34
- coro = self._wrr.workflow_listener.result(self._wrr.workflow_run_id)
35
-
36
- loop = get_active_event_loop()
37
-
38
- if loop is None:
39
- loop = asyncio.new_event_loop()
40
- asyncio.set_event_loop(loop)
41
- try:
42
- result = loop.run_until_complete(coro)
43
- finally:
44
- asyncio.set_event_loop(None)
45
- else:
46
- result = loop.run_until_complete(coro)
47
-
48
- return self._s._extract_result(result)
33
+ return run_async_from_sync(self.aio_result)
49
34
 
50
35
 
51
36
  class Standalone(BaseWorkflow[TWorkflowInput], Generic[TWorkflowInput, R]):
@@ -44,6 +44,10 @@ def fall_back_to_default(value: T, default: T, fallback_value: T) -> T:
44
44
  return fallback_value
45
45
 
46
46
 
47
+ class NonRetryableException(Exception):
48
+ pass
49
+
50
+
47
51
  class Task(Generic[TWorkflowInput, R]):
48
52
  def __init__(
49
53
  self,