Skip to content

Commit

Permalink
Join check for enough realizations and validate
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Jun 14, 2024
1 parent 641ae0f commit e238e0d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
25 changes: 3 additions & 22 deletions src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,20 +397,6 @@ def get_runtime(self) -> Union[int, float]:
return time.time() - self.start_time
return self.stop_time - self.start_time

@staticmethod
def checkHaveSufficientRealizations(
num_successful_realizations: int, minimum_realizations: int
) -> None:
if num_successful_realizations == 0:
raise ErtRunError("Experiment failed! All realizations failed!")
if num_successful_realizations < minimum_realizations:
raise ErtRunError(
f"Too many realizations have failed! Number of successful realizations:"
f" {num_successful_realizations}, expected minimal number of successful"
f" realizations: {minimum_realizations}\n You can add/adjust "
f"MIN_REALIZATIONS to allow (more) failures in your experiments."
)

def _progress(self) -> float:
"""Fraction of completed iterations over total iterations"""

Expand Down Expand Up @@ -612,9 +598,7 @@ def rm_run_path(self) -> None:

def validate(self) -> None:
active_mask = self.active_realizations
active_realizations_count = len(
[i for i in range(len(active_mask)) if active_mask[i]]
)
active_realizations_count = active_mask.count(True)

min_realization_count = self.minimum_required_realizations

Expand Down Expand Up @@ -654,13 +638,10 @@ def _evaluate_and_postprocess(
)
for iens in failed_realizations:
run_context.deactivate_realization(iens)
self.active_realizations[iens] = False

num_successful_realizations = len(successful_realizations)
self.checkHaveSufficientRealizations(
num_successful_realizations,
self.minimum_required_realizations,
)

self.validate()
event_logger.info(
f"Experiment ran on QUEUESYSTEM: {self._queue_config.queue_system}"
)
Expand Down
5 changes: 0 additions & 5 deletions src/ert/run_models/ensemble_smoother.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ def simulation_arguments(self) -> ESRunArguments:
def run_experiment(
self, evaluator_server_config: EvaluatorServerConfig
) -> RunContext:
self.checkHaveSufficientRealizations(
self.active_realizations.count(True),
self.minimum_required_realizations,
)

log_msg = "Running ES"
logger.info(log_msg)
self.setPhaseName(log_msg)
Expand Down
10 changes: 1 addition & 9 deletions src/ert/run_models/single_test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing_extensions import override

from ert.config import ErtConfig
from ert.run_models import EnsembleExperiment, ErtRunError
from ert.run_models import EnsembleExperiment

if TYPE_CHECKING:
from queue import SimpleQueue
Expand All @@ -29,14 +29,6 @@ def __init__(
simulation_arguments, config, storage, local_queue_config, status_queue
)

@staticmethod
def checkHaveSufficientRealizations(
num_successful_realizations: int, _: int
) -> None:
# Should only have one successful realization
if num_successful_realizations != 1:
raise ErtRunError("Experiment failed!")

@override
@classmethod
def run_message(cls) -> str:
Expand Down

0 comments on commit e238e0d

Please sign in to comment.