stouputils 1.15.0__tar.gz → 1.15.1__tar.gz
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-1.15.0 → stouputils-1.15.1}/PKG-INFO +1 -1
- {stouputils-1.15.0 → stouputils-1.15.1}/pyproject.toml +1 -1
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/parallel.py +88 -2
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/parallel.pyi +21 -1
- {stouputils-1.15.0 → stouputils-1.15.1}/README.md +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/__init__.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/__main__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/_deprecated.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/_deprecated.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/all_doctests.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/all_doctests.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/__init__.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/automatic_docs.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/automatic_docs.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/__init__.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/config.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/config.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/image.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/image.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/video.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/applications/upscaler/video.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/archive.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/archive.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/backup.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/backup.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/collections.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/collections.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/__init__.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/cd_utils.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/cd_utils.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/github.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/github.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/pypi.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/pypi.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/pyproject.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/pyproject.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/stubs.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/continuous_delivery/stubs.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/ctx.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/ctx.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/config/get.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/config/set.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/auto_contrast.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/axis_flip.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/bias_field_correction.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/binary_threshold.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/blur.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/brightness.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/canny.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/clahe.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/common.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/contrast.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/curvature_flow_filter.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/denoise.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/histogram_equalization.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/invert.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/laplacian.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/median_blur.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/noise.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/normalize.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/random_erase.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/resize.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/rotation.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/salt_pepper.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/sharpening.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/shearing.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/threshold.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/translation.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/zoom.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image_augmentation.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image_preprocess.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/prosthesis_detection.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/technique.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/dataset.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/dataset_loader.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/grouping_strategy.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/image_loader.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/xy_tuple.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/metric_dictionnary.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/metric_utils.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/mlflow_utils.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/abstract_model.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/all.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/base_keras.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/all.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/convnext.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/densenet.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/efficientnet.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/mobilenet.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/resnet.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/squeezenet.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/vgg.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/xception.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/callbacks/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/callbacks/colored_progress_bar.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/callbacks/learning_rate_finder.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/callbacks/model_checkpoint_v2.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/callbacks/progressive_unfreezing.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/callbacks/warmup_scheduler.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/losses/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/losses/next_generation_loss.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/visualizations.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/model_interface.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/sandbox.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/range_tuple.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/scripts/augment_dataset.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/scripts/exhaustive_process.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/scripts/preprocess_dataset.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/scripts/routine.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/utils.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/decorators.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/decorators.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/image.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/image.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/__init__.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/__init__.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/common.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/common.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/downloader.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/downloader.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/linux.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/linux.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/main.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/main.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/windows.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/installer/windows.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/io.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/io.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/print.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/print.pyi +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/py.typed +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/version_pkg.py +0 -0
- {stouputils-1.15.0 → stouputils-1.15.1}/stouputils/version_pkg.pyi +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: stouputils
|
|
3
|
-
Version: 1.15.
|
|
3
|
+
Version: 1.15.1
|
|
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
|
|
@@ -8,7 +8,7 @@ module-root = ""
|
|
|
8
8
|
|
|
9
9
|
[project]
|
|
10
10
|
name = "stouputils"
|
|
11
|
-
version = "1.15.
|
|
11
|
+
version = "1.15.1"
|
|
12
12
|
description = "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."
|
|
13
13
|
readme = "README.md"
|
|
14
14
|
keywords = ["utilities", "tools", "helpers", "development", "python"]
|
|
@@ -7,6 +7,16 @@ This module provides utility functions for parallel processing, such as:
|
|
|
7
7
|
|
|
8
8
|
I highly encourage you to read the function docstrings to understand when to use each method.
|
|
9
9
|
|
|
10
|
+
Priority (nice) mapping for multiprocessing():
|
|
11
|
+
|
|
12
|
+
- Unix-style values from -20 (highest priority) to 19 (lowest priority)
|
|
13
|
+
- Windows automatic mapping:
|
|
14
|
+
* -20 to -10: HIGH_PRIORITY_CLASS
|
|
15
|
+
* -9 to -1: ABOVE_NORMAL_PRIORITY_CLASS
|
|
16
|
+
* 0: NORMAL_PRIORITY_CLASS
|
|
17
|
+
* 1 to 9: BELOW_NORMAL_PRIORITY_CLASS
|
|
18
|
+
* 10 to 19: IDLE_PRIORITY_CLASS
|
|
19
|
+
|
|
10
20
|
.. image:: https://raw.githubusercontent.com/Stoupy51/stouputils/refs/heads/main/assets/parallel_module.gif
|
|
11
21
|
:alt: stouputils parallel examples
|
|
12
22
|
"""
|
|
@@ -42,6 +52,7 @@ def multiprocessing[T, R](
|
|
|
42
52
|
desc: str = "",
|
|
43
53
|
max_workers: int | float = CPU_COUNT,
|
|
44
54
|
delay_first_calls: float = 0,
|
|
55
|
+
nice: int | None = None,
|
|
45
56
|
color: str = MAGENTA,
|
|
46
57
|
bar_format: str = BAR_FORMAT,
|
|
47
58
|
ascii: bool = False,
|
|
@@ -69,6 +80,11 @@ def multiprocessing[T, R](
|
|
|
69
80
|
delay_first_calls (float): Apply i*delay_first_calls seconds delay to the first "max_workers" calls.
|
|
70
81
|
For instance, the first process will be delayed by 0 seconds, the second by 1 second, etc.
|
|
71
82
|
(Defaults to 0): This can be useful to avoid functions being called in the same second.
|
|
83
|
+
nice (int | None): Adjust the priority of worker processes (Defaults to None).
|
|
84
|
+
Use Unix-style values: -20 (highest priority) to 19 (lowest priority).
|
|
85
|
+
Positive values reduce priority, negative values increase it.
|
|
86
|
+
Automatically converted to appropriate priority class on Windows.
|
|
87
|
+
If None, no priority adjustment is made.
|
|
72
88
|
color (str): Color of the progress bar (Defaults to MAGENTA)
|
|
73
89
|
bar_format (str): Format of the progress bar (Defaults to BAR_FORMAT)
|
|
74
90
|
ascii (bool): Whether to use ASCII or Unicode characters for the progress bar
|
|
@@ -140,13 +156,21 @@ def multiprocessing[T, R](
|
|
|
140
156
|
# Do multiprocessing only if there is more than 1 argument and more than 1 CPU
|
|
141
157
|
if max_workers > 1 and len(args) > 1:
|
|
142
158
|
def process() -> list[Any]:
|
|
159
|
+
# Wrap function with nice if specified
|
|
160
|
+
if nice is not None:
|
|
161
|
+
wrapped_args = [(nice, func, arg) for arg in args]
|
|
162
|
+
wrapped_func = _nice_wrapper
|
|
163
|
+
else:
|
|
164
|
+
wrapped_args = args
|
|
165
|
+
wrapped_func = func
|
|
166
|
+
|
|
143
167
|
if verbose:
|
|
144
168
|
return list(process_map(
|
|
145
|
-
|
|
169
|
+
wrapped_func, wrapped_args, max_workers=max_workers, chunksize=chunksize, desc=desc, bar_format=bar_format, ascii=ascii, **tqdm_kwargs
|
|
146
170
|
)) # type: ignore
|
|
147
171
|
else:
|
|
148
172
|
with Pool(max_workers) as pool:
|
|
149
|
-
return list(pool.map(
|
|
173
|
+
return list(pool.map(wrapped_func, wrapped_args, chunksize=chunksize)) # type: ignore
|
|
150
174
|
try:
|
|
151
175
|
return process()
|
|
152
176
|
except RuntimeError as e:
|
|
@@ -382,6 +406,68 @@ def run_in_subprocess[R](
|
|
|
382
406
|
raise RuntimeError("Subprocess did not return any result") from e
|
|
383
407
|
|
|
384
408
|
|
|
409
|
+
# "Private" function to wrap function execution with nice priority (must be at module level for pickling)
|
|
410
|
+
def _nice_wrapper[T, R](args: tuple[int, Callable[[T], R], T]) -> R:
|
|
411
|
+
""" Wrapper that applies nice priority then executes the function.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
args (tuple): Tuple containing (nice_value, func, arg)
|
|
415
|
+
|
|
416
|
+
Returns:
|
|
417
|
+
R: Result of the function execution
|
|
418
|
+
"""
|
|
419
|
+
nice_value, func, arg = args
|
|
420
|
+
_set_process_priority(nice_value)
|
|
421
|
+
return func(arg)
|
|
422
|
+
|
|
423
|
+
# "Private" function to set process priority (must be at module level for pickling on Windows)
|
|
424
|
+
def _set_process_priority(nice_value: int) -> None:
|
|
425
|
+
""" Set the priority of the current process.
|
|
426
|
+
|
|
427
|
+
Args:
|
|
428
|
+
nice_value (int): Unix-style priority value (-20 to 19)
|
|
429
|
+
"""
|
|
430
|
+
try:
|
|
431
|
+
import sys
|
|
432
|
+
if sys.platform == "win32":
|
|
433
|
+
# Map Unix nice values to Windows priority classes
|
|
434
|
+
# -20 to -10: HIGH, -9 to -1: ABOVE_NORMAL, 0: NORMAL, 1-9: BELOW_NORMAL, 10-19: IDLE
|
|
435
|
+
try:
|
|
436
|
+
import psutil
|
|
437
|
+
if nice_value <= -10:
|
|
438
|
+
priority = psutil.HIGH_PRIORITY_CLASS
|
|
439
|
+
elif nice_value < 0:
|
|
440
|
+
priority = psutil.ABOVE_NORMAL_PRIORITY_CLASS
|
|
441
|
+
elif nice_value == 0:
|
|
442
|
+
priority = psutil.NORMAL_PRIORITY_CLASS
|
|
443
|
+
elif nice_value < 10:
|
|
444
|
+
priority = psutil.BELOW_NORMAL_PRIORITY_CLASS
|
|
445
|
+
else:
|
|
446
|
+
priority = psutil.IDLE_PRIORITY_CLASS
|
|
447
|
+
psutil.Process().nice(priority)
|
|
448
|
+
except ImportError:
|
|
449
|
+
# Fallback to ctypes if psutil is not available
|
|
450
|
+
import ctypes
|
|
451
|
+
# Windows priority class constants
|
|
452
|
+
if nice_value <= -10:
|
|
453
|
+
priority = 0x00000080 # HIGH_PRIORITY_CLASS
|
|
454
|
+
elif nice_value < 0:
|
|
455
|
+
priority = 0x00008000 # ABOVE_NORMAL_PRIORITY_CLASS
|
|
456
|
+
elif nice_value == 0:
|
|
457
|
+
priority = 0x00000020 # NORMAL_PRIORITY_CLASS
|
|
458
|
+
elif nice_value < 10:
|
|
459
|
+
priority = 0x00004000 # BELOW_NORMAL_PRIORITY_CLASS
|
|
460
|
+
else:
|
|
461
|
+
priority = 0x00000040 # IDLE_PRIORITY_CLASS
|
|
462
|
+
kernel32 = ctypes.windll.kernel32
|
|
463
|
+
handle = kernel32.GetCurrentProcess()
|
|
464
|
+
kernel32.SetPriorityClass(handle, priority)
|
|
465
|
+
else:
|
|
466
|
+
# Unix-like systems
|
|
467
|
+
os.nice(nice_value)
|
|
468
|
+
except Exception:
|
|
469
|
+
pass # Silently ignore if we can't set priority
|
|
470
|
+
|
|
385
471
|
# "Private" function for subprocess wrapper (must be at module level for pickling on Windows)
|
|
386
472
|
def _subprocess_wrapper[R](
|
|
387
473
|
result_queue: Any,
|
|
@@ -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, smooth_tqdm: bool = True, **tqdm_kwargs: Any) -> 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, nice: int | None = None, 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.
|
|
@@ -32,6 +32,11 @@ def multiprocessing[T, R](func: Callable[..., R] | list[Callable[..., R]], args:
|
|
|
32
32
|
\t\tdelay_first_calls\t(float):\t\t\tApply i*delay_first_calls seconds delay to the first "max_workers" calls.
|
|
33
33
|
\t\t\tFor instance, the first process will be delayed by 0 seconds, the second by 1 second, etc.
|
|
34
34
|
\t\t\t(Defaults to 0): This can be useful to avoid functions being called in the same second.
|
|
35
|
+
\t\tnice\t\t\t\t(int | None):\t\tAdjust the priority of worker processes (Defaults to None).
|
|
36
|
+
\t\t\tUse Unix-style values: -20 (highest priority) to 19 (lowest priority).
|
|
37
|
+
\t\t\tPositive values reduce priority, negative values increase it.
|
|
38
|
+
\t\t\tAutomatically converted to appropriate priority class on Windows.
|
|
39
|
+
\t\t\tIf None, no priority adjustment is made.
|
|
35
40
|
\t\tcolor\t\t\t\t(str):\t\t\t\tColor of the progress bar (Defaults to MAGENTA)
|
|
36
41
|
\t\tbar_format\t\t\t(str):\t\t\t\tFormat of the progress bar (Defaults to BAR_FORMAT)
|
|
37
42
|
\t\tascii\t\t\t\t(bool):\t\t\t\tWhether to use ASCII or Unicode characters for the progress bar
|
|
@@ -169,6 +174,21 @@ def run_in_subprocess[R](func: Callable[..., R], *args: Any, timeout: float | No
|
|
|
169
174
|
\t\t\t> # With timeout to prevent hanging
|
|
170
175
|
\t\t\t> run_in_subprocess(some_gpu_func, data, timeout=300.0)
|
|
171
176
|
\t'''
|
|
177
|
+
def _nice_wrapper[T, R](args: tuple[int, Callable[[T], R], T]) -> R:
|
|
178
|
+
""" Wrapper that applies nice priority then executes the function.
|
|
179
|
+
|
|
180
|
+
\tArgs:
|
|
181
|
+
\t\targs (tuple): Tuple containing (nice_value, func, arg)
|
|
182
|
+
|
|
183
|
+
\tReturns:
|
|
184
|
+
\t\tR: Result of the function execution
|
|
185
|
+
\t"""
|
|
186
|
+
def _set_process_priority(nice_value: int) -> None:
|
|
187
|
+
""" Set the priority of the current process.
|
|
188
|
+
|
|
189
|
+
\tArgs:
|
|
190
|
+
\t\tnice_value (int): Unix-style priority value (-20 to 19)
|
|
191
|
+
\t"""
|
|
172
192
|
def _subprocess_wrapper[R](result_queue: Any, func: Callable[..., R], args: tuple[Any, ...], kwargs: dict[str, Any]) -> None:
|
|
173
193
|
""" Wrapper function to execute the target function and store the result in the queue.
|
|
174
194
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/axis_flip.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/blur.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/brightness.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/canny.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/clahe.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/common.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/contrast.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/denoise.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/invert.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/laplacian.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/median_blur.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/noise.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/normalize.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/resize.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/rotation.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/salt_pepper.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/sharpening.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/shearing.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/threshold.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/translation.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image/zoom.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/image_preprocess.py
RENAMED
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/data_processing/technique.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/dataset/grouping_strategy.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras/efficientnet.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/models/keras_utils/visualizations.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/scripts/exhaustive_process.py
RENAMED
|
File without changes
|
{stouputils-1.15.0 → stouputils-1.15.1}/stouputils/data_science/scripts/preprocess_dataset.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|