-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make everest config imutable #9842
base: main
Are you sure you want to change the base?
Changes from 4 commits
870a8a3
4a38244
035733f
9bfd0a3
b734a69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import logging | ||
import os | ||
from functools import partial | ||
from pathlib import Path | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
@@ -503,14 +502,20 @@ def test_complete_status_for_normal_run_monitor( | |
"everest.bin.everest_script.everserver_status", | ||
return_value={"status": ServerStatus.never_run, "message": None}, | ||
) | ||
@patch( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diff for this file in commit |
||
"everest.simulator.everest_to_ert._everest_to_ert_config_dict", | ||
return_value={"SUMMARY": "*"}, | ||
) | ||
def test_validate_ert_config_before_starting_everest_server( | ||
server_is_running_mock, server_status_mock, copy_math_func_test_data_to_tmp | ||
server_is_running_mock, | ||
server_status_mock, | ||
_ert_config_mock, | ||
copy_math_func_test_data_to_tmp, | ||
): | ||
config_file = "config_minimal.yml" | ||
everest_config = EverestConfig.with_defaults() | ||
everest_config.model.realizations = [] | ||
everest_config.model.realizations = [0] | ||
everest_config.dump(config_file) | ||
everest_config.config_path = Path(config_file) | ||
|
||
with pytest.raises(SystemExit): | ||
everest_entry([str(everest_config.config_path)]) | ||
with pytest.raises(SystemExit, match="Config validation error:"): | ||
everest_entry([config_file]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,7 @@ | |
|
||
from ert.run_models.everest_run_model import EverestRunModel | ||
from everest.config import ( | ||
ControlConfig, | ||
EverestConfig, | ||
InputConstraintConfig, | ||
InstallJobConfig, | ||
OptimizationConfig, | ||
) | ||
|
||
|
||
|
@@ -16,30 +12,32 @@ def test_discrete_optimizer( | |
): | ||
# Arrange | ||
config = EverestConfig.load_file("config_minimal.yml") | ||
config.controls = [ | ||
ControlConfig( | ||
name="point", | ||
type="generic_control", | ||
min=0, | ||
max=10, | ||
control_type="integer", | ||
initial_guess=0, | ||
variables=[{"name": "x"}, {"name": "y"}], | ||
) | ||
config_dict = config.model_dump(exclude_none=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick/style suggestion: Would do |
||
config_dict["optimization"] = { | ||
"backend": "scipy", | ||
"algorithm": "differential_evolution", | ||
"max_function_evaluations": 4, | ||
"parallel": False, | ||
"backend_options": {"seed": 9}, | ||
} | ||
|
||
config_dict["controls"] = [ | ||
{ | ||
"name": "point", | ||
"type": "generic_control", | ||
"min": 0, | ||
"max": 10, | ||
"control_type": "integer", | ||
"initial_guess": 0, | ||
"variables": [{"name": "x"}, {"name": "y"}], | ||
} | ||
] | ||
config.input_constraints = [ | ||
InputConstraintConfig(weights={"point.x": 1.0, "point.y": 1.0}, upper_bound=10) | ||
config_dict["input_constraints"] = [ | ||
{"weights": {"point.x": 1.0, "point.y": 1.0}, "upper_bound": 10} | ||
] | ||
config.optimization = OptimizationConfig( | ||
backend="scipy", | ||
algorithm="differential_evolution", | ||
max_function_evaluations=4, | ||
parallel=False, | ||
backend_options={"seed": 9}, | ||
) | ||
config.install_jobs = [InstallJobConfig(name="discrete", source="jobs/DISCRETE")] | ||
config.forward_model = ["discrete --point-file point.json --out distance"] | ||
|
||
config_dict["install_jobs"] = [{"name": "discrete", "source": "jobs/DISCRETE"}] | ||
config_dict["forward_model"] = ["discrete --point-file point.json --out distance"] | ||
config = EverestConfig.model_validate(config_dict) | ||
# Act | ||
run_model = EverestRunModel.create(config) | ||
evaluator_server_config = evaluator_server_config_generator(run_model) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice