Skip to content

Commit

Permalink
Use new Ert plugin API
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Aug 26, 2024
1 parent f4ad52d commit 4577c9b
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions res2df/hook_implementations/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
from pathlib import Path

try:
from ert.shared.plugins.plugin_manager import hook_implementation
from ert.shared.plugins.plugin_response import plugin_response
from ert import plugin as ert_plugin
except ModuleNotFoundError:
# ert is not installed - use dummy/transparent function decorators.
def hook_implementation(func):
return func

def plugin_response(plugin_name): # pylint: disable=unused-argument
# ert is not installed - use dummy/transparent function decorator
def ert_plugin(_):
def decorator(func):
return func

Expand All @@ -28,8 +24,7 @@ def _get_jobs_from_directory(directory):
return {path.name: str(path) for path in all_files}


@hook_implementation
@plugin_response(plugin_name="res2df")
@ert_plugin(name="res2df")
def installable_jobs():
return _get_jobs_from_directory("config_jobs")

Expand All @@ -43,8 +38,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="res2df")
@ert_plugin(name="res2df")
def job_documentation(job_name):
res2df_jobs = set(installable_jobs().data.keys())
if job_name not in res2df_jobs:
Expand Down

0 comments on commit 4577c9b

Please sign in to comment.