sunholo 0.101.2__py3-none-any.whl → 0.101.3__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.
@@ -13,12 +13,18 @@ class AsyncTaskRunner:
13
13
  self.retry_enabled = retry_enabled
14
14
  self.retry_kwargs = retry_kwargs or {}
15
15
 
16
- def add_task(self, func: Callable[..., Any], *args: Any):
16
+ def add_task(self, func: Callable[..., Any], *args: Any, **kwargs: Any):
17
17
  """
18
- Adds a task to the list of tasks to be executed.
18
+ Adds a task to the list of tasks to be executed, supporting both positional and keyword arguments.
19
+
20
+ Args:
21
+ func: The function to be executed.
22
+ *args: Positional arguments for the function.
23
+ **kwargs: Keyword arguments for the function.
19
24
  """
20
- log.info(f"Adding task: {func.__name__} with args: {args}")
21
- self.tasks.append((func.__name__, func, args))
25
+ log.info(f"Adding task: {func.__name__} with args: {args}, kwargs: {kwargs}")
26
+ # Store the function name, function itself, args, and kwargs
27
+ self.tasks.append((func.__name__, func, args, kwargs))
22
28
 
23
29
  async def run_async_as_completed(self) -> AsyncGenerator[Dict[str, Any], None]:
24
30
  """
@@ -34,12 +40,13 @@ class AsyncTaskRunner:
34
40
  task_infos = []
35
41
 
36
42
  # Start all tasks and their corresponding heartbeats
37
- for name, func, args in self.tasks:
43
+ for name, func, args, kwargs in self.tasks:
38
44
  # Create an event to signal task completion to the heartbeat
45
+ log.info(f"Executing task: {name=}, {func=} with args: {args}, kwargs: {kwargs}")
39
46
  completion_event = asyncio.Event()
40
47
 
41
48
  # Start the main task with retries
42
- task_coro = self._run_with_retries(name, func, *args, queue=queue, completion_event=completion_event)
49
+ task_coro = self._run_with_retries(name, func, args, kwargs, queue, completion_event)
43
50
  task = asyncio.create_task(task_coro)
44
51
 
45
52
  # Start the heartbeat coroutine
@@ -98,11 +105,18 @@ class AsyncTaskRunner:
98
105
  await queue.put(None)
99
106
  log.info("Monitor: Sent sentinel to queue")
100
107
 
101
- async def _run_with_retries(self, name: str, func: Callable[..., Any], *args: Any, queue: asyncio.Queue, completion_event: asyncio.Event) -> None:
108
+ async def _run_with_retries(self,
109
+ name: str,
110
+ func: Callable[..., Any],
111
+ args: tuple,
112
+ kwargs: dict,
113
+ queue: asyncio.Queue,
114
+ completion_event: asyncio.Event) -> None:
102
115
  """
103
116
  Executes a task with optional retries and sends completion or error messages to the queue.
104
117
  """
105
118
  try:
119
+ log.info(f"run_with_retries: {name=}, {func=} with args: {args}, kwargs: {kwargs}")
106
120
  if self.retry_enabled:
107
121
  retry_kwargs = {
108
122
  'wait': wait_random_exponential(multiplier=1, max=60),
@@ -113,13 +127,13 @@ class AsyncTaskRunner:
113
127
  async for attempt in AsyncRetrying(**retry_kwargs):
114
128
  with attempt:
115
129
  log.info(f"Starting task '{name}' with retry")
116
- result = await self._execute_task(func, *args)
130
+ result = await self._execute_task(func, *args, **kwargs)
117
131
  await queue.put({'type': 'task_complete', 'func_name': name, 'result': result})
118
132
  log.info(f"Sent 'task_complete' message for task '{name}'")
119
133
  return
120
134
  else:
121
135
  log.info(f"Starting task '{name}' with no retry")
122
- result = await self._execute_task(func, *args)
136
+ result = await self._execute_task(func, *args, **kwargs)
123
137
  await queue.put({'type': 'task_complete', 'func_name': name, 'result': result})
124
138
  log.info(f"Sent 'task_complete' message for task '{name}'")
125
139
  except Exception as e:
@@ -128,24 +142,24 @@ class AsyncTaskRunner:
128
142
  log.info(f"Sent 'task_error' message for task '{name}'")
129
143
  finally:
130
144
  log.info(f"Task '{name}' completed.")
131
- # Set the completion event after sending the message
132
145
  completion_event.set()
133
146
 
134
- async def _execute_task(self, func: Callable[..., Any], *args: Any) -> Any:
147
+ async def _execute_task(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> Any:
135
148
  """
136
149
  Executes the given task function and returns its result.
137
150
 
138
151
  Args:
139
152
  func (Callable): The callable to execute.
140
- *args: Arguments to pass to the callable.
153
+ *args: Positional arguments to pass to the callable.
154
+ **kwargs: Keyword arguments to pass to the callable.
141
155
 
142
156
  Returns:
143
157
  Any: The result of the task.
144
158
  """
145
159
  if asyncio.iscoroutinefunction(func):
146
- return await func(*args)
160
+ return await func(*args, **kwargs)
147
161
  else:
148
- return await asyncio.to_thread(func, *args)
162
+ return await asyncio.to_thread(func, *args, **kwargs)
149
163
 
150
164
  async def _send_heartbeat(self, func_name: str, completion_event: asyncio.Event, queue: asyncio.Queue, interval: int = 2):
151
165
  """
@@ -174,5 +188,4 @@ class AsyncTaskRunner:
174
188
  except asyncio.CancelledError:
175
189
  log.info(f"Heartbeat for task '{func_name}' has been canceled")
176
190
  finally:
177
- log.info(f"Heartbeat for task '{func_name}' stopped")
178
-
191
+ log.info(f"Heartbeat for task '{func_name}' stopped")
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sunholo
3
- Version: 0.101.2
3
+ Version: 0.101.3
4
4
  Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
5
5
  Home-page: https://github.com/sunholo-data/sunholo-py
6
- Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.101.2.tar.gz
6
+ Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.101.3.tar.gz
7
7
  Author: Holosun ApS
8
8
  Author-email: multivac@sunholo.com
9
9
  License: Apache License, Version 2.0
@@ -91,7 +91,7 @@ sunholo/genai/init.py,sha256=yG8E67TduFCTQPELo83OJuWfjwTnGZsyACospahyEaY,687
91
91
  sunholo/genai/process_funcs_cls.py,sha256=krjhwruW-7OUR0gEOPC5Ew9KOoAoTWDMW5HfvpvuPNM,28755
92
92
  sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
93
93
  sunholo/invoke/__init__.py,sha256=o1RhwBGOtVK0MIdD55fAIMCkJsxTksi8GD5uoqVKI-8,184
94
- sunholo/invoke/async_class.py,sha256=Wkrv3exjN3aDQdI1Q4tv8I8xSloKgdz_LzGomayfLhw,7734
94
+ sunholo/invoke/async_class.py,sha256=DViVOHsuir7Zrfa3tVKgvz5wLCfXba15XryWGuMjKYI,8540
95
95
  sunholo/invoke/direct_vac_func.py,sha256=GXSCMkC6vOWGUtQjxy-ZpTrMvJa3CgcW-y9mDpJwWC8,9533
96
96
  sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Qof63M,2053
97
97
  sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -147,9 +147,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
147
147
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
148
148
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
149
149
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
150
- sunholo-0.101.2.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
151
- sunholo-0.101.2.dist-info/METADATA,sha256=Df6VGsfppMzyER5-llKTW2B9jBjY5SuIrivo2kZrcA4,8312
152
- sunholo-0.101.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
153
- sunholo-0.101.2.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
154
- sunholo-0.101.2.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
155
- sunholo-0.101.2.dist-info/RECORD,,
150
+ sunholo-0.101.3.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
151
+ sunholo-0.101.3.dist-info/METADATA,sha256=X_RjEUyzY8ejvVlwkm7Pf1GIkAxybLMR0v2HpKentr4,8312
152
+ sunholo-0.101.3.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
153
+ sunholo-0.101.3.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
154
+ sunholo-0.101.3.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
155
+ sunholo-0.101.3.dist-info/RECORD,,