Skip to content

Commit

Permalink
Remove the get_forward_models hook
Browse files Browse the repository at this point in the history
  • Loading branch information
verveerpj committed Nov 7, 2024
1 parent ae1fb1a commit acde21c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 41 deletions.
2 changes: 0 additions & 2 deletions src/everest_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import pathlib

from everest_models.everest_hooks import (
get_forward_models,
get_forward_models_schemas,
parse_forward_model_schema,
)
from everest_models.logger import set_up_logger

__all__ = [
"get_forward_models",
"get_forward_models_schemas",
"parse_forward_model_schema",
]
Expand Down
10 changes: 0 additions & 10 deletions src/everest_models/everest_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ def _get_jobs():
return (job for job in resources.contents(JOBS) if job.startswith("fm_"))


@hookimpl
def get_forward_models() -> List[str]:
"""Return a list of forward model names.
Returns:
List[str]: list of forward models
"""
return [job[3:] if job.startswith("fm_") else job for job in _get_jobs()]


@hookimpl
def get_forward_models_schemas() -> Dict[str, Dict[str, Type[BaseModel]]]:
"""Accumulate all forward model jobs and schemas.
Expand Down
12 changes: 11 additions & 1 deletion src/everest_models/forward_models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
from importlib import resources
from importlib.util import find_spec
from typing import Final, Type
from typing import Final, List, Type

_HAVE_ERT: Final = find_spec("ert") is not None


def get_forward_models() -> List[str]:
"""Return the list of forward model names."""
return [
job[3:]
for job in resources.contents("everest_models.jobs")
if job.startswith("fm_")
]


if _HAVE_ERT: # The everest-models package should remain installable without ERT.
import ert
from ert import ForwardModelStepDocumentation, ForwardModelStepPlugin
Expand Down
3 changes: 0 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class TestSpec:

hookspec = pluggy.HookspecMarker("test")

@hookspec
def get_forward_models(self): ...

@hookspec
def get_forward_models_schemas(self): ...

Expand Down
25 changes: 0 additions & 25 deletions tests/integration/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import itertools
import sys
from pathlib import Path

Expand All @@ -16,30 +15,6 @@ def test_hooks_registered(plugin_manager):
assert sys.modules["everest_models.everest_hooks"] in plugin_manager.get_plugins()


def test_get_forward_models_hook(plugin_manager):
jobs = {
"stea",
"drill_planner",
"compute_economics",
"schmerge",
"extract_summary_data",
"drill_date_planner",
"strip_dates",
"select_wells",
"npv",
"well_constraints",
"add_templates",
"rf",
"well_filter",
"interpret_well_drill",
"well_trajectory",
"well_swapping",
}
assert jobs.issubset(
set(itertools.chain.from_iterable(plugin_manager.hook.get_forward_models()))
)


def test_get_forward_model_schemas_hook(plugin_manager):
assert not set(plugin_manager.hook.get_forward_models_schemas().pop()) - {
"add_templates",
Expand Down

0 comments on commit acde21c

Please sign in to comment.