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

@@ -9,6 +9,7 @@ from pydantic import StrictInt
9
9
  from hatchet_sdk.clients.rest.api.event_api import EventApi
10
10
  from hatchet_sdk.clients.rest.api.log_api import LogApi
11
11
  from hatchet_sdk.clients.rest.api.step_run_api import StepRunApi
12
+ from hatchet_sdk.clients.rest.api.worker_api import WorkerApi
12
13
  from hatchet_sdk.clients.rest.api.workflow_api import WorkflowApi
13
14
  from hatchet_sdk.clients.rest.api.workflow_run_api import WorkflowRunApi
14
15
  from hatchet_sdk.clients.rest.api.workflow_runs_api import WorkflowRunsApi
@@ -83,6 +84,7 @@ class AsyncRestApi:
83
84
  self._step_run_api = None
84
85
  self._event_api = None
85
86
  self._log_api = None
87
+ self._worker_api: WorkerApi | None = None
86
88
 
87
89
  @property
88
90
  def api_client(self):
@@ -102,6 +104,13 @@ class AsyncRestApi:
102
104
  self._workflow_run_api = WorkflowRunApi(self.api_client)
103
105
  return self._workflow_run_api
104
106
 
107
+ @property
108
+ def worker_api(self):
109
+ if self._worker_api is None:
110
+ self._worker_api = WorkerApi(self.api_client)
111
+
112
+ return self._worker_api
113
+
105
114
  @property
106
115
  def step_run_api(self):
107
116
  if self._step_run_api is None:
@@ -8,12 +8,14 @@ from typing import Any, List, Mapping, Optional
8
8
 
9
9
  import grpc
10
10
 
11
+ from hatchet_sdk.client import Client, new_client_raw
11
12
  from hatchet_sdk.clients.dispatcher.action_listener import Action
12
13
  from hatchet_sdk.clients.dispatcher.dispatcher import (
13
14
  ActionListener,
14
15
  GetActionListenerRequest,
15
16
  new_dispatcher,
16
17
  )
18
+ from hatchet_sdk.clients.rest.models.update_worker_request import UpdateWorkerRequest
17
19
  from hatchet_sdk.contracts.dispatcher_pb2 import (
18
20
  GROUP_KEY_EVENT_TYPE_STARTED,
19
21
  STEP_EVENT_TYPE_STARTED,
@@ -41,10 +43,6 @@ BLOCKED_THREAD_WARNING = (
41
43
  )
42
44
 
43
45
 
44
- def noop_handler():
45
- pass
46
-
47
-
48
46
  @dataclass
49
47
  class WorkerActionListenerProcess:
50
48
  name: str
@@ -70,9 +68,15 @@ class WorkerActionListenerProcess:
70
68
  if self.debug:
71
69
  logger.setLevel(logging.DEBUG)
72
70
 
71
+ self.client = new_client_raw(self.config, self.debug)
72
+
73
73
  loop = asyncio.get_event_loop()
74
- loop.add_signal_handler(signal.SIGINT, noop_handler)
75
- loop.add_signal_handler(signal.SIGTERM, noop_handler)
74
+ loop.add_signal_handler(
75
+ signal.SIGINT, lambda: asyncio.create_task(self.pause_task_assignment())
76
+ )
77
+ loop.add_signal_handler(
78
+ signal.SIGTERM, lambda: asyncio.create_task(self.pause_task_assignment())
79
+ )
76
80
  loop.add_signal_handler(
77
81
  signal.SIGQUIT, lambda: asyncio.create_task(self.exit_gracefully())
78
82
  )
@@ -249,7 +253,15 @@ class WorkerActionListenerProcess:
249
253
 
250
254
  self.event_queue.put(STOP_LOOP)
251
255
 
256
+ async def pause_task_assignment(self) -> None:
257
+ await self.client.rest.aio.worker_api.worker_update(
258
+ worker=self.listener.worker_id,
259
+ update_worker_request=UpdateWorkerRequest(isPaused=True),
260
+ )
261
+
252
262
  async def exit_gracefully(self, skip_unregister=False):
263
+ await self.pause_task_assignment()
264
+
253
265
  if self.killing:
254
266
  return
255
267
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hatchet-sdk
3
- Version: 0.47.0
3
+ Version: 0.47.1
4
4
  Summary:
5
5
  Author: Alexander Belanger
6
6
  Author-email: alexander@hatchet.run
@@ -186,7 +186,7 @@ hatchet_sdk/clients/rest/models/workflow_version_meta.py,sha256=TW4R7bAuYAg_LraN
186
186
  hatchet_sdk/clients/rest/models/workflow_workers_count.py,sha256=qhzqfvjjIDyARkiiLGluMIqEmqO-diHTsjlu0Doi0yg,2875
187
187
  hatchet_sdk/clients/rest/rest.py,sha256=G83F1k4g_ePzvXW95rApzvaRDQPcaxrj-JmZyq1LvGw,6606
188
188
  hatchet_sdk/clients/rest/tenacity_utils.py,sha256=gy500kHXQ-4ZrZH1biHGmavhfh0NarCJcaIfW-A9Qd0,1051
189
- hatchet_sdk/clients/rest_client.py,sha256=jEu9KNTaGgy64bqIIMV6r2st3EqAsyr5Vz77NipJtjU,21867
189
+ hatchet_sdk/clients/rest_client.py,sha256=Jp4qRRsQdXzrWm3Fca6X2k6nMvECTQ87ux2jGyMgqfQ,22148
190
190
  hatchet_sdk/clients/run_event_listener.py,sha256=51WTg52_aISgYPOFPHJ21rb4IO6aEd7Ugp7FCf4HnfM,10184
191
191
  hatchet_sdk/clients/workflow_listener.py,sha256=HG7qwPaeUmsChYMhvj95IBZ6cuBDt3BDvsSi1h5PXcg,9596
192
192
  hatchet_sdk/connection.py,sha256=593aUGAj7Ouf00lcVwx_pmhdQ9NOC5ANT1Jrf8nwkHs,2165
@@ -223,7 +223,7 @@ hatchet_sdk/v2/callable.py,sha256=DqBc3VS7WAk5qU9Ef1HnyAzdgxUq1hDzj-CwQYQrvcA,69
223
223
  hatchet_sdk/v2/concurrency.py,sha256=mRsbCj3G2kwkAJjHOg67y226mYdXVmd0uka3ypdRKUQ,1434
224
224
  hatchet_sdk/v2/hatchet.py,sha256=mQZoloWuRCIEwDwXeTaJL2kBjgs9YLHy7UPWxBD5070,7282
225
225
  hatchet_sdk/worker/__init__.py,sha256=1Ze1seDuXx5yD1IfHmqGFgK5qrRazVW4ZcDVGl-Pddw,61
226
- hatchet_sdk/worker/action_listener_process.py,sha256=tmlzDgyHWxGl8fJWE9NKqjvhqpGi9SMmOh5dFyiVL-Q,9979
226
+ hatchet_sdk/worker/action_listener_process.py,sha256=QFGxxsSGdAp4PzcENcGRHNmhDHgfuP3omt9-kyolEyk,10566
227
227
  hatchet_sdk/worker/runner/run_loop_manager.py,sha256=nV7fhNxJKCcrBm0ci118aszF_7AxenBkOTIe1UsBEt4,3490
228
228
  hatchet_sdk/worker/runner/runner.py,sha256=2aT5rumcisfzliI9ghKelA7LuZir-4tLzYk_N8a6S9c,16723
229
229
  hatchet_sdk/worker/runner/utils/capture_logs.py,sha256=s_BGxeykelVbusx6u31EPx3vv9c2BHkuBnYcaLW680E,2381
@@ -231,7 +231,7 @@ hatchet_sdk/worker/runner/utils/error_with_traceback.py,sha256=Iih_s8JNqrinXETFJ
231
231
  hatchet_sdk/worker/worker.py,sha256=7UPm3qTzNYSSm9QTNX6zBBMJqVA6nKFeCbAdqLLjUBs,13007
232
232
  hatchet_sdk/workflow.py,sha256=XRj5jcCQSvPQMXxBipf-ZlARua2E8Z9igRzGcQ5alkI,9375
233
233
  hatchet_sdk/workflow_run.py,sha256=-RUhI48NOr1Z8ha9entmVu3yVlHBbr0LWZKVHUfPVzY,1743
234
- hatchet_sdk-0.47.0.dist-info/METADATA,sha256=9xwNmXBdLQocIrJYm505zY4kMuQ2Y1bM1hAIgxEbqKY,1826
235
- hatchet_sdk-0.47.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
236
- hatchet_sdk-0.47.0.dist-info/entry_points.txt,sha256=lyWn37JwpYymrqp6Awq-Var43vhDG6rfauPS6KQa8JY,1124
237
- hatchet_sdk-0.47.0.dist-info/RECORD,,
234
+ hatchet_sdk-0.47.1.dist-info/METADATA,sha256=47a2WMiEGAa1OL7_iL0s2PiOwP2uxMahlkZ0KRLfBv0,1826
235
+ hatchet_sdk-0.47.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
236
+ hatchet_sdk-0.47.1.dist-info/entry_points.txt,sha256=lyWn37JwpYymrqp6Awq-Var43vhDG6rfauPS6KQa8JY,1124
237
+ hatchet_sdk-0.47.1.dist-info/RECORD,,