From 4c49e43f67bec83a71d85f3a947a9eb8f1ec2f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Mon, 21 Oct 2024 15:18:43 +0200 Subject: [PATCH] Switch to Erts newer plugin system Avoids DeprecationWarnings. --- src/fmu/dataio/hook_implementations/jobs.py | 10 +++------- src/fmu/dataio/scripts/copy_preprocessed.py | 9 +++------ src/fmu/dataio/scripts/create_case_metadata.py | 8 ++------ tests/test_integration/test_hook_implementations.py | 2 +- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/fmu/dataio/hook_implementations/jobs.py b/src/fmu/dataio/hook_implementations/jobs.py index 19098eab6..97def8b19 100644 --- a/src/fmu/dataio/hook_implementations/jobs.py +++ b/src/fmu/dataio/hook_implementations/jobs.py @@ -1,14 +1,10 @@ from __future__ import annotations -try: - from ert.shared.plugins.plugin_manager import hook_implementation - from ert.shared.plugins.plugin_response import plugin_response -except ModuleNotFoundError: - from ert_shared.plugins.plugin_manager import hook_implementation - from ert_shared.plugins.plugin_response import plugin_response +from ert import plugin +from ert.plugins.plugin_manager import hook_implementation @hook_implementation -@plugin_response(plugin_name="fmu_dataio") +@plugin(name="fmu_dataio") def installable_workflow_jobs() -> dict: return {} diff --git a/src/fmu/dataio/scripts/copy_preprocessed.py b/src/fmu/dataio/scripts/copy_preprocessed.py index 14888249e..d3c75654e 100644 --- a/src/fmu/dataio/scripts/copy_preprocessed.py +++ b/src/fmu/dataio/scripts/copy_preprocessed.py @@ -14,12 +14,9 @@ from pathlib import Path from typing import TYPE_CHECKING, Final -from fmu.dataio import ExportPreprocessedData +from ert.plugins.plugin_manager import hook_implementation -try: - from ert.shared.plugins.plugin_manager import hook_implementation -except ModuleNotFoundError: - from ert_shared.plugins.plugin_manager import hook_implementation +from fmu.dataio import ExportPreprocessedData try: from ert.config import ErtScript @@ -27,7 +24,7 @@ from res.job_queue import ErtScript if TYPE_CHECKING: - from ert.shared.plugins.workflow_config import WorkflowConfigs + from ert.plugins.workflow_config import WorkflowConfigs logger: Final = logging.getLogger(__name__) diff --git a/src/fmu/dataio/scripts/create_case_metadata.py b/src/fmu/dataio/scripts/create_case_metadata.py index 1f2244c2c..6d0a35f3f 100644 --- a/src/fmu/dataio/scripts/create_case_metadata.py +++ b/src/fmu/dataio/scripts/create_case_metadata.py @@ -16,21 +16,17 @@ from typing import TYPE_CHECKING, Final import yaml +from ert.plugins.plugin_manager import hook_implementation from fmu.dataio import CreateCaseMetadata -try: - from ert.shared.plugins.plugin_manager import hook_implementation -except ModuleNotFoundError: - from ert_shared.plugins.plugin_manager import hook_implementation - try: from ert.config import ErtScript except ImportError: from res.job_queue import ErtScript if TYPE_CHECKING: - from ert.shared.plugins.workflow_config import WorkflowConfigs + from ert.plugins.workflow_config import WorkflowConfigs logger: Final = logging.getLogger(__name__) logger.setLevel(logging.CRITICAL) diff --git a/tests/test_integration/test_hook_implementations.py b/tests/test_integration/test_hook_implementations.py index 1c5283c5e..26bba8830 100644 --- a/tests/test_integration/test_hook_implementations.py +++ b/tests/test_integration/test_hook_implementations.py @@ -1,6 +1,6 @@ import os -from ert.shared.plugins.plugin_manager import ErtPluginManager +from ert.plugins.plugin_manager import ErtPluginManager import fmu.dataio.hook_implementations.jobs from fmu.dataio.scripts import copy_preprocessed, create_case_metadata