stouputils 1.13.1__py3-none-any.whl → 1.13.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.
- stouputils/continuous_delivery/pypi.py +5 -4
- stouputils/decorators.py +20 -10
- stouputils/parallel.py +34 -4
- stouputils/print.py +16 -3
- stouputils/stouputils/decorators.pyi +10 -0
- stouputils/stouputils/parallel.pyi +8 -3
- stouputils/stouputils/print.pyi +2 -2
- {stouputils-1.13.1.dist-info → stouputils-1.13.3.dist-info}/METADATA +1 -1
- {stouputils-1.13.1.dist-info → stouputils-1.13.3.dist-info}/RECORD +11 -11
- {stouputils-1.13.1.dist-info → stouputils-1.13.3.dist-info}/WHEEL +1 -1
- {stouputils-1.13.1.dist-info → stouputils-1.13.3.dist-info}/entry_points.txt +0 -0
|
@@ -108,14 +108,15 @@ def pypi_full_routine_using_uv() -> None:
|
|
|
108
108
|
package_dir = "src/" + package_name
|
|
109
109
|
|
|
110
110
|
# Generate stubs unless '--no-stubs' is passed
|
|
111
|
-
if "--no-stubs" not in sys.argv:
|
|
111
|
+
if "--no-stubs" not in sys.argv and "--no_stubs" not in sys.argv:
|
|
112
112
|
from .stubs import stubs_full_routine
|
|
113
113
|
stubs_full_routine(package_name, output_directory=package_dir, clean_before=True)
|
|
114
114
|
|
|
115
115
|
# Increment version in pyproject.toml
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
if "--no-bump" not in sys.argv and "--no_bump" not in sys.argv:
|
|
117
|
+
increment: str = "patch" if sys.argv[-1] not in ("minor", "major") else sys.argv[-1]
|
|
118
|
+
if os.system(f"uv version --bump {increment} --frozen") != 0:
|
|
119
|
+
raise Exception("Error while incrementing version using 'uv version'")
|
|
119
120
|
|
|
120
121
|
# Build the package using 'uv build'
|
|
121
122
|
import shutil
|
stouputils/decorators.py
CHANGED
|
@@ -64,7 +64,7 @@ def measure_time(
|
|
|
64
64
|
"""
|
|
65
65
|
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
66
66
|
# Set the message if not specified, else use the provided one
|
|
67
|
-
new_msg: str = message if message else f"Execution time of {_get_func_name(func)}"
|
|
67
|
+
new_msg: str = message if message else f"Execution time of {_get_func_name(func)}()"
|
|
68
68
|
|
|
69
69
|
if is_generator:
|
|
70
70
|
@wraps(func)
|
|
@@ -149,11 +149,11 @@ def handle_error(
|
|
|
149
149
|
return func(*args, **kwargs)
|
|
150
150
|
except exceptions as e:
|
|
151
151
|
if error_log == LogLevels.WARNING:
|
|
152
|
-
warning(f"{msg}Error during {_get_func_name(func)}: ({type(e).__name__}) {e}")
|
|
152
|
+
warning(f"{msg}Error during {_get_func_name(func)}(): ({type(e).__name__}) {e}")
|
|
153
153
|
elif error_log == LogLevels.WARNING_TRACEBACK:
|
|
154
|
-
warning(f"{msg}Error during {_get_func_name(func)}:\n{format_exc()}")
|
|
154
|
+
warning(f"{msg}Error during {_get_func_name(func)}():\n{format_exc()}")
|
|
155
155
|
elif error_log == LogLevels.ERROR_TRACEBACK:
|
|
156
|
-
error(f"{msg}Error during {_get_func_name(func)}:\n{format_exc()}", exit=True)
|
|
156
|
+
error(f"{msg}Error during {_get_func_name(func)}():\n{format_exc()}", exit=True)
|
|
157
157
|
elif error_log == LogLevels.RAISE_EXCEPTION:
|
|
158
158
|
raise e
|
|
159
159
|
|
|
@@ -212,7 +212,7 @@ def timeout(
|
|
|
212
212
|
@wraps(func)
|
|
213
213
|
def wrapper(*args: tuple[Any, ...], **kwargs: dict[str, Any]) -> Any:
|
|
214
214
|
# Build timeout message
|
|
215
|
-
msg: str = message if message else f"Function '{_get_func_name(func)}' timed out after {seconds} seconds"
|
|
215
|
+
msg: str = message if message else f"Function '{_get_func_name(func)}()' timed out after {seconds} seconds"
|
|
216
216
|
|
|
217
217
|
# Try to use signal-based timeout (Unix only, main thread only)
|
|
218
218
|
try:
|
|
@@ -332,7 +332,7 @@ def retry(
|
|
|
332
332
|
if message:
|
|
333
333
|
warning(f"{message}, retrying ({attempt + 1}/{max_attempts}): {e}")
|
|
334
334
|
else:
|
|
335
|
-
warning(f"{type(e).__name__} encountered while running {_get_func_name(func)}, retrying ({attempt + 1}/{max_attempts}): {e}")
|
|
335
|
+
warning(f"{type(e).__name__} encountered while running {_get_func_name(func)}(), retrying ({attempt + 1}/{max_attempts}): {e}")
|
|
336
336
|
|
|
337
337
|
# Wait before next attempt
|
|
338
338
|
time.sleep(current_delay)
|
|
@@ -375,10 +375,20 @@ def simple_cache(
|
|
|
375
375
|
3
|
|
376
376
|
>>> test2(3, 4)
|
|
377
377
|
7
|
|
378
|
+
|
|
379
|
+
>>> @simple_cache
|
|
380
|
+
... def factorial(n: int) -> int:
|
|
381
|
+
... return n * factorial(n - 1) if n else 1
|
|
382
|
+
>>> factorial(10) # no previously cached result, makes 11 recursive calls
|
|
383
|
+
3628800
|
|
384
|
+
>>> factorial(5) # no new calls, just returns the cached result
|
|
385
|
+
120
|
|
386
|
+
>>> factorial(12) # two new recursive calls, factorial(10) is cached
|
|
387
|
+
479001600
|
|
378
388
|
"""
|
|
379
389
|
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
380
390
|
# Create the cache dict
|
|
381
|
-
cache_dict: dict[
|
|
391
|
+
cache_dict: dict[Any, Any] = {}
|
|
382
392
|
|
|
383
393
|
# Create the wrapper
|
|
384
394
|
@wraps(func)
|
|
@@ -386,9 +396,9 @@ def simple_cache(
|
|
|
386
396
|
|
|
387
397
|
# Get the hashed key
|
|
388
398
|
if method == "str":
|
|
389
|
-
hashed
|
|
399
|
+
hashed = str(args) + str(kwargs)
|
|
390
400
|
elif method == "pickle":
|
|
391
|
-
hashed
|
|
401
|
+
hashed = pickle_dumps((args, kwargs))
|
|
392
402
|
else:
|
|
393
403
|
raise ValueError("Invalid caching method. Supported methods are 'str' and 'pickle'.")
|
|
394
404
|
|
|
@@ -447,7 +457,7 @@ def abstract(
|
|
|
447
457
|
NotImplementedError: Function 'method' is abstract and must be implemented by a subclass
|
|
448
458
|
"""
|
|
449
459
|
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
450
|
-
message: str = f"Function '{_get_func_name(func)}' is abstract and must be implemented by a subclass"
|
|
460
|
+
message: str = f"Function '{_get_func_name(func)}()' is abstract and must be implemented by a subclass"
|
|
451
461
|
if not func.__doc__:
|
|
452
462
|
func.__doc__ = message
|
|
453
463
|
|
stouputils/parallel.py
CHANGED
|
@@ -45,6 +45,8 @@ def multiprocessing[T, R](
|
|
|
45
45
|
color: str = MAGENTA,
|
|
46
46
|
bar_format: str = BAR_FORMAT,
|
|
47
47
|
ascii: bool = False,
|
|
48
|
+
smooth_tqdm: bool = True,
|
|
49
|
+
**tqdm_kwargs: Any
|
|
48
50
|
) -> list[R]:
|
|
49
51
|
r""" Method to execute a function in parallel using multiprocessing
|
|
50
52
|
|
|
@@ -70,6 +72,8 @@ def multiprocessing[T, R](
|
|
|
70
72
|
color (str): Color of the progress bar (Defaults to MAGENTA)
|
|
71
73
|
bar_format (str): Format of the progress bar (Defaults to BAR_FORMAT)
|
|
72
74
|
ascii (bool): Whether to use ASCII or Unicode characters for the progress bar
|
|
75
|
+
smooth_tqdm (bool): Whether to enable smooth progress bar updates by setting miniters and mininterval (Defaults to True)
|
|
76
|
+
**tqdm_kwargs (Any): Additional keyword arguments to pass to tqdm
|
|
73
77
|
|
|
74
78
|
Returns:
|
|
75
79
|
list[object]: Results of the function execution
|
|
@@ -123,13 +127,22 @@ def multiprocessing[T, R](
|
|
|
123
127
|
desc, func, args = _handle_parameters(func, args, use_starmap, delay_first_calls, max_workers, desc, color)
|
|
124
128
|
if bar_format == BAR_FORMAT:
|
|
125
129
|
bar_format = bar_format.replace(MAGENTA, color)
|
|
130
|
+
if smooth_tqdm:
|
|
131
|
+
tqdm_kwargs.setdefault("mininterval", 0.0)
|
|
132
|
+
try:
|
|
133
|
+
total = len(args) # type: ignore
|
|
134
|
+
import shutil
|
|
135
|
+
width = shutil.get_terminal_size().columns
|
|
136
|
+
tqdm_kwargs.setdefault("miniters", max(1, total // width))
|
|
137
|
+
except (TypeError, OSError):
|
|
138
|
+
tqdm_kwargs.setdefault("miniters", 1)
|
|
126
139
|
|
|
127
140
|
# Do multiprocessing only if there is more than 1 argument and more than 1 CPU
|
|
128
141
|
if max_workers > 1 and len(args) > 1:
|
|
129
142
|
def process() -> list[Any]:
|
|
130
143
|
if verbose:
|
|
131
144
|
return list(process_map(
|
|
132
|
-
func, args, max_workers=max_workers, chunksize=chunksize, desc=desc, bar_format=bar_format, ascii=ascii
|
|
145
|
+
func, args, max_workers=max_workers, chunksize=chunksize, desc=desc, bar_format=bar_format, ascii=ascii, **tqdm_kwargs
|
|
133
146
|
)) # type: ignore
|
|
134
147
|
else:
|
|
135
148
|
with Pool(max_workers) as pool:
|
|
@@ -148,7 +161,7 @@ def multiprocessing[T, R](
|
|
|
148
161
|
# Single process execution
|
|
149
162
|
else:
|
|
150
163
|
if verbose:
|
|
151
|
-
return [func(arg) for arg in tqdm(args, total=len(args), desc=desc, bar_format=bar_format, ascii=ascii)]
|
|
164
|
+
return [func(arg) for arg in tqdm(args, total=len(args), desc=desc, bar_format=bar_format, ascii=ascii, **tqdm_kwargs)]
|
|
152
165
|
else:
|
|
153
166
|
return [func(arg) for arg in args]
|
|
154
167
|
|
|
@@ -163,6 +176,8 @@ def multithreading[T, R](
|
|
|
163
176
|
color: str = MAGENTA,
|
|
164
177
|
bar_format: str = BAR_FORMAT,
|
|
165
178
|
ascii: bool = False,
|
|
179
|
+
smooth_tqdm: bool = True,
|
|
180
|
+
**tqdm_kwargs: Any
|
|
166
181
|
) -> list[R]:
|
|
167
182
|
r""" Method to execute a function in parallel using multithreading, you should use it:
|
|
168
183
|
|
|
@@ -186,6 +201,8 @@ def multithreading[T, R](
|
|
|
186
201
|
color (str): Color of the progress bar (Defaults to MAGENTA)
|
|
187
202
|
bar_format (str): Format of the progress bar (Defaults to BAR_FORMAT)
|
|
188
203
|
ascii (bool): Whether to use ASCII or Unicode characters for the progress bar
|
|
204
|
+
smooth_tqdm (bool): Whether to enable smooth progress bar updates by setting miniters and mininterval (Defaults to True)
|
|
205
|
+
**tqdm_kwargs (Any): Additional keyword arguments to pass to tqdm
|
|
189
206
|
|
|
190
207
|
Returns:
|
|
191
208
|
list[object]: Results of the function execution
|
|
@@ -237,12 +254,21 @@ def multithreading[T, R](
|
|
|
237
254
|
desc, func, args = _handle_parameters(func, args, use_starmap, delay_first_calls, max_workers, desc, color)
|
|
238
255
|
if bar_format == BAR_FORMAT:
|
|
239
256
|
bar_format = bar_format.replace(MAGENTA, color)
|
|
257
|
+
if smooth_tqdm:
|
|
258
|
+
tqdm_kwargs.setdefault("mininterval", 0.0)
|
|
259
|
+
try:
|
|
260
|
+
total = len(args) # type: ignore
|
|
261
|
+
import shutil
|
|
262
|
+
width = shutil.get_terminal_size().columns
|
|
263
|
+
tqdm_kwargs.setdefault("miniters", max(1, total // width))
|
|
264
|
+
except (TypeError, OSError):
|
|
265
|
+
tqdm_kwargs.setdefault("miniters", 1)
|
|
240
266
|
|
|
241
267
|
# Do multithreading only if there is more than 1 argument and more than 1 CPU
|
|
242
268
|
if max_workers > 1 and len(args) > 1:
|
|
243
269
|
if verbose:
|
|
244
270
|
with ThreadPoolExecutor(max_workers) as executor:
|
|
245
|
-
return list(tqdm(executor.map(func, args), total=len(args), desc=desc, bar_format=bar_format, ascii=ascii))
|
|
271
|
+
return list(tqdm(executor.map(func, args), total=len(args), desc=desc, bar_format=bar_format, ascii=ascii, **tqdm_kwargs))
|
|
246
272
|
else:
|
|
247
273
|
with ThreadPoolExecutor(max_workers) as executor:
|
|
248
274
|
return list(executor.map(func, args))
|
|
@@ -250,7 +276,7 @@ def multithreading[T, R](
|
|
|
250
276
|
# Single process execution
|
|
251
277
|
else:
|
|
252
278
|
if verbose:
|
|
253
|
-
return [func(arg) for arg in tqdm(args, total=len(args), desc=desc, bar_format=bar_format, ascii=ascii)]
|
|
279
|
+
return [func(arg) for arg in tqdm(args, total=len(args), desc=desc, bar_format=bar_format, ascii=ascii, **tqdm_kwargs)]
|
|
254
280
|
else:
|
|
255
281
|
return [func(arg) for arg in args]
|
|
256
282
|
|
|
@@ -259,6 +285,7 @@ def run_in_subprocess[R](
|
|
|
259
285
|
func: Callable[..., R],
|
|
260
286
|
*args: Any,
|
|
261
287
|
timeout: float | None = None,
|
|
288
|
+
no_join: bool = False,
|
|
262
289
|
**kwargs: Any
|
|
263
290
|
) -> R:
|
|
264
291
|
""" Execute a function in a subprocess with positional and keyword arguments.
|
|
@@ -273,6 +300,7 @@ def run_in_subprocess[R](
|
|
|
273
300
|
*args (Any): Positional arguments to pass to the function.
|
|
274
301
|
timeout (float | None): Maximum time in seconds to wait for the subprocess.
|
|
275
302
|
If None, wait indefinitely. If the subprocess exceeds this time, it will be terminated.
|
|
303
|
+
no_join (bool): If True, do not wait for the subprocess to finish (fire-and-forget).
|
|
276
304
|
**kwargs (Any): Keyword arguments to pass to the function.
|
|
277
305
|
|
|
278
306
|
Returns:
|
|
@@ -318,6 +346,8 @@ def run_in_subprocess[R](
|
|
|
318
346
|
process.start()
|
|
319
347
|
|
|
320
348
|
# Join with timeout to prevent indefinite hanging
|
|
349
|
+
if no_join:
|
|
350
|
+
return None # type: ignore
|
|
321
351
|
process.join(timeout=timeout)
|
|
322
352
|
|
|
323
353
|
# Check if process is still alive (timed out)
|
stouputils/print.py
CHANGED
|
@@ -45,6 +45,7 @@ def colored_for_loop[T](
|
|
|
45
45
|
color: str = MAGENTA,
|
|
46
46
|
bar_format: str = BAR_FORMAT,
|
|
47
47
|
ascii: bool = False,
|
|
48
|
+
smooth_tqdm: bool = True,
|
|
48
49
|
**kwargs: Any
|
|
49
50
|
) -> Iterator[T]:
|
|
50
51
|
""" Function to iterate over a list with a colored TQDM progress bar like the other functions in this module.
|
|
@@ -55,7 +56,7 @@ def colored_for_loop[T](
|
|
|
55
56
|
color (str): Color of the progress bar (Defaults to MAGENTA)
|
|
56
57
|
bar_format (str): Format of the progress bar (Defaults to BAR_FORMAT)
|
|
57
58
|
ascii (bool): Whether to use ASCII or Unicode characters for the progress bar (Defaults to False)
|
|
58
|
-
|
|
59
|
+
smooth_tqdm (bool): Whether to enable smooth progress bar updates by setting miniters=1 and mininterval=0.0 (Defaults to True)
|
|
59
60
|
**kwargs: Additional arguments to pass to the TQDM progress bar
|
|
60
61
|
|
|
61
62
|
Yields:
|
|
@@ -70,6 +71,16 @@ def colored_for_loop[T](
|
|
|
70
71
|
bar_format = bar_format.replace(MAGENTA, color)
|
|
71
72
|
desc = color + desc
|
|
72
73
|
|
|
74
|
+
if smooth_tqdm:
|
|
75
|
+
kwargs.setdefault("mininterval", 0.0)
|
|
76
|
+
try:
|
|
77
|
+
total = len(iterable) # type: ignore
|
|
78
|
+
import shutil
|
|
79
|
+
width = shutil.get_terminal_size().columns
|
|
80
|
+
kwargs.setdefault("miniters", max(1, total // width))
|
|
81
|
+
except (TypeError, OSError):
|
|
82
|
+
kwargs.setdefault("miniters", 1)
|
|
83
|
+
|
|
73
84
|
from tqdm.auto import tqdm
|
|
74
85
|
yield from tqdm(iterable, desc=desc, bar_format=bar_format, ascii=ascii, **kwargs)
|
|
75
86
|
|
|
@@ -224,8 +235,10 @@ def whatisit(
|
|
|
224
235
|
try:
|
|
225
236
|
if not isinstance(value, str | bytes | bytearray | dict | int | float):
|
|
226
237
|
import numpy as np
|
|
227
|
-
|
|
228
|
-
|
|
238
|
+
mini, maxi = np.min(value), np.max(value)
|
|
239
|
+
if mini != maxi:
|
|
240
|
+
metadata_parts.append(f"min: {mini}")
|
|
241
|
+
metadata_parts.append(f"max: {maxi}")
|
|
229
242
|
except (Exception):
|
|
230
243
|
pass
|
|
231
244
|
|
|
@@ -151,6 +151,16 @@ def simple_cache(func: Callable[..., Any] | None = None, *, method: Literal['str
|
|
|
151
151
|
\t\t3
|
|
152
152
|
\t\t>>> test2(3, 4)
|
|
153
153
|
\t\t7
|
|
154
|
+
|
|
155
|
+
\t\t>>> @simple_cache
|
|
156
|
+
\t\t... def factorial(n: int) -> int:
|
|
157
|
+
\t\t... return n * factorial(n - 1) if n else 1
|
|
158
|
+
\t\t>>> factorial(10) # no previously cached result, makes 11 recursive calls
|
|
159
|
+
\t\t3628800
|
|
160
|
+
\t\t>>> factorial(5) # no new calls, just returns the cached result
|
|
161
|
+
\t\t120
|
|
162
|
+
\t\t>>> factorial(12) # two new recursive calls, factorial(10) is cached
|
|
163
|
+
\t\t479001600
|
|
154
164
|
\t'''
|
|
155
165
|
def abstract(func: Callable[..., Any] | None = None, *, error_log: LogLevels = ...) -> Callable[..., Any]:
|
|
156
166
|
""" Decorator that marks a function as abstract.
|
|
@@ -10,7 +10,7 @@ CPU_COUNT: int
|
|
|
10
10
|
T = TypeVar('T')
|
|
11
11
|
R = TypeVar('R')
|
|
12
12
|
|
|
13
|
-
def multiprocessing[T, R](func: Callable[..., R] | list[Callable[..., R]], args: Iterable[T], use_starmap: bool = False, chunksize: int = 1, desc: str = '', max_workers: int | float = ..., delay_first_calls: float = 0, color: str = ..., bar_format: str = ..., ascii: bool = False) -> list[R]:
|
|
13
|
+
def multiprocessing[T, R](func: Callable[..., R] | list[Callable[..., R]], args: Iterable[T], use_starmap: bool = False, chunksize: int = 1, desc: str = '', max_workers: int | float = ..., delay_first_calls: float = 0, color: str = ..., bar_format: str = ..., ascii: bool = False, smooth_tqdm: bool = True, **tqdm_kwargs: Any) -> list[R]:
|
|
14
14
|
''' Method to execute a function in parallel using multiprocessing
|
|
15
15
|
|
|
16
16
|
\t- For CPU-bound operations where the GIL (Global Interpreter Lock) is a bottleneck.
|
|
@@ -35,6 +35,8 @@ def multiprocessing[T, R](func: Callable[..., R] | list[Callable[..., R]], args:
|
|
|
35
35
|
\t\tcolor\t\t\t\t(str):\t\t\t\tColor of the progress bar (Defaults to MAGENTA)
|
|
36
36
|
\t\tbar_format\t\t\t(str):\t\t\t\tFormat of the progress bar (Defaults to BAR_FORMAT)
|
|
37
37
|
\t\tascii\t\t\t\t(bool):\t\t\t\tWhether to use ASCII or Unicode characters for the progress bar
|
|
38
|
+
\t\tsmooth_tqdm\t\t\t(bool):\t\t\t\tWhether to enable smooth progress bar updates by setting miniters and mininterval (Defaults to True)
|
|
39
|
+
\t\t**tqdm_kwargs\t\t(Any):\t\t\t\tAdditional keyword arguments to pass to tqdm
|
|
38
40
|
|
|
39
41
|
\tReturns:
|
|
40
42
|
\t\tlist[object]:\tResults of the function execution
|
|
@@ -66,7 +68,7 @@ def multiprocessing[T, R](func: Callable[..., R] | list[Callable[..., R]], args:
|
|
|
66
68
|
\t\t\t. )
|
|
67
69
|
\t\t\t[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
68
70
|
\t'''
|
|
69
|
-
def multithreading[T, R](func: Callable[..., R] | list[Callable[..., R]], args: Iterable[T], use_starmap: bool = False, desc: str = '', max_workers: int | float = ..., delay_first_calls: float = 0, color: str = ..., bar_format: str = ..., ascii: bool = False) -> list[R]:
|
|
71
|
+
def multithreading[T, R](func: Callable[..., R] | list[Callable[..., R]], args: Iterable[T], use_starmap: bool = False, desc: str = '', max_workers: int | float = ..., delay_first_calls: float = 0, color: str = ..., bar_format: str = ..., ascii: bool = False, smooth_tqdm: bool = True, **tqdm_kwargs: Any) -> list[R]:
|
|
70
72
|
''' Method to execute a function in parallel using multithreading, you should use it:
|
|
71
73
|
|
|
72
74
|
\t- For I/O-bound operations where the GIL is not a bottleneck, such as network requests or disk operations.
|
|
@@ -89,6 +91,8 @@ def multithreading[T, R](func: Callable[..., R] | list[Callable[..., R]], args:
|
|
|
89
91
|
\t\tcolor\t\t\t\t(str):\t\t\t\tColor of the progress bar (Defaults to MAGENTA)
|
|
90
92
|
\t\tbar_format\t\t\t(str):\t\t\t\tFormat of the progress bar (Defaults to BAR_FORMAT)
|
|
91
93
|
\t\tascii\t\t\t\t(bool):\t\t\t\tWhether to use ASCII or Unicode characters for the progress bar
|
|
94
|
+
\t\tsmooth_tqdm\t\t\t(bool):\t\t\t\tWhether to enable smooth progress bar updates by setting miniters and mininterval (Defaults to True)
|
|
95
|
+
\t\t**tqdm_kwargs\t\t(Any):\t\t\t\tAdditional keyword arguments to pass to tqdm
|
|
92
96
|
|
|
93
97
|
\tReturns:
|
|
94
98
|
\t\tlist[object]:\tResults of the function execution
|
|
@@ -120,7 +124,7 @@ def multithreading[T, R](func: Callable[..., R] | list[Callable[..., R]], args:
|
|
|
120
124
|
\t\t\t. )
|
|
121
125
|
\t\t\t[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
122
126
|
\t'''
|
|
123
|
-
def run_in_subprocess[R](func: Callable[..., R], *args: Any, timeout: float | None = None, **kwargs: Any) -> R:
|
|
127
|
+
def run_in_subprocess[R](func: Callable[..., R], *args: Any, timeout: float | None = None, no_join: bool = False, **kwargs: Any) -> R:
|
|
124
128
|
''' Execute a function in a subprocess with positional and keyword arguments.
|
|
125
129
|
|
|
126
130
|
\tThis is useful when you need to run a function in isolation to avoid memory leaks,
|
|
@@ -133,6 +137,7 @@ def run_in_subprocess[R](func: Callable[..., R], *args: Any, timeout: float | No
|
|
|
133
137
|
\t\t*args (Any): Positional arguments to pass to the function.
|
|
134
138
|
\t\ttimeout (float | None): Maximum time in seconds to wait for the subprocess.
|
|
135
139
|
\t\t\tIf None, wait indefinitely. If the subprocess exceeds this time, it will be terminated.
|
|
140
|
+
\t\tno_join (bool): If True, do not wait for the subprocess to finish (fire-and-forget).
|
|
136
141
|
\t\t**kwargs (Any): Keyword arguments to pass to the function.
|
|
137
142
|
|
|
138
143
|
\tReturns:
|
stouputils/stouputils/print.pyi
CHANGED
|
@@ -15,7 +15,7 @@ previous_args_kwards: tuple[Any, Any]
|
|
|
15
15
|
nb_values: int
|
|
16
16
|
import_time: float
|
|
17
17
|
|
|
18
|
-
def colored_for_loop[T](iterable: Iterable[T], desc: str = 'Processing', color: str = ..., bar_format: str = ..., ascii: bool = False, **kwargs: Any) -> Iterator[T]:
|
|
18
|
+
def colored_for_loop[T](iterable: Iterable[T], desc: str = 'Processing', color: str = ..., bar_format: str = ..., ascii: bool = False, smooth_tqdm: bool = True, **kwargs: Any) -> Iterator[T]:
|
|
19
19
|
''' Function to iterate over a list with a colored TQDM progress bar like the other functions in this module.
|
|
20
20
|
|
|
21
21
|
\tArgs:
|
|
@@ -24,7 +24,7 @@ def colored_for_loop[T](iterable: Iterable[T], desc: str = 'Processing', color:
|
|
|
24
24
|
\t\tcolor\t\t(str):\t\t\t\tColor of the progress bar (Defaults to MAGENTA)
|
|
25
25
|
\t\tbar_format\t(str):\t\t\t\tFormat of the progress bar (Defaults to BAR_FORMAT)
|
|
26
26
|
\t\tascii\t\t(bool):\t\t\t\tWhether to use ASCII or Unicode characters for the progress bar (Defaults to False)
|
|
27
|
-
\t\
|
|
27
|
+
\t\tsmooth_tqdm\t(bool):\t\t\t\tWhether to enable smooth progress bar updates by setting miniters=1 and mininterval=0.0 (Defaults to True)
|
|
28
28
|
\t\t**kwargs:\t\t\t\t\t\tAdditional arguments to pass to the TQDM progress bar
|
|
29
29
|
|
|
30
30
|
\tYields:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.13.
|
|
3
|
+
Version: 1.13.3
|
|
4
4
|
Summary: Stouputils is a collection of utility modules designed to simplify and enhance the development process. It includes a range of tools for tasks such as execution of doctests, display utilities, decorators, as well as context managers, and many more.
|
|
5
5
|
Keywords: utilities,tools,helpers,development,python
|
|
6
6
|
Author: Stoupy51
|
|
@@ -29,7 +29,7 @@ stouputils/continuous_delivery/cd_utils.py,sha256=fkaHk2V3j66uFAUsM2c_UddNhXW2KA
|
|
|
29
29
|
stouputils/continuous_delivery/cd_utils.pyi,sha256=nxTLQydVOSVIix88dRtBXjMrUPpI5ftiQYbLI_nMByQ,4848
|
|
30
30
|
stouputils/continuous_delivery/github.py,sha256=Iva2XNm60Th78P_evnhCJHn0Q9-06udPlOZAxtZB5vw,19464
|
|
31
31
|
stouputils/continuous_delivery/github.pyi,sha256=RHRsSroEsT0I1qeuq-Wg0JLdEEDttLrzgHZPVRtLZ0Q,6641
|
|
32
|
-
stouputils/continuous_delivery/pypi.py,sha256=
|
|
32
|
+
stouputils/continuous_delivery/pypi.py,sha256=H62NlWKG_9OQcNpisEJ3DqtNnneVmcnVnv3NItdNvv0,5298
|
|
33
33
|
stouputils/continuous_delivery/pypi.pyi,sha256=qmMeHDzezN_ZW-_jGRFbaccG_rkfELbmW9hUPU6vptY,2325
|
|
34
34
|
stouputils/continuous_delivery/pyproject.py,sha256=olD3QqzLfCLnTBw8IkSKSLBPWyeMv6uS7A0yGdFuIvQ,4802
|
|
35
35
|
stouputils/continuous_delivery/pyproject.pyi,sha256=bMWwqyG0Auo46dt-dWGePQ9yJ8rSrgb7mnJTfbiS3TQ,2053
|
|
@@ -109,7 +109,7 @@ stouputils/data_science/scripts/exhaustive_process.py,sha256=Ty2lHBZBweWxH6smpjo
|
|
|
109
109
|
stouputils/data_science/scripts/preprocess_dataset.py,sha256=OLC2KjEtSMeyHHPpNOATfNDuq0lZ09utKhsuzBA4MN4,2929
|
|
110
110
|
stouputils/data_science/scripts/routine.py,sha256=FkTLzmcdm_qUp69D-dPAKJm2RfXZZLtPgje6lEopu2I,7662
|
|
111
111
|
stouputils/data_science/utils.py,sha256=MQ5-S21W2uvtKiwUFsyKJdeN9s9y7MxuvjfjRbwKTD8,10799
|
|
112
|
-
stouputils/decorators.py,sha256=
|
|
112
|
+
stouputils/decorators.py,sha256=bheT64aWNE22yQePB_5-JMQ4Ezm-1VcTg2WRZaJB2r4,21534
|
|
113
113
|
stouputils/decorators.pyi,sha256=k7kAOPM6c2LkhskUatoiv95JmfnMcKIxJRvhZN63axM,10561
|
|
114
114
|
stouputils/image.py,sha256=NtduEVzgbCuZhDRpDZHGTW7-wTs7MqoxUwSQcipvb08,16633
|
|
115
115
|
stouputils/image.pyi,sha256=Dkf64KmXJTAEcbtYDHFZ1kqEHqOf2FgJ2Z2BlJgp4fU,8455
|
|
@@ -127,9 +127,9 @@ stouputils/installer/windows.py,sha256=WJcsRvEj00uAlJVAWgePhR7Hq0chYE0_n2QUZG901
|
|
|
127
127
|
stouputils/installer/windows.pyi,sha256=tHogIFhPVDQS0I10liLkAxnpaFFAvmFtEVMpPIae5LU,1616
|
|
128
128
|
stouputils/io.py,sha256=yQ4jGWoI81cP-ZWxgYwqXmuD6s_IbpkKkZf5jjqqIAE,16841
|
|
129
129
|
stouputils/io.pyi,sha256=TCBTVEWUkI3dO_jWI9oPMF9SbnT1yLzFChE551JPbSY,9076
|
|
130
|
-
stouputils/parallel.py,sha256=
|
|
130
|
+
stouputils/parallel.py,sha256=duVEwRoMOOFnIW00lWNRi3DdP6crpK70H7mW_EnArS0,18867
|
|
131
131
|
stouputils/parallel.pyi,sha256=cvNMT0FyjOmehaVghurwVKABqvTO3BUbPF8f8ISp8Bw,10855
|
|
132
|
-
stouputils/print.py,sha256=
|
|
132
|
+
stouputils/print.py,sha256=BGPGu8SfIWhIjFRoUI2VaSCVGFhbBumYq9U2g1K-5uQ,16627
|
|
133
133
|
stouputils/print.pyi,sha256=-uYWZ-hlPhkeu8E0gSoQqY0u-4UhkJAtPUioQb3Xujo,6674
|
|
134
134
|
stouputils/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
135
135
|
stouputils/stouputils/__init__.pyi,sha256=J8LeijIkWrTdGlevNR8dlGlgYg-Dh_MvGjp2EsPZ8UM,351
|
|
@@ -151,7 +151,7 @@ stouputils/stouputils/continuous_delivery/pypi.pyi,sha256=fRAu8ocLNpEN6dhUTMuFxl
|
|
|
151
151
|
stouputils/stouputils/continuous_delivery/pyproject.pyi,sha256=bMWwqyG0Auo46dt-dWGePQ9yJ8rSrgb7mnJTfbiS3TQ,2053
|
|
152
152
|
stouputils/stouputils/continuous_delivery/stubs.pyi,sha256=sLZypdz1oGoymQIRPez50rnH8TQhvEIx6A7xUdGtnys,2390
|
|
153
153
|
stouputils/stouputils/ctx.pyi,sha256=-7AJwD9bKzKBFsYlgyULPznstq3LvXRXe2r_2at72FI,9799
|
|
154
|
-
stouputils/stouputils/decorators.pyi,sha256=
|
|
154
|
+
stouputils/stouputils/decorators.pyi,sha256=_ZPqr84G316gkj_cq_LZGuCMhSyGBWunvlxM5Cq9Hvo,10944
|
|
155
155
|
stouputils/stouputils/image.pyi,sha256=Dkf64KmXJTAEcbtYDHFZ1kqEHqOf2FgJ2Z2BlJgp4fU,8455
|
|
156
156
|
stouputils/stouputils/installer/__init__.pyi,sha256=ZB-8frAUOW-0pCEJL-e2AdbFodivv46v3EBYwEXCxRo,117
|
|
157
157
|
stouputils/stouputils/installer/common.pyi,sha256=5aG0-58omFkkNYeVHnQ0uHUBsaI7xoMD-WqWVdOgOms,1403
|
|
@@ -160,12 +160,12 @@ stouputils/stouputils/installer/linux.pyi,sha256=V-EbY7seOFnC6LL844bqWRNvQ7rHmMh
|
|
|
160
160
|
stouputils/stouputils/installer/main.pyi,sha256=r3j4GoMBpU06MpOqjSwoDTiSMOmbA3WWUA87970b6KE,3134
|
|
161
161
|
stouputils/stouputils/installer/windows.pyi,sha256=tHogIFhPVDQS0I10liLkAxnpaFFAvmFtEVMpPIae5LU,1616
|
|
162
162
|
stouputils/stouputils/io.pyi,sha256=TCBTVEWUkI3dO_jWI9oPMF9SbnT1yLzFChE551JPbSY,9076
|
|
163
|
-
stouputils/stouputils/parallel.pyi,sha256=
|
|
164
|
-
stouputils/stouputils/print.pyi,sha256
|
|
163
|
+
stouputils/stouputils/parallel.pyi,sha256=KjFCgIgTZu1YY0ETF-5IpEQzGpSy3a_NX-hnYlUtE8Y,11511
|
|
164
|
+
stouputils/stouputils/print.pyi,sha256=TtP-OuK22uwsP0Wcruy0FxG_zD3fFwHUpxNp34HgCUU,6745
|
|
165
165
|
stouputils/stouputils/version_pkg.pyi,sha256=QPvqp1U3QA-9C_CC1dT9Vahv1hXEhstbM7x5uzMZSsQ,755
|
|
166
166
|
stouputils/version_pkg.py,sha256=Jsp-s03L14DkiZ94vQgrlQmaxApfn9DC8M_nzT1SJLk,7014
|
|
167
167
|
stouputils/version_pkg.pyi,sha256=QPvqp1U3QA-9C_CC1dT9Vahv1hXEhstbM7x5uzMZSsQ,755
|
|
168
|
-
stouputils-1.13.
|
|
169
|
-
stouputils-1.13.
|
|
170
|
-
stouputils-1.13.
|
|
171
|
-
stouputils-1.13.
|
|
168
|
+
stouputils-1.13.3.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
|
|
169
|
+
stouputils-1.13.3.dist-info/entry_points.txt,sha256=tx0z9VOnE-sfkmbFbA93zaBMzV3XSsKEJa_BWIqUzxw,57
|
|
170
|
+
stouputils-1.13.3.dist-info/METADATA,sha256=pm63_dvhti4aalCYknYp9w3w0Th56UXDf71zVQ_oXfk,13615
|
|
171
|
+
stouputils-1.13.3.dist-info/RECORD,,
|
|
File without changes
|