Parallel Utilities
The SpectraNorm package was implemented with parallel processing capabilities to efficiently handle large datasets and computationally intensive tasks. The parallel utilities module provides functions for managing parallel execution and tracking the progress of parallel tasks.
spectranorm.utils.parallel
utils/parallel.py
Utility functions for spectranorm's parallel execution (e.g. via Joblib).
ParallelTqdm
Bases: Parallel
joblib.Parallel, but with a tqdm progressbar
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
total_tasks
|
int | None
|
int, default: None the number of expected jobs. Used in the tqdm progressbar. If None, try to infer from the length of the called iterator, and fallback to use the number of remaining items as soon as we finish dispatching. Note: use a list instead of an iterator if you want the total_tasks to be inferred from its length. |
None
|
desc
|
str | None
|
str, default: None the description used in the tqdm progressbar. |
None
|
disable_progressbar
|
bool
|
bool, default: False If True, a tqdm progressbar is not used. |
False
|
show_joblib_header
|
bool
|
bool, default: False If True, show joblib header before the progressbar. |
False
|
Removed parameters
verbose: will be ignored
Usage:
from joblib import delayed
from time import sleep
ParallelTqdm(n_jobs=-1)([delayed(sleep)(.1) for _ in range(10)])
80%|████████ | 8/10 [00:02<00:00, 3.12tasks/s]
Source code in src/spectranorm/utils/parallel.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
print_progress() -> None
Display the process of the parallel execution using tqdm