From 358267b7ef02e871e182283e3c80fc6602e5b7c8 Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Tue, 23 Jul 2024 10:02:14 +0200 Subject: [PATCH] Use new plugin api --- pyproject.toml | 2 +- src/semeio/hook_implementations/forward_models.py | 11 ++++------- src/semeio/workflows/ahm_analysis/ahmanalysis.py | 4 ++-- src/semeio/workflows/csv_export2/csv_export2.py | 4 ++-- .../workflows/localisation/local_config_script.py | 4 ++-- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 23db9321d..7bca2fd7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ dynamic = ["version"] dependencies = [ "resdata", - "ert>=10.2.0b8", + "ert>=10.2.0b13", "importlib_metadata", "importlib_resources", "numpy", diff --git a/src/semeio/hook_implementations/forward_models.py b/src/semeio/hook_implementations/forward_models.py index a95f6c39b..3d0a2bc32 100644 --- a/src/semeio/hook_implementations/forward_models.py +++ b/src/semeio/hook_implementations/forward_models.py @@ -1,8 +1,8 @@ import importlib from typing import Dict +import ert import importlib_resources -from ert import hook_implementation, plugin_response from semeio.forward_models import ( OTS, @@ -47,8 +47,7 @@ def _get_forward_models_from_directory(directory: str) -> Dict[str, str]: return {_remove_suffix(path.name, "_CONFIG"): str(path) for path in all_files} -@hook_implementation -@plugin_response(plugin_name="semeio") +@ert.plugin(name="semeio") def installable_jobs(): return _get_forward_models_from_directory("forward_models/config") @@ -62,8 +61,7 @@ def _get_module_variable_if_exists(module_name, variable_name, default=""): return getattr(script_module, variable_name, default) -@hook_implementation -@plugin_response(plugin_name="semeio") +@ert.plugin(name="semeio") def job_documentation(job_name): forward_model_name = job_name semeio_forward_models = set(installable_jobs().data.keys()) @@ -108,8 +106,7 @@ def job_documentation(job_name): } -@hook_implementation -@plugin_response(plugin_name="semeio") +@ert.plugin(name="semeio") def installable_forward_model_steps(): return [ Design2Params, diff --git a/src/semeio/workflows/ahm_analysis/ahmanalysis.py b/src/semeio/workflows/ahm_analysis/ahmanalysis.py index 5c8d215db..3caba191c 100644 --- a/src/semeio/workflows/ahm_analysis/ahmanalysis.py +++ b/src/semeio/workflows/ahm_analysis/ahmanalysis.py @@ -5,9 +5,9 @@ import warnings from copy import deepcopy +import ert import numpy as np import pandas as pd -from ert import hook_implementation from ert.analysis import ErtAnalysisError, SmootherSnapshot from ert.storage import open_storage from scipy.stats import ks_2samp @@ -410,7 +410,7 @@ def _group_observations(facade, obs_keys, group_by): return key_map -@hook_implementation +@ert.plugin(name="semeio") def legacy_ertscript_workflow(config): workflow = config.add_workflow(AhmAnalysisJob, "AHM_ANALYSIS") workflow.description = DESCRIPTION diff --git a/src/semeio/workflows/csv_export2/csv_export2.py b/src/semeio/workflows/csv_export2/csv_export2.py index a462aaba8..b916184e2 100644 --- a/src/semeio/workflows/csv_export2/csv_export2.py +++ b/src/semeio/workflows/csv_export2/csv_export2.py @@ -2,7 +2,7 @@ import sys import pandas as pd -from ert import ErtScript, hook_implementation +from ert import ErtScript, plugin from fmu import ensemble DESCRIPTION = """ @@ -141,7 +141,7 @@ def csv_export_parser(): return parser -@hook_implementation +@plugin(name="semeio") def legacy_ertscript_workflow(config): workflow = config.add_workflow(CsvExport2Job, "CSV_EXPORT2") workflow.parser = csv_export_parser diff --git a/src/semeio/workflows/localisation/local_config_script.py b/src/semeio/workflows/localisation/local_config_script.py index 5d220d5ba..fe2ac0467 100644 --- a/src/semeio/workflows/localisation/local_config_script.py +++ b/src/semeio/workflows/localisation/local_config_script.py @@ -1,4 +1,4 @@ -from ert import hook_implementation +import ert from ert.config import ConfigValidationError from resdata.grid import Grid @@ -473,7 +473,7 @@ def validate(*_): """ -@hook_implementation +@ert.plugin(name="semeio") def legacy_ertscript_workflow(config): workflow = config.add_workflow(LocalisationConfigJob, "LOCALISATION_JOB") workflow.description = DESCRIPTION