Skip to content

Commit

Permalink
Move max_runtime to QueueConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Dec 20, 2024
1 parent 1889e2a commit ead6423
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
6 changes: 0 additions & 6 deletions src/ert/config/analysis_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class UpdateSettings:

@dataclass
class AnalysisConfig:
max_runtime: int | None = None
minimum_required_realizations: int = 0
update_log_path: str | Path = "update_log"
es_module: ESSettings = field(default_factory=ESSettings)
Expand Down Expand Up @@ -188,7 +187,6 @@ def from_dict(cls, config_dict: ConfigDict) -> AnalysisConfig:
raise ConfigValidationError.from_collected(all_errors)

config = cls(
max_runtime=config_dict.get(ConfigKeys.MAX_RUNTIME),
minimum_required_realizations=min_realization,
update_log_path=config_dict.get(ConfigKeys.UPDATE_LOG_PATH, "update_log"),
observation_settings=obs_settings,
Expand All @@ -207,7 +205,6 @@ def log_path(self) -> Path:
def __repr__(self) -> str:
return (
"AnalysisConfig("
f"max_runtime={self.max_runtime}, "
f"min_realization={self.minimum_required_realizations}, "
f"update_log_path={self.update_log_path}, "
)
Expand All @@ -219,9 +216,6 @@ def __eq__(self, other: object) -> bool:
if self.log_path != other.log_path:
return False

if self.max_runtime != other.max_runtime:
return False

if self.observation_settings != other.observation_settings:
return False

Expand Down
3 changes: 3 additions & 0 deletions src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class QueueConfig:
) = pydantic.Field(default_factory=LocalQueueOptions, discriminator="name")
queue_options_test_run: LocalQueueOptions = field(default_factory=LocalQueueOptions)
stop_long_running: bool = False
max_runtime: int | None = None

@no_type_check
@classmethod
Expand Down Expand Up @@ -347,6 +348,7 @@ def from_dict(cls, config_dict: ConfigDict) -> QueueConfig:
queue_options,
queue_options_test_run,
stop_long_running=bool(stop_long_running),
max_runtime=config_dict.get(ConfigKeys.MAX_RUNTIME),
)

def create_local_copy(self) -> QueueConfig:
Expand All @@ -358,6 +360,7 @@ def create_local_copy(self) -> QueueConfig:
self.queue_options_test_run,
self.queue_options_test_run,
stop_long_running=bool(self.stop_long_running),
max_runtime=self.max_runtime,
)

@property
Expand Down
2 changes: 1 addition & 1 deletion src/ert/run_models/base_run_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def _build_ensemble(
active=run_arg.active,
iens=run_arg.iens,
fm_steps=self.ert_config.forward_model_steps,
max_runtime=self.ert_config.analysis_config.max_runtime,
max_runtime=self._queue_config.max_runtime,
run_arg=run_arg,
num_cpu=self.ert_config.preferred_num_cpu,
job_script=self.ert_config.queue_config.job_script,
Expand Down
13 changes: 0 additions & 13 deletions tests/ert/unit_tests/config/test_analysis_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,6 @@ def test_std_cutoff_is_set_from_corresponding_key(value):
)


def test_default_max_runtime_is_unlimited():
assert AnalysisConfig.from_dict({}).max_runtime is None
assert AnalysisConfig().max_runtime is None


@given(st.integers(min_value=1))
def test_max_runtime_is_set_from_corresponding_keyword(value):
assert (
AnalysisConfig.from_dict({ConfigKeys.MAX_RUNTIME: value}).max_runtime == value
)
assert AnalysisConfig(max_runtime=value).max_runtime == value


@given(st.integers(min_value=1))
def test_default_min_realization_is_all_realizations(value):
assert (
Expand Down
11 changes: 11 additions & 0 deletions tests/ert/unit_tests/config/test_queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,14 @@ def test_default_activate_script_generation(expected, monkeypatch, venv):
monkeypatch.delenv("VIRTUAL_ENV", raising=False)
options = QueueOptions(name="local")
assert options.activate_script == expected


def test_default_max_runtime_is_unlimited():
assert QueueConfig.from_dict({}).max_runtime is None
assert QueueConfig().max_runtime is None


@given(st.integers(min_value=1))
def test_max_runtime_is_set_from_corresponding_keyword(value):
assert QueueConfig.from_dict({ConfigKeys.MAX_RUNTIME: value}).max_runtime == value
assert QueueConfig(max_runtime=value).max_runtime == value

0 comments on commit ead6423

Please sign in to comment.