diff --git a/src/everest/config/everest_config.py b/src/everest/config/everest_config.py index 807463ba694..ff5eb7ec9be 100644 --- a/src/everest/config/everest_config.py +++ b/src/everest/config/everest_config.py @@ -73,18 +73,6 @@ from pydantic_core import ErrorDetails -def _dummy_ert_config(): - site_config = ErtConfig.read_site_config() - dummy_config = {"NUM_REALIZATIONS": 1, "ENSPATH": "."} - dummy_config.update(site_config) - return ErtConfig.with_plugins().from_dict(config_dict=dummy_config) - - -def get_system_installed_jobs(): - """Returns list of all system installed job names""" - return list(_dummy_ert_config().installed_forward_model_steps.keys()) - - # Makes property.setter work # Based on https://github.com/pydantic/pydantic/issues/1577#issuecomment-790506164 # We should use computed_property instead of this, when upgrading to pydantic 2. @@ -200,7 +188,7 @@ class EverestConfig(BaseModelWithPropertySupport, BaseModelWithContextSupport): default=None, description="A list of output constraints with unique names." ) install_jobs: list[InstallJobConfig] | None = Field( - default=None, description="A list of jobs to install" + default=None, description="A list of jobs to install", validate_default=True ) install_workflow_jobs: list[InstallJobConfig] | None = Field( default=None, description="A list of workflow jobs to install" @@ -284,7 +272,8 @@ def validate_forward_model_job_name_installed(self, info: ValidationInfo) -> Sel return self 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 + if info.context: # Add plugin jobs + installed_jobs_name += info.context.get("install_jobs", {}).keys() errors = [] for fm_job in forward_model_jobs: @@ -769,7 +758,7 @@ def with_defaults(cls, **kwargs): "model": {"realizations": [0]}, } - return cls.model_validate({**defaults, **kwargs}) + return cls.with_plugins({**defaults, **kwargs}) @staticmethod def lint_config_dict(config: dict) -> list["ErrorDetails"]: @@ -818,13 +807,17 @@ def load_file(config_file: str) -> "EverestConfig": @classmethod def with_plugins(cls, config_dict): site_config = ErtConfig.read_site_config() + ert_config: ErtConfig = ErtConfig.with_plugins().from_dict( + config_dict=site_config + ) queue_config = QueueConfig.from_dict(site_config) context = { "activate_script": ErtPluginManager().activate_script(), "queue_system": queue_config.queue_options, + "install_jobs": ert_config.installed_forward_model_steps, } with init_context(context): - return EverestConfig(**config_dict) + return cls(**config_dict) @staticmethod def load_file_with_argparser( diff --git a/tests/everest/test_util.py b/tests/everest/test_util.py index 3570f6aedaa..7cc292095d0 100644 --- a/tests/everest/test_util.py +++ b/tests/everest/test_util.py @@ -7,7 +7,6 @@ from everest import util from everest.bin.utils import report_on_previous_run from everest.config import EverestConfig, ServerConfig -from everest.config.everest_config import get_system_installed_jobs from everest.config_keys import ConfigKeys from everest.detached import ServerStatus from everest.strings import SERVER_STATUS @@ -134,13 +133,6 @@ def test_get_everserver_status_path(copy_math_func_test_data_to_tmp): assert path == expected_path -def test_get_system_installed_job_names(): - job_names = get_system_installed_jobs() - assert job_names is not None - assert isinstance(job_names, list) - assert len(job_names) > 0 - - @patch( "everest.bin.utils.everserver_status", return_value={"status": ServerStatus.failed, "message": "mock error"},