Skip to content

Commit

Permalink
Have rm_run_path() delete in parallell
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Feb 26, 2025
1 parent a8a163b commit 8025e0b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import asyncio
import concurrent.futures
import copy
import dataclasses
import functools
Expand Down Expand Up @@ -88,6 +89,11 @@ class ErtRunError(Exception):
pass


def delete_runpath(run_path: str) -> None:
if os.path.exists(run_path):
shutil.rmtree(run_path)


class _LogAggregration(logging.Handler):
def __init__(self, messages: MutableSequence[str]) -> None:
self.messages = messages
Expand Down Expand Up @@ -696,9 +702,8 @@ def get_number_of_successful_realizations(self) -> int:

@log_duration(logger, logging.INFO)
def rm_run_path(self) -> None:
for run_path in self.paths:
if Path(run_path).exists():
shutil.rmtree(run_path)
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(delete_runpath, self.paths)

def validate_successful_realizations_count(self) -> None:
successful_realizations_count = self.get_number_of_successful_realizations()
Expand Down

0 comments on commit 8025e0b

Please sign in to comment.