diff --git a/src/everest/config/everest_config.py b/src/everest/config/everest_config.py index 4f6f3a8c7cf..b4e6e8aaf75 100644 --- a/src/everest/config/everest_config.py +++ b/src/everest/config/everest_config.py @@ -34,7 +34,6 @@ validate_forward_model_configs, ) from everest.jobs import script_names -from everest.util.forward_models import collect_forward_models from ..config_file_loader import yaml_file_to_substituted_config_dict from ..strings import ( @@ -289,7 +288,6 @@ def validate_forward_model_job_name_installed(self): # pylint: disable=E0213 installed_jobs_name = [job.name for job in install_jobs] installed_jobs_name += list(script_names) # default jobs installed_jobs_name += get_system_installed_jobs() # system jobs - installed_jobs_name += [job["name"] for job in collect_forward_models()] errors = [] for fm_job in forward_model_jobs: diff --git a/src/everest/plugins/hook_specs.py b/src/everest/plugins/hook_specs.py index ded4c3d38d1..411f2551830 100644 --- a/src/everest/plugins/hook_specs.py +++ b/src/everest/plugins/hook_specs.py @@ -64,8 +64,6 @@ def flow_config_path(): def get_forward_models(): """ Return a list of dicts detailing the names and paths to forward models. - - Example [{"name": "job1", "path":"path1"}, {"name": "job2", "path":"path2"}] """ diff --git a/src/everest/simulator/everest_to_ert.py b/src/everest/simulator/everest_to_ert.py index 209b6c45bfd..8916f481489 100644 --- a/src/everest/simulator/everest_to_ert.py +++ b/src/everest/simulator/everest_to_ert.py @@ -20,7 +20,6 @@ from everest.config_keys import ConfigKeys from everest.queue_driver.queue_driver import _extract_queue_system from everest.strings import EVEREST, SIMULATION_DIR, STORAGE_DIR -from everest.util.forward_models import collect_forward_models def _get_datafiles(ever_config: EverestConfig): @@ -209,8 +208,6 @@ def _fetch_everest_jobs(ever_config: EverestConfig): f.write("EXECUTABLE %s" % script) ever_jobs.append(Job(name=default_job, source=job_spec_file)) - for job in collect_forward_models(): - ever_jobs.append(Job(name=job["name"], source=job["path"])) return ever_jobs diff --git a/tests/everest/test_everlint.py b/tests/everest/test_everlint.py index 3d654af394c..dccc28fa27f 100644 --- a/tests/everest/test_everlint.py +++ b/tests/everest/test_everlint.py @@ -590,7 +590,7 @@ def test_lint_everest_models_jobs(): def test_overloading_everest_models_names(): config = yaml_file_to_substituted_config_dict(SNAKE_OIL_CONFIG) for job in collect_forward_models(): - config["install_jobs"][2]["name"] = job["name"] - config["forward_model"][1] = job["name"] + config["install_jobs"][2]["name"] = job + config["forward_model"][1] = job errors = EverestConfig.lint_config_dict(config) - assert len(errors) == 0, f"Failed for job {job['name']}" + assert len(errors) == 0, f"Failed for job {job}" diff --git a/tests/everest/test_fm_plugins.py b/tests/everest/test_fm_plugins.py index be1fae80582..1316559c1ea 100644 --- a/tests/everest/test_fm_plugins.py +++ b/tests/everest/test_fm_plugins.py @@ -1,4 +1,5 @@ import logging +from importlib import resources from itertools import chain from typing import Callable, Iterator, Sequence, Type @@ -6,9 +7,15 @@ import pytest from pydantic import BaseModel +from ert import ForwardModelStepPlugin +from everest.config import EverestConfig from everest.plugins import hook_impl, hook_specs, hookimpl +from everest.simulator.everest_to_ert import everest_to_ert_config from everest.strings import EVEREST from everest.util.forward_models import collect_forward_models +from tests.everest.utils import relpath + +SNAKE_CONFIG_PATH = relpath("test_data/snake_oil/everest/model/snake_oil.yml") class MockPluginManager(pluggy.PluginManager): @@ -35,26 +42,19 @@ def register_plugin_hooks(*plugins) -> MockPluginManager: yield register_plugin_hooks -def test_jobs(): - for job in collect_forward_models(): - assert "name" in job - assert "path" in job - - -def test_everest_models_jobs(plugin_manager): +def test_everest_models_jobs(): pytest.importorskip("everest_models") - pm = plugin_manager() - assert any( - hook.plugin_name.startswith(EVEREST) - for hook in pm.hook.get_forward_models.get_hookimpls() - ) + ert_config = everest_to_ert_config(EverestConfig.load_file(SNAKE_CONFIG_PATH)) + jobs = collect_forward_models() + assert bool(jobs) + for job in jobs: + job_class = ert_config.installed_forward_model_steps.get(job) + assert job_class is not None + assert isinstance(job_class, ForwardModelStepPlugin) def test_multiple_plugins(plugin_manager): - _JOBS = [ - {"name": "job1", "path": "/some/path1"}, - {"name": "job2", "path": "/some/path2"}, - ] + _JOBS = ["job1", "job2"] class Plugin1: @hookimpl @@ -68,7 +68,7 @@ def get_forward_models(self): pm = plugin_manager(Plugin1(), Plugin2()) - jobs = list(chain.from_iterable(pm.hook.get_forward_models())) + jobs = set(chain.from_iterable(pm.hook.get_forward_models())) for value in _JOBS: assert value in jobs diff --git a/tests/everest/test_res_initialization.py b/tests/everest/test_res_initialization.py index ed4a66991c5..0a22fb10000 100644 --- a/tests/everest/test_res_initialization.py +++ b/tests/everest/test_res_initialization.py @@ -17,7 +17,6 @@ _everest_to_ert_config_dict, everest_to_ert_config, ) -from everest.util.forward_models import collect_forward_models from tests.everest.utils import ( everest_default_jobs, hide_opm, @@ -578,19 +577,6 @@ def test_strip_date_job_insertion(copy_test_data_to_tmp): assert snake_dict == ert_config_dict -def test_forward_model_job_insertion(copy_test_data_to_tmp): - # Load config file - ever_config = EverestConfig.load_file(SNAKE_CONFIG_PATH) - - # Transform to res dict - ert_config_dict = _everest_to_ert_config_dict(ever_config) - - jobs = ert_config_dict[ErtConfigKeys.INSTALL_JOB] - for job in collect_forward_models(): - res_job = (job["name"], job["path"]) - assert res_job in jobs - - def test_workflow_job(copy_test_data_to_tmp): workflow_jobs = [{"name": "test", "source": "jobs/TEST"}] ever_config = EverestConfig.load_file(SNAKE_CONFIG_PATH) diff --git a/tests/everest/utils/__init__.py b/tests/everest/utils/__init__.py index 3e0d9dfcdb7..26772311f1b 100644 --- a/tests/everest/utils/__init__.py +++ b/tests/everest/utils/__init__.py @@ -15,7 +15,6 @@ from everest.detached import ServerStatus, everserver_status from everest.jobs import script_names from everest.util import has_opm -from everest.util.forward_models import collect_forward_models def skipif_no_opm(function): @@ -124,7 +123,7 @@ def everest_default_jobs(output_dir): os.path.join(output_dir, ".jobs", "_%s" % script_name), ) for script_name in script_names - ] + [(job["name"], job["path"]) for job in collect_forward_models()] + ] def create_cached_mocked_test_case(request, monkeypatch) -> pathlib.Path: