-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from importlib import resources | ||
from importlib.util import find_spec | ||
from typing import Final | ||
|
||
_HAVE_ERT: Final = find_spec("ert") is not None | ||
|
||
if _HAVE_ERT: | ||
import ert | ||
from ert import ForwardModelStepDocumentation, ForwardModelStepPlugin | ||
|
||
def build_forward_model_step_plugin(executable_name: str): | ||
forward_model_name = executable_name.lstrip("fm_") | ||
class_name = "".join( | ||
x.capitalize() for x in forward_model_name.lower().split("_") | ||
) | ||
return type( | ||
class_name, | ||
(ForwardModelStepPlugin,), | ||
{ | ||
"__init__": lambda x: ForwardModelStepPlugin.__init__( | ||
x, name=forward_model_name, command=[executable_name] | ||
), | ||
"documentation": lambda: ForwardModelStepDocumentation( | ||
category="everest.everest_models", | ||
source_package="everest_models", | ||
source_function_name=class_name, | ||
description=f"The {forward_model_name} forward model.", | ||
), | ||
}, | ||
) | ||
|
||
@ert.plugin(name="everest_models") | ||
def installable_forward_model_steps(): | ||
return [ | ||
build_forward_model_step_plugin(job) | ||
for job in resources.contents("everest_models.jobs") | ||
if job.startswith("fm_") | ||
] |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.