Skip to content

Commit

Permalink
Merge pull request #197 from caracal-pipeline/issue-195
Browse files Browse the repository at this point in the history
fixes #195 (RAM usage in for-loops)
  • Loading branch information
o-smirnov authored Jan 25, 2024
2 parents 490f812 + 239d3bc commit 1d8c0d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions stimela/kitchen/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from collections.abc import Mapping
import rich.table

from concurrent.futures import ProcessPoolExecutor
from concurrent.futures import ProcessPoolExecutor, as_completed

from stimela.config import EmptyDictDefault, EmptyListDefault
import stimela
Expand Down Expand Up @@ -1214,12 +1214,11 @@ def _run(self, params, subst=None, backend={}) -> Dict[str, Any]:
with ProcessPoolExecutor(num_workers) as pool:
# submit each iterant to pool
futures = [pool.submit(self._iterate_loop_worker, *args, raise_exc=False) for args in loop_worker_args]
stats = [f.result() for f in futures]
# update task stats, since they're recorded independently within each step, as well
# as get any exceptions from the nesting
errors = []
nfail = 0
for f in futures:
for f in as_completed(futures):
stats, outputs, exc, tb = f.result()
task_stats.add_missing_stats(stats)
if exc is not None:
Expand Down
2 changes: 1 addition & 1 deletion stimela/task_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def add(self, other: "TaskStatsDatum"):
def peak(self, other: "TaskStatsDatum"):
for f in _taskstats_sample_names + other.extras:
if hasattr(self, f):
self.extras.append(f)
setattr(self, f, max(getattr(self, f, -1e-9999), getattr(other, f)))
else:
self.extras.append(f)
setattr(self, f, getattr(other, f))

def averaged(self):
Expand Down

0 comments on commit 1d8c0d2

Please sign in to comment.