Skip to content
This repository was archived by the owner on Feb 20, 2025. It is now read-only.

Commit f0ac9f4

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents f3cd051 + 3d29644 commit f0ac9f4

26 files changed

+462
-86
lines changed

examples/cancellation/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ async def step1(self, context: Context) -> None:
2323
print("Cancelled")
2424

2525

26-
workflow = CancelWorkflow()
27-
worker = hatchet.worker("cancellation-worker", max_runs=4)
28-
worker.register_workflow(workflow)
26+
def main() -> None:
27+
workflow = CancelWorkflow()
28+
worker = hatchet.worker("cancellation-worker", max_runs=4)
29+
worker.register_workflow(workflow)
2930

30-
worker.start()
31+
worker.start()
32+
33+
34+
if __name__ == "__main__":
35+
main()

examples/concurrency_limit_rr/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ def step1(self, context: Context) -> None:
3333
pass
3434

3535

36-
workflow = ConcurrencyDemoWorkflowRR()
37-
worker = hatchet.worker("concurrency-demo-worker-rr", max_runs=10)
38-
worker.register_workflow(workflow)
36+
def main() -> None:
37+
workflow = ConcurrencyDemoWorkflowRR()
38+
worker = hatchet.worker("concurrency-demo-worker-rr", max_runs=10)
39+
worker.register_workflow(workflow)
3940

40-
worker.start()
41+
worker.start()
42+
43+
44+
if __name__ == "__main__":
45+
main()

examples/delayed/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ def step1(self, context: Context) -> None:
3232
print(f"message \t {context.workflow_input()['message']}")
3333

3434

35-
worker = hatchet.worker("delayed-worker", max_runs=4)
36-
worker.register_workflow(PrintSchedule())
37-
worker.register_workflow(PrintPrinter())
35+
def main() -> None:
36+
worker = hatchet.worker("delayed-worker", max_runs=4)
37+
worker.register_workflow(PrintSchedule())
38+
worker.register_workflow(PrintPrinter())
3839

39-
worker.start()
40+
worker.start()
41+
42+
43+
if __name__ == "__main__":
44+
main()

examples/manual_trigger/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ def step2(self, context: Context) -> dict[str, str]:
4747
return {"step2": "data2"}
4848

4949

50-
workflow = ManualTriggerWorkflow()
51-
worker = hatchet.worker("manual-worker", max_runs=4)
52-
worker.register_workflow(workflow)
50+
def main() -> None:
51+
workflow = ManualTriggerWorkflow()
52+
worker = hatchet.worker("manual-worker", max_runs=4)
53+
worker.register_workflow(workflow)
5354

54-
worker.start()
55+
worker.start()
56+
57+
58+
if __name__ == "__main__":
59+
main()

examples/overrides/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ def step4(self, context: Context) -> dict[str, str]:
6969
}
7070

7171

72-
workflow = OverridesWorkflow()
73-
worker = hatchet.worker("overrides-worker")
74-
worker.register_workflow(workflow)
72+
def main() -> None:
73+
workflow = OverridesWorkflow()
74+
worker = hatchet.worker("overrides-worker")
75+
worker.register_workflow(workflow)
7576

76-
worker.start()
77+
worker.start()
78+
79+
80+
if __name__ == "__main__":
81+
main()

examples/rate_limit/worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ def main() -> None:
2323
worker.register_workflow(RateLimitWorkflow())
2424

2525
worker.start()
26+
27+
28+
if __name__ == "__main__":
29+
main()

examples/sticky_workers/worker.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ def child(self, context: Context) -> dict[str, str | None]:
3636
return {"worker": context.worker.id()}
3737

3838

39-
worker = hatchet.worker("sticky-worker", max_runs=10)
40-
worker.register_workflow(StickyWorkflow())
41-
worker.register_workflow(StickyChildWorkflow())
42-
worker.start()
39+
def main() -> None:
40+
worker = hatchet.worker("sticky-worker", max_runs=10)
41+
worker.register_workflow(StickyWorkflow())
42+
worker.register_workflow(StickyChildWorkflow())
43+
worker.start()
44+
45+
46+
if __name__ == "__main__":
47+
main()

hatchet_sdk/clients/dispatcher/dispatcher.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ def __init__(self, config: ClientConfig):
5353
async def get_action_listener(
5454
self, req: GetActionListenerRequest
5555
) -> ActionListener:
56+
57+
# Override labels with the preset labels
58+
preset_labels = self.config.worker_preset_labels
59+
60+
for key, value in preset_labels.items():
61+
req.labels[key] = WorkerLabels(strValue=str(value))
62+
5663
# Register the worker
5764
response: WorkerRegisterResponse = await self.aio_client.Register(
5865
WorkerRegisterRequest(
@@ -104,6 +111,7 @@ async def _try_send_step_action_event(
104111
eventTimestamp=eventTimestamp,
105112
eventType=event_type,
106113
eventPayload=payload,
114+
retryCount=action.retry_count,
107115
)
108116

109117
return cast(

hatchet_sdk/clients/rest/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
from hatchet_sdk.clients.rest.models.get_step_run_diff_response import (
112112
GetStepRunDiffResponse,
113113
)
114+
from hatchet_sdk.clients.rest.models.info_get_version200_response import (
115+
InfoGetVersion200Response,
116+
)
114117
from hatchet_sdk.clients.rest.models.job import Job
115118
from hatchet_sdk.clients.rest.models.job_run import JobRun
116119
from hatchet_sdk.clients.rest.models.job_run_status import JobRunStatus

hatchet_sdk/clients/rest/api/default_api.py

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
from hatchet_sdk.clients.rest.api_client import ApiClient, RequestSerialized
2121
from hatchet_sdk.clients.rest.api_response import ApiResponse
22+
from hatchet_sdk.clients.rest.models.info_get_version200_response import (
23+
InfoGetVersion200Response,
24+
)
2225
from hatchet_sdk.clients.rest.models.tenant_invite import TenantInvite
2326
from hatchet_sdk.clients.rest.models.update_tenant_invite_request import (
2427
UpdateTenantInviteRequest,
@@ -48,6 +51,233 @@ def __init__(self, api_client=None) -> None:
4851
api_client = ApiClient.get_default()
4952
self.api_client = api_client
5053

54+
@validate_call
55+
async def info_get_version(
56+
self,
57+
_request_timeout: Union[
58+
None,
59+
Annotated[StrictFloat, Field(gt=0)],
60+
Tuple[
61+
Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
62+
],
63+
] = None,
64+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
65+
_content_type: Optional[StrictStr] = None,
66+
_headers: Optional[Dict[StrictStr, Any]] = None,
67+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
68+
) -> InfoGetVersion200Response:
69+
"""We return the version for the currently running server
70+
71+
Get the version of the server
72+
73+
:param _request_timeout: timeout setting for this request. If one
74+
number provided, it will be total request
75+
timeout. It can also be a pair (tuple) of
76+
(connection, read) timeouts.
77+
:type _request_timeout: int, tuple(int, int), optional
78+
:param _request_auth: set to override the auth_settings for an a single
79+
request; this effectively ignores the
80+
authentication in the spec for a single request.
81+
:type _request_auth: dict, optional
82+
:param _content_type: force content-type for the request.
83+
:type _content_type: str, Optional
84+
:param _headers: set to override the headers for a single
85+
request; this effectively ignores the headers
86+
in the spec for a single request.
87+
:type _headers: dict, optional
88+
:param _host_index: set to override the host_index for a single
89+
request; this effectively ignores the host_index
90+
in the spec for a single request.
91+
:type _host_index: int, optional
92+
:return: Returns the result object.
93+
""" # noqa: E501
94+
95+
_param = self._info_get_version_serialize(
96+
_request_auth=_request_auth,
97+
_content_type=_content_type,
98+
_headers=_headers,
99+
_host_index=_host_index,
100+
)
101+
102+
_response_types_map: Dict[str, Optional[str]] = {
103+
"200": "InfoGetVersion200Response",
104+
}
105+
response_data = await self.api_client.call_api(
106+
*_param, _request_timeout=_request_timeout
107+
)
108+
await response_data.read()
109+
return self.api_client.response_deserialize(
110+
response_data=response_data,
111+
response_types_map=_response_types_map,
112+
).data
113+
114+
@validate_call
115+
async def info_get_version_with_http_info(
116+
self,
117+
_request_timeout: Union[
118+
None,
119+
Annotated[StrictFloat, Field(gt=0)],
120+
Tuple[
121+
Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
122+
],
123+
] = None,
124+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
125+
_content_type: Optional[StrictStr] = None,
126+
_headers: Optional[Dict[StrictStr, Any]] = None,
127+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
128+
) -> ApiResponse[InfoGetVersion200Response]:
129+
"""We return the version for the currently running server
130+
131+
Get the version of the server
132+
133+
:param _request_timeout: timeout setting for this request. If one
134+
number provided, it will be total request
135+
timeout. It can also be a pair (tuple) of
136+
(connection, read) timeouts.
137+
:type _request_timeout: int, tuple(int, int), optional
138+
:param _request_auth: set to override the auth_settings for an a single
139+
request; this effectively ignores the
140+
authentication in the spec for a single request.
141+
:type _request_auth: dict, optional
142+
:param _content_type: force content-type for the request.
143+
:type _content_type: str, Optional
144+
:param _headers: set to override the headers for a single
145+
request; this effectively ignores the headers
146+
in the spec for a single request.
147+
:type _headers: dict, optional
148+
:param _host_index: set to override the host_index for a single
149+
request; this effectively ignores the host_index
150+
in the spec for a single request.
151+
:type _host_index: int, optional
152+
:return: Returns the result object.
153+
""" # noqa: E501
154+
155+
_param = self._info_get_version_serialize(
156+
_request_auth=_request_auth,
157+
_content_type=_content_type,
158+
_headers=_headers,
159+
_host_index=_host_index,
160+
)
161+
162+
_response_types_map: Dict[str, Optional[str]] = {
163+
"200": "InfoGetVersion200Response",
164+
}
165+
response_data = await self.api_client.call_api(
166+
*_param, _request_timeout=_request_timeout
167+
)
168+
await response_data.read()
169+
return self.api_client.response_deserialize(
170+
response_data=response_data,
171+
response_types_map=_response_types_map,
172+
)
173+
174+
@validate_call
175+
async def info_get_version_without_preload_content(
176+
self,
177+
_request_timeout: Union[
178+
None,
179+
Annotated[StrictFloat, Field(gt=0)],
180+
Tuple[
181+
Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
182+
],
183+
] = None,
184+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
185+
_content_type: Optional[StrictStr] = None,
186+
_headers: Optional[Dict[StrictStr, Any]] = None,
187+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
188+
) -> RESTResponseType:
189+
"""We return the version for the currently running server
190+
191+
Get the version of the server
192+
193+
:param _request_timeout: timeout setting for this request. If one
194+
number provided, it will be total request
195+
timeout. It can also be a pair (tuple) of
196+
(connection, read) timeouts.
197+
:type _request_timeout: int, tuple(int, int), optional
198+
:param _request_auth: set to override the auth_settings for an a single
199+
request; this effectively ignores the
200+
authentication in the spec for a single request.
201+
:type _request_auth: dict, optional
202+
:param _content_type: force content-type for the request.
203+
:type _content_type: str, Optional
204+
:param _headers: set to override the headers for a single
205+
request; this effectively ignores the headers
206+
in the spec for a single request.
207+
:type _headers: dict, optional
208+
:param _host_index: set to override the host_index for a single
209+
request; this effectively ignores the host_index
210+
in the spec for a single request.
211+
:type _host_index: int, optional
212+
:return: Returns the result object.
213+
""" # noqa: E501
214+
215+
_param = self._info_get_version_serialize(
216+
_request_auth=_request_auth,
217+
_content_type=_content_type,
218+
_headers=_headers,
219+
_host_index=_host_index,
220+
)
221+
222+
_response_types_map: Dict[str, Optional[str]] = {
223+
"200": "InfoGetVersion200Response",
224+
}
225+
response_data = await self.api_client.call_api(
226+
*_param, _request_timeout=_request_timeout
227+
)
228+
return response_data.response
229+
230+
def _info_get_version_serialize(
231+
self,
232+
_request_auth,
233+
_content_type,
234+
_headers,
235+
_host_index,
236+
) -> RequestSerialized:
237+
238+
_host = None
239+
240+
_collection_formats: Dict[str, str] = {}
241+
242+
_path_params: Dict[str, str] = {}
243+
_query_params: List[Tuple[str, str]] = []
244+
_header_params: Dict[str, Optional[str]] = _headers or {}
245+
_form_params: List[Tuple[str, str]] = []
246+
_files: Dict[
247+
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
248+
] = {}
249+
_body_params: Optional[bytes] = None
250+
251+
# process the path parameters
252+
# process the query parameters
253+
# process the header parameters
254+
# process the form parameters
255+
# process the body parameter
256+
257+
# set the HTTP header `Accept`
258+
if "Accept" not in _header_params:
259+
_header_params["Accept"] = self.api_client.select_header_accept(
260+
["application/json"]
261+
)
262+
263+
# authentication setting
264+
_auth_settings: List[str] = []
265+
266+
return self.api_client.param_serialize(
267+
method="GET",
268+
resource_path="/api/v1/version",
269+
path_params=_path_params,
270+
query_params=_query_params,
271+
header_params=_header_params,
272+
body=_body_params,
273+
post_params=_form_params,
274+
files=_files,
275+
auth_settings=_auth_settings,
276+
collection_formats=_collection_formats,
277+
_host=_host,
278+
_request_auth=_request_auth,
279+
)
280+
51281
@validate_call
52282
async def monitoring_post_run_probe(
53283
self,

0 commit comments

Comments
 (0)