FlowerPower 0.11.6.7__py3-none-any.whl → 0.11.6.8__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.
flowerpower/utils/misc.py CHANGED
@@ -266,6 +266,8 @@ else:
266
266
 
267
267
  if importlib.util.find_spec("joblib"):
268
268
  from joblib import Parallel, delayed
269
+ from rich.progress import (BarColumn, Progress, TextColumn,
270
+ TimeElapsedColumn)
269
271
 
270
272
  def run_parallel(
271
273
  func: callable,
@@ -299,19 +301,15 @@ if importlib.util.find_spec("joblib"):
299
301
  >>> # Only kwargs iterables
300
302
  >>> run_parallel(func, x=[1,2,3], y=[4,5,6], fixed=42)
301
303
  """
302
- # Special kwargs for run_parallel itself
303
304
  parallel_kwargs = {"n_jobs": n_jobs, "backend": backend, "verbose": 0}
304
305
 
305
- # Process args and kwargs to separate iterables and fixed values
306
306
  iterables = []
307
307
  fixed_args = []
308
308
  iterable_kwargs = {}
309
309
  fixed_kwargs = {}
310
310
 
311
- # Get the length of the first iterable to determine number of iterations
312
311
  first_iterable_len = None
313
312
 
314
- # Process args
315
313
  for arg in args:
316
314
  if isinstance(arg, (list, tuple)) and not isinstance(arg[0], (list, tuple)):
317
315
  iterables.append(arg)
@@ -324,7 +322,6 @@ if importlib.util.find_spec("joblib"):
324
322
  else:
325
323
  fixed_args.append(arg)
326
324
 
327
- # Process kwargs
328
325
  for key, value in kwargs.items():
329
326
  if isinstance(value, (list, tuple)) and not isinstance(
330
327
  value[0], (list, tuple)
@@ -342,26 +339,56 @@ if importlib.util.find_spec("joblib"):
342
339
  if first_iterable_len is None:
343
340
  raise ValueError("At least one iterable argument is required")
344
341
 
345
- # Create parameter combinations
346
342
  all_iterables = iterables + list(iterable_kwargs.values())
347
- param_combinations = list(zip(*all_iterables)) # Convert to list for tqdm
348
-
349
- # if verbose:
350
- # param_combinations = tqdm.tqdm(param_combinations)
351
-
352
- return Parallel(**parallel_kwargs)(
353
- delayed(func)(
354
- *(list(param_tuple[: len(iterables)]) + fixed_args),
355
- **{
356
- k: v
357
- for k, v in zip(
358
- iterable_kwargs.keys(), param_tuple[len(iterables) :]
359
- )
360
- },
361
- **fixed_kwargs,
343
+ param_combinations = list(zip(*all_iterables))
344
+
345
+ if not verbose:
346
+ return Parallel(**parallel_kwargs)(
347
+ delayed(func)(
348
+ *(list(param_tuple[: len(iterables)]) + fixed_args),
349
+ **{
350
+ k: v
351
+ for k, v in zip(
352
+ iterable_kwargs.keys(), param_tuple[len(iterables) :]
353
+ )
354
+ },
355
+ **fixed_kwargs,
356
+ )
357
+ for param_tuple in param_combinations
362
358
  )
363
- for param_tuple in param_combinations
364
- )
359
+ else:
360
+ results = [None] * len(param_combinations)
361
+ with Progress(
362
+ TextColumn("[progress.description]{task.description}"),
363
+ BarColumn(),
364
+ "[progress.percentage]{task.percentage:>3.0f}%",
365
+ TimeElapsedColumn(),
366
+ transient=True,
367
+ ) as progress:
368
+ task = progress.add_task(
369
+ "Running in parallel...", total=len(param_combinations)
370
+ )
371
+
372
+ def wrapper(idx, param_tuple):
373
+ res = func(
374
+ *(list(param_tuple[: len(iterables)]) + fixed_args),
375
+ **{
376
+ k: v
377
+ for k, v in zip(
378
+ iterable_kwargs.keys(), param_tuple[len(iterables) :]
379
+ )
380
+ },
381
+ **fixed_kwargs,
382
+ )
383
+ progress.update(task, advance=1)
384
+ return idx, res
385
+
386
+ for idx, result in Parallel(**parallel_kwargs)(
387
+ delayed(wrapper)(i, param_tuple)
388
+ for i, param_tuple in enumerate(param_combinations)
389
+ ):
390
+ results[idx] = result
391
+ return results
365
392
 
366
393
  else:
367
394
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: FlowerPower
3
- Version: 0.11.6.7
3
+ Version: 0.11.6.8
4
4
  Summary: A simple workflow framework. Hamilton + APScheduler = FlowerPower
5
5
  Author-email: "Volker L." <ligno.blades@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/legout/flowerpower
@@ -89,14 +89,14 @@ flowerpower/settings/logging.py,sha256=xzoiM-87WGduC-RJu8RfyeweHGTM7SnHXHQPbxKwe
89
89
  flowerpower/settings/retry.py,sha256=W3AAVSxmTUAeeSbzRGA37RxqtKKyUdi2MkwDzCsXP94,181
90
90
  flowerpower/utils/callback.py,sha256=sGYSrEbnl0xfRa1X-mA-om3erpH7pmpsWdyPQ9HpU7E,6736
91
91
  flowerpower/utils/logging.py,sha256=QO1Q3pv-m3mK2xT_VbkjTsomFnDeuqBmRuOtoxaowgg,864
92
- flowerpower/utils/misc.py,sha256=7VKlmso0jyJwOZ2VR1mPIiN_3LHpbJ0nJ_gkgVzJGWg,15986
92
+ flowerpower/utils/misc.py,sha256=SK913FEYmOjS7GfSQ8oXNFiQ7owrH70fxp952vN5aWg,17099
93
93
  flowerpower/utils/monkey.py,sha256=VPl3yimoWhwD9kI05BFsjNvtyQiDyLfY4Q85Bb6Ma0w,2903
94
94
  flowerpower/utils/open_telemetry.py,sha256=fQWJWbIQFtKIxMBjAWeF12NGnqT0isO3A3j-DSOv_vE,949
95
95
  flowerpower/utils/scheduler.py,sha256=2zJ_xmLXpvXUQNF1XS2Gqm3Ogo907ctZ50GtvQB_rhE,9354
96
96
  flowerpower/utils/templates.py,sha256=ouyEeSDqa9PjW8c32fGpcINlpC0WToawRFZkMPtwsLE,1591
97
- flowerpower-0.11.6.7.dist-info/licenses/LICENSE,sha256=9AkLexxrmr0aBgSHiqxpJk9wgazpP1CTJyiDyr56J9k,1063
98
- flowerpower-0.11.6.7.dist-info/METADATA,sha256=GVpO7ezPrWQ-YOnadysNNaOKVUOvzJR3GwseHdlALQY,21612
99
- flowerpower-0.11.6.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
- flowerpower-0.11.6.7.dist-info/entry_points.txt,sha256=61X11i5a2IwC9LBiP20XCDl5zMOigGCjMCx17B7bDbQ,52
101
- flowerpower-0.11.6.7.dist-info/top_level.txt,sha256=VraH4WtEUfSxs5L-rXwDQhzQb9eLHTUtgvmFZ2dAYnA,12
102
- flowerpower-0.11.6.7.dist-info/RECORD,,
97
+ flowerpower-0.11.6.8.dist-info/licenses/LICENSE,sha256=9AkLexxrmr0aBgSHiqxpJk9wgazpP1CTJyiDyr56J9k,1063
98
+ flowerpower-0.11.6.8.dist-info/METADATA,sha256=KAhpefN-RefOMHvlJrCkVPumnQXBB_n28BWf3FDFA_Q,21612
99
+ flowerpower-0.11.6.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ flowerpower-0.11.6.8.dist-info/entry_points.txt,sha256=61X11i5a2IwC9LBiP20XCDl5zMOigGCjMCx17B7bDbQ,52
101
+ flowerpower-0.11.6.8.dist-info/top_level.txt,sha256=VraH4WtEUfSxs5L-rXwDQhzQb9eLHTUtgvmFZ2dAYnA,12
102
+ flowerpower-0.11.6.8.dist-info/RECORD,,