Skip to content

Commit

Permalink
use tqdm process_map if progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonk committed Sep 30, 2024
1 parent a0e9157 commit e2c8ae0
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions pastastore/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from packaging.version import parse as parse_version
from pastas.io.pas import pastas_hook
from tqdm.auto import tqdm
from tqdm.contrib.concurrent import process_map

from pastastore.base import BaseConnector
from pastastore.connectors import DictConnector
Expand Down Expand Up @@ -1245,17 +1246,11 @@ def solve_models(
"Setting parallel to `False`"
)

if parallel and progressbar:
process_map(solve_model, modelnames, max_workers=max_workers)
elif parallel and not progressbar:
with ProcessPoolExecutor(max_workers=max_workers) as executor:
if progressbar:
_ = list(
tqdm(
executor.map(solve_model, modelnames),
total=len(modelnames),
desc="Solving models",
)
)
else:
executor.map(solve_model, modelnames)
executor.map(solve_model, modelnames)
else:
for ml_name in (
tqdm(modelnames, desc="Solving models") if progressbar else modelnames
Expand Down

0 comments on commit e2c8ae0

Please sign in to comment.