Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
style: Fixes types
Browse files Browse the repository at this point in the history
  • Loading branch information
frgfm committed Dec 11, 2023
1 parent f0b6948 commit 663c0a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/services/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def execute_in_parallel(
func: Callable[[Inp], Out],
arr: Union[Sequence[Inp], Generator[Inp, None, None]],
num_threads: Optional[int] = None,
) -> Union[Sequence[Out], map[Out]]:
) -> Sequence[Out]:
"""Execute a function in parallel on a sequence of inputs
Args:
Expand All @@ -30,9 +30,9 @@ def execute_in_parallel(
list: list of function's results
"""
num_threads = num_threads if isinstance(num_threads, int) else min(16, mp.cpu_count())

Check warning on line 32 in src/app/services/utils.py

View check run for this annotation

Codecov / codecov/patch

src/app/services/utils.py#L32

Added line #L32 was not covered by tests
results: Union[Sequence[Out], map[Out]]
results: Sequence[Out]
if num_threads < 2:
results = map(func, arr)
results = map(func, arr) # type: ignore[assignment]

Check warning on line 35 in src/app/services/utils.py

View check run for this annotation

Codecov / codecov/patch

src/app/services/utils.py#L34-L35

Added lines #L34 - L35 were not covered by tests
else:
with ThreadPool(num_threads) as tp:
results = tp.map(func, arr)

Check warning on line 38 in src/app/services/utils.py

View check run for this annotation

Codecov / codecov/patch

src/app/services/utils.py#L37-L38

Added lines #L37 - L38 were not covered by tests
Expand All @@ -44,7 +44,7 @@ def run_executions_in_parallel(
funcs: Sequence[Callable[[Inp], Out]],
arr: Sequence[Inp],
**kwargs,
) -> Union[Sequence[Out], map[Out]]:
) -> Sequence[Out]:
"""Execute distinct function calls in parallel
Args:
Expand Down

0 comments on commit 663c0a3

Please sign in to comment.