agi-med-common 3.5.13__py3-none-any.whl → 3.6.1__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.
@@ -1,4 +1,4 @@
1
- __version__ = "3.5.13"
1
+ __version__ = "3.6.1"
2
2
 
3
3
  from .logger import LogLevelEnum, logger_init
4
4
  from .models import (
@@ -18,3 +18,4 @@ from .models import DiagnosticsXMLTagEnum, MTRSXMLTagEnum, DoctorChoiceXMLTagEnu
18
18
  from .utils import make_session_id, read_json
19
19
  from .validators import is_file_exist, validate_prompt
20
20
  from .xml_parser import XMLParser
21
+ from .parallel_map import parallel_map
@@ -0,0 +1,31 @@
1
+ from typing import Any, Callable, TypeVar
2
+ import concurrent.futures
3
+ from tqdm import tqdm
4
+
5
+
6
+ X = TypeVar("X")
7
+
8
+
9
+ def parallel_map(
10
+ func: Callable[..., X],
11
+ items: list[Any],
12
+ process: bool = False,
13
+ multiple_args: bool = False,
14
+ max_workers: int = 2,
15
+ show_tqdm: bool = False,
16
+ desc: str = "",
17
+ ) -> list[X]:
18
+ pool = (
19
+ concurrent.futures.ProcessPoolExecutor(max_workers=max_workers)
20
+ if process
21
+ else concurrent.futures.ThreadPoolExecutor(max_workers=max_workers)
22
+ )
23
+ with pool as executor:
24
+ futures = []
25
+ for item in items:
26
+ if multiple_args:
27
+ futures.append(executor.submit(func, *item))
28
+ else:
29
+ futures.append(executor.submit(func, item))
30
+ results: list[X] = [future.result() for future in tqdm(futures, disable=(not show_tqdm), desc=desc)]
31
+ return results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agi_med_common
3
- Version: 3.5.13
3
+ Version: 3.6.1
4
4
  Summary: Сommon for agi-med team
5
5
  Author: AGI-MED-TEAM
6
6
  Requires-Python: >=3.11
@@ -1,5 +1,6 @@
1
- agi_med_common/__init__.py,sha256=fYfAcXePLHvwwFdAP5vbZX0L5HFZuZLKFXij2BLvCUc,537
1
+ agi_med_common/__init__.py,sha256=qJk81VD0GhIv5kgOHlHaN0LMgw9GukSqiSB3fMJ4-I4,575
2
2
  agi_med_common/file_storage.py,sha256=GR6_jKZ0o9uwUkOKZd1XaCVOSw0YmFlCOlC6EX8zz0I,1247
3
+ agi_med_common/parallel_map.py,sha256=bC7YGM5sWxSNvaA54Qpu8rlFJTOlRyMw0eWlttkTsW8,886
3
4
  agi_med_common/utils.py,sha256=5iurKl5d1zZ_cN4yqtc0_FhrwuNBcDurbWilu28_saE,325
4
5
  agi_med_common/validators.py,sha256=R678gjPp-5XbnocRuEtdOQgJyCCOurxwaOe2nT04kSg,705
5
6
  agi_med_common/xml_parser.py,sha256=VvLIX_XCZao9i0qqpTVx8nx0vbFXSe8pEbdJdXnj97g,568
@@ -24,7 +25,7 @@ agi_med_common/models/enums/mtrs_label_enum.py,sha256=6emBndt3SCsQVZZFKQYCV2_iyj
24
25
  agi_med_common/models/enums/mtrs_xml_tag_enum.py,sha256=6OxuRsrx4b2uBjfrBgm4Y789Ly337_mQXL9VPRCpLyg,273
25
26
  agi_med_common/models/enums/state_enum.py,sha256=p7XhDxBxPeeSgbLWitq6JpJLKntS3XMHon_EevbnhEs,163
26
27
  agi_med_common/models/enums/track_id_enum.py,sha256=N3KUd97a4xDet_NKZ5URm0qWAAv3ts1l_foOjdlGY4c,532
27
- agi_med_common-3.5.13.dist-info/METADATA,sha256=p3UYLkQfXfGzVZY8lmaO49NHWRgf_TkHOpJZNBMol2w,521
28
- agi_med_common-3.5.13.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
29
- agi_med_common-3.5.13.dist-info/top_level.txt,sha256=26o565jF_7wYQj7-YJfTedtT9yDxDcf8RNikOYuPq78,15
30
- agi_med_common-3.5.13.dist-info/RECORD,,
28
+ agi_med_common-3.6.1.dist-info/METADATA,sha256=zXIejfAPXm8Q1u_8OCjTP_v8bTSWCYExG0IumlienhI,520
29
+ agi_med_common-3.6.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
30
+ agi_med_common-3.6.1.dist-info/top_level.txt,sha256=26o565jF_7wYQj7-YJfTedtT9yDxDcf8RNikOYuPq78,15
31
+ agi_med_common-3.6.1.dist-info/RECORD,,