Skip to content
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

Speed up tests by reusing plugin manager #9740

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ert/config/ert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ def with_plugins(
forward_model_step_classes: list[type[ForwardModelStepPlugin]] | None = None,
env_pr_fm_step: dict[str, dict[str, Any]] | None = None,
) -> type["ErtConfig"]:
pm = ErtPluginManager()
if forward_model_step_classes is None:
forward_model_step_classes = ErtPluginManager().forward_model_steps
forward_model_step_classes = pm.forward_model_steps

preinstalled_fm_steps: dict[str, ForwardModelStepPlugin] = {}
for fm_step_subclass in forward_model_step_classes:
Expand All @@ -315,15 +316,15 @@ def with_plugins(

if env_pr_fm_step is None:
env_pr_fm_step = _uppercase_subkeys_and_stringify_subvalues(
ErtPluginManager().get_forward_model_configuration()
pm.get_forward_model_configuration()
)

class ErtConfigWithPlugins(ErtConfig):
PREINSTALLED_FORWARD_MODEL_STEPS: ClassVar[
dict[str, ForwardModelStepPlugin]
] = preinstalled_fm_steps
ENV_PR_FM_STEP: ClassVar[dict[str, dict[str, Any]]] = env_pr_fm_step
ACTIVATE_SCRIPT = ErtPluginManager().activate_script()
ACTIVATE_SCRIPT = pm.activate_script()

assert issubclass(ErtConfigWithPlugins, ErtConfig)
return ErtConfigWithPlugins
Expand Down
6 changes: 4 additions & 2 deletions src/everest/config/simulator_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ class SimulatorConfig(BaseModel, extra="forbid"): # type: ignore
def default_local_queue(cls, v):
if v is None:
return LocalQueueOptions(max_running=8)
elif "activate_script" not in v and ErtPluginManager().activate_script():
v["activate_script"] = ErtPluginManager().activate_script()
if "activate_script" not in v and (
active_script := ErtPluginManager().activate_script()
):
v["activate_script"] = active_script
return v

@model_validator(mode="before")
Expand Down
4 changes: 3 additions & 1 deletion tests/ert/ui_tests/cli/run_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from ert.cli.main import run_cli as cli_runner
from ert.plugins import ErtPluginManager

PM = ErtPluginManager()


def run_cli(*args):
parser = ArgumentParser(prog="test_main")
Expand All @@ -15,7 +17,7 @@ def run_cli(*args):

def run_cli_with_pm(args: list[Any], pm: ErtPluginManager | None = None):
if pm is None:
pm = ErtPluginManager()
pm = PM
parser = ArgumentParser(prog="test_main")
parsed = ert_parser(parser, args)
res = cli_runner(parsed, pm)
Expand Down
2 changes: 1 addition & 1 deletion tests/ert/unit_tests/test_run_path_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def test_that_deprecated_runpath_substitution_remain_valid(make_run_path):
def test_write_runpath_file(storage, itr, run_paths):
runpath_fmt = "simulations/<GEO_ID>/realization-<IENS>/iter-<ITER>"
runpath_list_path = "a_file_name"
ert_config = ErtConfig.with_plugins().from_file_contents(
ert_config = ErtConfig.from_file_contents(
dedent(
f"""\
NUM_REALIZATIONS 25
Expand Down
Loading