hatchet-sdk 1.0.0__py3-none-any.whl → 1.0.1__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 (73) hide show
  1. hatchet_sdk/__init__.py +32 -16
  2. hatchet_sdk/client.py +25 -63
  3. hatchet_sdk/clients/admin.py +203 -142
  4. hatchet_sdk/clients/dispatcher/action_listener.py +42 -42
  5. hatchet_sdk/clients/dispatcher/dispatcher.py +18 -16
  6. hatchet_sdk/clients/durable_event_listener.py +327 -0
  7. hatchet_sdk/clients/rest/__init__.py +12 -1
  8. hatchet_sdk/clients/rest/api/log_api.py +258 -0
  9. hatchet_sdk/clients/rest/api/task_api.py +32 -6
  10. hatchet_sdk/clients/rest/api/workflow_runs_api.py +626 -0
  11. hatchet_sdk/clients/rest/models/__init__.py +12 -1
  12. hatchet_sdk/clients/rest/models/v1_log_line.py +94 -0
  13. hatchet_sdk/clients/rest/models/v1_log_line_level.py +39 -0
  14. hatchet_sdk/clients/rest/models/v1_log_line_list.py +110 -0
  15. hatchet_sdk/clients/rest/models/v1_task_summary.py +80 -64
  16. hatchet_sdk/clients/rest/models/v1_trigger_workflow_run_request.py +95 -0
  17. hatchet_sdk/clients/rest/models/v1_workflow_run_display_name.py +98 -0
  18. hatchet_sdk/clients/rest/models/v1_workflow_run_display_name_list.py +114 -0
  19. hatchet_sdk/clients/rest/models/workflow_run_shape_item_for_workflow_run_details.py +9 -4
  20. hatchet_sdk/clients/rest/models/workflow_runs_metrics.py +5 -1
  21. hatchet_sdk/clients/run_event_listener.py +0 -1
  22. hatchet_sdk/clients/v1/api_client.py +81 -0
  23. hatchet_sdk/context/context.py +86 -159
  24. hatchet_sdk/contracts/dispatcher_pb2_grpc.py +1 -1
  25. hatchet_sdk/contracts/events_pb2.py +2 -2
  26. hatchet_sdk/contracts/events_pb2_grpc.py +1 -1
  27. hatchet_sdk/contracts/v1/dispatcher_pb2.py +36 -0
  28. hatchet_sdk/contracts/v1/dispatcher_pb2.pyi +38 -0
  29. hatchet_sdk/contracts/v1/dispatcher_pb2_grpc.py +145 -0
  30. hatchet_sdk/contracts/v1/shared/condition_pb2.py +39 -0
  31. hatchet_sdk/contracts/v1/shared/condition_pb2.pyi +72 -0
  32. hatchet_sdk/contracts/v1/shared/condition_pb2_grpc.py +29 -0
  33. hatchet_sdk/contracts/v1/workflows_pb2.py +67 -0
  34. hatchet_sdk/contracts/v1/workflows_pb2.pyi +228 -0
  35. hatchet_sdk/contracts/v1/workflows_pb2_grpc.py +234 -0
  36. hatchet_sdk/contracts/workflows_pb2_grpc.py +1 -1
  37. hatchet_sdk/features/cron.py +91 -121
  38. hatchet_sdk/features/logs.py +16 -0
  39. hatchet_sdk/features/metrics.py +75 -0
  40. hatchet_sdk/features/rate_limits.py +45 -0
  41. hatchet_sdk/features/runs.py +221 -0
  42. hatchet_sdk/features/scheduled.py +114 -131
  43. hatchet_sdk/features/workers.py +41 -0
  44. hatchet_sdk/features/workflows.py +55 -0
  45. hatchet_sdk/hatchet.py +463 -165
  46. hatchet_sdk/opentelemetry/instrumentor.py +8 -13
  47. hatchet_sdk/rate_limit.py +33 -39
  48. hatchet_sdk/runnables/contextvars.py +12 -0
  49. hatchet_sdk/runnables/standalone.py +192 -0
  50. hatchet_sdk/runnables/task.py +144 -0
  51. hatchet_sdk/runnables/types.py +138 -0
  52. hatchet_sdk/runnables/workflow.py +771 -0
  53. hatchet_sdk/utils/aio_utils.py +0 -79
  54. hatchet_sdk/utils/proto_enums.py +0 -7
  55. hatchet_sdk/utils/timedelta_to_expression.py +23 -0
  56. hatchet_sdk/utils/typing.py +2 -2
  57. hatchet_sdk/v0/clients/rest_client.py +9 -0
  58. hatchet_sdk/v0/worker/action_listener_process.py +18 -2
  59. hatchet_sdk/waits.py +120 -0
  60. hatchet_sdk/worker/action_listener_process.py +64 -30
  61. hatchet_sdk/worker/runner/run_loop_manager.py +35 -26
  62. hatchet_sdk/worker/runner/runner.py +72 -55
  63. hatchet_sdk/worker/runner/utils/capture_logs.py +3 -11
  64. hatchet_sdk/worker/worker.py +155 -118
  65. hatchet_sdk/workflow_run.py +4 -5
  66. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/METADATA +1 -2
  67. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/RECORD +69 -43
  68. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/entry_points.txt +2 -0
  69. hatchet_sdk/clients/rest_client.py +0 -636
  70. hatchet_sdk/semver.py +0 -30
  71. hatchet_sdk/worker/runner/utils/error_with_traceback.py +0 -6
  72. hatchet_sdk/workflow.py +0 -527
  73. {hatchet_sdk-1.0.0.dist-info → hatchet_sdk-1.0.1.dist-info}/WHEEL +0 -0
hatchet_sdk/__init__.py CHANGED
@@ -1,10 +1,9 @@
1
- from hatchet_sdk.client import new_client
2
1
  from hatchet_sdk.clients.admin import (
3
- ChildTriggerWorkflowOptions,
4
2
  DedupeViolationErr,
5
3
  ScheduleTriggerWorkflowOptions,
6
4
  TriggerWorkflowOptions,
7
5
  )
6
+ from hatchet_sdk.clients.durable_event_listener import RegisterDurableEventRequest
8
7
  from hatchet_sdk.clients.events import PushEventOptions
9
8
  from hatchet_sdk.clients.rest.models.accept_invite_request import AcceptInviteRequest
10
9
 
@@ -76,7 +75,6 @@ from hatchet_sdk.clients.rest.models.pull_request_state import PullRequestState
76
75
  from hatchet_sdk.clients.rest.models.reject_invite_request import RejectInviteRequest
77
76
  from hatchet_sdk.clients.rest.models.replay_event_request import ReplayEventRequest
78
77
  from hatchet_sdk.clients.rest.models.rerun_step_run_request import RerunStepRunRequest
79
- from hatchet_sdk.clients.rest.models.step import Step
80
78
  from hatchet_sdk.clients.rest.models.step_run import StepRun
81
79
  from hatchet_sdk.clients.rest.models.step_run_diff import StepRunDiff
82
80
  from hatchet_sdk.clients.rest.models.step_run_status import StepRunStatus
@@ -100,6 +98,7 @@ from hatchet_sdk.clients.rest.models.user_tenant_memberships_list import (
100
98
  UserTenantMembershipsList,
101
99
  )
102
100
  from hatchet_sdk.clients.rest.models.user_tenant_public import UserTenantPublic
101
+ from hatchet_sdk.clients.rest.models.v1_task_status import V1TaskStatus
103
102
  from hatchet_sdk.clients.rest.models.worker_list import WorkerList
104
103
  from hatchet_sdk.clients.rest.models.workflow import Workflow
105
104
  from hatchet_sdk.clients.rest.models.workflow_deployment_config import (
@@ -130,23 +129,33 @@ from hatchet_sdk.clients.run_event_listener import (
130
129
  WorkflowRunEventType,
131
130
  )
132
131
  from hatchet_sdk.config import ClientConfig
133
- from hatchet_sdk.context.context import Context
132
+ from hatchet_sdk.context.context import Context, DurableContext
134
133
  from hatchet_sdk.context.worker_context import WorkerContext
135
134
  from hatchet_sdk.contracts.workflows_pb2 import (
136
135
  CreateWorkflowVersionOpts,
137
136
  RateLimitDuration,
138
137
  WorkerLabelComparator,
139
138
  )
139
+ from hatchet_sdk.features.runs import BulkCancelReplayOpts, RunFilter
140
140
  from hatchet_sdk.hatchet import Hatchet
141
- from hatchet_sdk.utils.aio_utils import sync_to_async
142
- from hatchet_sdk.worker.worker import Worker, WorkerStartOptions, WorkerStatus
143
- from hatchet_sdk.workflow import (
144
- BaseWorkflow,
141
+ from hatchet_sdk.runnables.task import Task
142
+ from hatchet_sdk.runnables.types import (
145
143
  ConcurrencyExpression,
146
144
  ConcurrencyLimitStrategy,
145
+ EmptyModel,
147
146
  StickyStrategy,
147
+ TaskDefaults,
148
148
  WorkflowConfig,
149
149
  )
150
+ from hatchet_sdk.waits import (
151
+ Condition,
152
+ OrGroup,
153
+ ParentCondition,
154
+ SleepCondition,
155
+ UserEventCondition,
156
+ or_,
157
+ )
158
+ from hatchet_sdk.worker.worker import Worker, WorkerStartOptions, WorkerStatus
150
159
 
151
160
  __all__ = [
152
161
  "AcceptInviteRequest",
@@ -191,11 +200,9 @@ __all__ = [
191
200
  "RejectInviteRequest",
192
201
  "ReplayEventRequest",
193
202
  "RerunStepRunRequest",
194
- "Step",
195
203
  "StepRun",
196
204
  "StepRunDiff",
197
205
  "StepRunStatus",
198
- "sync_to_async",
199
206
  "Tenant",
200
207
  "TenantInvite",
201
208
  "TenantInviteList",
@@ -231,8 +238,6 @@ __all__ = [
231
238
  "CreateWorkflowVersionOpts",
232
239
  "RateLimitDuration",
233
240
  "StickyStrategy",
234
- "new_client",
235
- "ChildTriggerWorkflowOptions",
236
241
  "DedupeViolationErr",
237
242
  "ScheduleTriggerWorkflowOptions",
238
243
  "TriggerWorkflowOptions",
@@ -243,14 +248,25 @@ __all__ = [
243
248
  "WorkerContext",
244
249
  "ClientConfig",
245
250
  "Hatchet",
246
- "concurrency",
247
- "on_failure_step",
248
- "step",
249
251
  "workflow",
250
252
  "Worker",
251
253
  "WorkerStartOptions",
252
254
  "WorkerStatus",
253
255
  "ConcurrencyExpression",
254
- "BaseWorkflow",
256
+ "Workflow",
255
257
  "WorkflowConfig",
258
+ "Task",
259
+ "EmptyModel",
260
+ "Condition",
261
+ "OrGroup",
262
+ "or_",
263
+ "SleepCondition",
264
+ "UserEventCondition",
265
+ "ParentCondition",
266
+ "DurableContext",
267
+ "RegisterDurableEventRequest",
268
+ "TaskDefaults",
269
+ "BulkCancelReplayOpts",
270
+ "RunFilter",
271
+ "V1TaskStatus",
256
272
  ]
hatchet_sdk/client.py CHANGED
@@ -1,76 +1,32 @@
1
1
  import asyncio
2
- from typing import Callable
3
2
 
4
3
  import grpc
5
4
 
6
5
  from hatchet_sdk.clients.admin import AdminClient
7
6
  from hatchet_sdk.clients.dispatcher.dispatcher import DispatcherClient
8
7
  from hatchet_sdk.clients.events import EventClient, new_event
9
- from hatchet_sdk.clients.rest_client import RestApi
10
8
  from hatchet_sdk.clients.run_event_listener import RunEventListenerClient
11
9
  from hatchet_sdk.clients.workflow_listener import PooledWorkflowRunListener
12
10
  from hatchet_sdk.config import ClientConfig
13
11
  from hatchet_sdk.connection import new_conn
12
+ from hatchet_sdk.features.cron import CronClient
13
+ from hatchet_sdk.features.logs import LogsClient
14
+ from hatchet_sdk.features.metrics import MetricsClient
15
+ from hatchet_sdk.features.rate_limits import RateLimitsClient
16
+ from hatchet_sdk.features.runs import RunsClient
17
+ from hatchet_sdk.features.scheduled import ScheduledClient
18
+ from hatchet_sdk.features.workers import WorkersClient
19
+ from hatchet_sdk.features.workflows import WorkflowsClient
14
20
 
15
21
 
16
22
  class Client:
17
- @classmethod
18
- def from_environment(
19
- cls,
20
- defaults: ClientConfig = ClientConfig(),
21
- debug: bool = False,
22
- *opts_functions: Callable[[ClientConfig], None],
23
- ) -> "Client":
24
- try:
25
- loop = asyncio.get_running_loop()
26
- except RuntimeError:
27
- loop = asyncio.new_event_loop()
28
- asyncio.set_event_loop(loop)
29
-
30
- for opt_function in opts_functions:
31
- opt_function(defaults)
32
-
33
- return cls.from_config(defaults, debug)
34
-
35
- @classmethod
36
- def from_config(
37
- cls,
38
- config: ClientConfig = ClientConfig(),
39
- debug: bool = False,
40
- ) -> "Client":
41
- try:
42
- loop = asyncio.get_running_loop()
43
- except RuntimeError:
44
- loop = asyncio.new_event_loop()
45
- asyncio.set_event_loop(loop)
46
-
47
- conn: grpc.Channel = new_conn(config, False)
48
-
49
- # Instantiate clients
50
- event_client = new_event(conn, config)
51
- admin_client = AdminClient(config)
52
- dispatcher_client = DispatcherClient(config)
53
- rest_client = RestApi(config.server_url, config.token, config.tenant_id)
54
- workflow_listener = None # Initialize this if needed
55
-
56
- return cls(
57
- event_client,
58
- admin_client,
59
- dispatcher_client,
60
- workflow_listener,
61
- rest_client,
62
- config,
63
- debug,
64
- )
65
-
66
23
  def __init__(
67
24
  self,
68
- event_client: EventClient,
69
- admin_client: AdminClient,
70
- dispatcher_client: DispatcherClient,
71
- workflow_listener: PooledWorkflowRunListener | None,
72
- rest_client: RestApi,
73
25
  config: ClientConfig,
26
+ event_client: EventClient | None = None,
27
+ admin_client: AdminClient | None = None,
28
+ dispatcher_client: DispatcherClient | None = None,
29
+ workflow_listener: PooledWorkflowRunListener | None | None = None,
74
30
  debug: bool = False,
75
31
  ):
76
32
  try:
@@ -79,16 +35,22 @@ class Client:
79
35
  loop = asyncio.new_event_loop()
80
36
  asyncio.set_event_loop(loop)
81
37
 
82
- self.admin = admin_client
83
- self.dispatcher = dispatcher_client
84
- self.event = event_client
85
- self.rest = rest_client
38
+ conn: grpc.Channel = new_conn(config, False)
39
+
86
40
  self.config = config
41
+ self.admin = admin_client or AdminClient(config)
42
+ self.dispatcher = dispatcher_client or DispatcherClient(config)
43
+ self.event = event_client or new_event(conn, config)
87
44
  self.listener = RunEventListenerClient(config)
88
45
  self.workflow_listener = workflow_listener
89
46
  self.logInterceptor = config.logger
90
47
  self.debug = debug
91
48
 
92
-
93
- new_client = Client.from_environment
94
- new_client_raw = Client.from_config
49
+ self.cron = CronClient(self.config)
50
+ self.logs = LogsClient(self.config)
51
+ self.metrics = MetricsClient(self.config)
52
+ self.rate_limits = RateLimitsClient(self.config)
53
+ self.runs = RunsClient(self.config)
54
+ self.scheduled = ScheduledClient(self.config)
55
+ self.workers = WorkersClient(self.config)
56
+ self.workflows = WorkflowsClient(self.config)