sunholo 0.145.1__py3-none-any.whl → 0.145.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.
@@ -96,6 +96,13 @@ class AsyncTaskRunner:
96
96
  >>> results = await runner.get_aggregated_results()
97
97
  >>> print(results['results']) # {'fetch_data': 'data from api'}
98
98
 
99
+ # Custom task names for better clarity
100
+ >>> runner = AsyncTaskRunner()
101
+ >>> runner.add_task(fetch_data, "user_api", task_name="fetch_user_data")
102
+ >>> runner.add_task(fetch_data, "posts_api", task_name="fetch_posts")
103
+ >>> results = await runner.get_aggregated_results()
104
+ >>> print(results['results']['fetch_user_data']) # User data
105
+
99
106
  # Silent mode - no console output but still collects results
100
107
  >>> runner = AsyncTaskRunner(verbose=False)
101
108
 
@@ -108,6 +115,7 @@ class AsyncTaskRunner:
108
115
  >>> runner = AsyncTaskRunner(use_default_callbacks=False)
109
116
  """
110
117
  self.tasks = []
118
+ self.task_name_counts = {} # Track task names to ensure uniqueness
111
119
  self.retry_enabled = retry_enabled
112
120
  self.retry_kwargs = retry_kwargs or {}
113
121
  self.timeout = timeout
@@ -209,18 +217,35 @@ class AsyncTaskRunner:
209
217
  func: Callable[..., Any],
210
218
  *args: Any,
211
219
  task_config: Optional[TaskConfig] = None,
220
+ task_name: Optional[str] = None,
212
221
  **kwargs: Any):
213
222
  """
214
223
  Adds a task to the list of tasks to be executed, with optional per-task configuration.
224
+
225
+ Automatically ensures task names are unique by appending a suffix if needed.
215
226
 
216
227
  Args:
217
228
  func: The function to be executed.
218
229
  *args: Positional arguments for the function.
219
230
  task_config: Optional per-task configuration for timeout, retry, and callbacks.
231
+ task_name: Optional custom name for the task. If not provided, uses func.__name__.
220
232
  **kwargs: Keyword arguments for the function.
221
233
  """
222
- log.info(f"Adding task: {func.__name__} with args: {args}, kwargs: {kwargs}, config: {task_config}")
223
- self.tasks.append((func.__name__, func, args, kwargs, task_config))
234
+ # Get base name from task_name or function name
235
+ base_name = task_name if task_name is not None else func.__name__
236
+
237
+ # Ensure uniqueness by adding suffix if needed
238
+ if base_name in self.task_name_counts:
239
+ # Name already exists, increment count and add suffix
240
+ self.task_name_counts[base_name] += 1
241
+ name = f"{base_name}_{self.task_name_counts[base_name]}"
242
+ else:
243
+ # First occurrence of this name
244
+ self.task_name_counts[base_name] = 0
245
+ name = base_name
246
+
247
+ log.info(f"Adding task: {name} with args: {args}, kwargs: {kwargs}, config: {task_config}")
248
+ self.tasks.append((name, func, args, kwargs, task_config))
224
249
 
225
250
  async def run_async_with_callbacks(self) -> AsyncGenerator[CallbackContext, None]:
226
251
  """
@@ -313,10 +338,10 @@ class AsyncTaskRunner:
313
338
 
314
339
  Example:
315
340
  >>> runner = AsyncTaskRunner()
316
- >>> runner.add_task(fetch_data, "api")
317
- >>> runner.add_task(process_data, "raw_data")
341
+ >>> runner.add_task(fetch_data, "api", task_name="api_fetch")
342
+ >>> runner.add_task(process_data, "raw_data", task_name="data_processing")
318
343
  >>> results = await runner.get_aggregated_results()
319
- >>> print(results['results']['fetch_data']) # Access specific result
344
+ >>> print(results['results']['api_fetch']) # Access specific result
320
345
  >>> if results['errors']: # Check for any errors
321
346
  ... print(f"Errors occurred: {results['errors']}")
322
347
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sunholo
3
- Version: 0.145.1
3
+ Version: 0.145.3
4
4
  Summary: AI DevOps - a package to help deploy GenAI to the Cloud.
5
5
  Author-email: Holosun ApS <multivac@sunholo.com>
6
6
  License: Apache License, Version 2.0
@@ -102,7 +102,7 @@ sunholo/genai/process_funcs_cls.py,sha256=D6eNrc3vtTZzwdkacZNOSfit499N_o0C5AHspy
102
102
  sunholo/genai/safety.py,sha256=mkFDO_BeEgiKjQd9o2I4UxB6XI7a9U-oOFjZ8LGRUC4,1238
103
103
  sunholo/invoke/__init__.py,sha256=BNyovdgKPt2Zuq3cw0VmxWGzYCPF5pfgqMn9SlLjGAU,219
104
104
  sunholo/invoke/async_class.py,sha256=ZMzxKQtelbYibu9Fac7P9OU3GorH8KxawZxSMv5EO9A,12514
105
- sunholo/invoke/async_task_runner.py,sha256=8FjZMKAxFkb6qr0EZlSI2Likc2B7BRNUggf9jebfa9c,30407
105
+ sunholo/invoke/async_task_runner.py,sha256=uv2v6HVvM294hVRCNiy2NXsZOkX4wcxgjIBgQA6XpIQ,31738
106
106
  sunholo/invoke/direct_vac_func.py,sha256=dACx3Zh7uZnuWLIFYiyLoyXUhh5-eUpd2RatDUd9ov8,9753
107
107
  sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Qof63M,2053
108
108
  sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -183,9 +183,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
183
183
  sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
184
184
  sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
185
185
  sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
186
- sunholo-0.145.1.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
187
- sunholo-0.145.1.dist-info/METADATA,sha256=KiLh38dP1mlkut1F1fxus_1FA1r5vxfTCACZIHPEfks,18639
188
- sunholo-0.145.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
189
- sunholo-0.145.1.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
190
- sunholo-0.145.1.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
191
- sunholo-0.145.1.dist-info/RECORD,,
186
+ sunholo-0.145.3.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
187
+ sunholo-0.145.3.dist-info/METADATA,sha256=X1gQCYnMVaouSX9h30QgR9WV6tmyVad93pscdRn49xQ,18639
188
+ sunholo-0.145.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
189
+ sunholo-0.145.3.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
190
+ sunholo-0.145.3.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
191
+ sunholo-0.145.3.dist-info/RECORD,,