diff --git a/crunch/runner/unstructured.py b/crunch/runner/unstructured.py index 6337d24..6e5e023 100644 --- a/crunch/runner/unstructured.py +++ b/crunch/runner/unstructured.py @@ -116,6 +116,8 @@ def trip_data_fuse(self) -> None: pass # pragma: no cover +_sentinel = object() + class UserModule(ABC): def get_function( @@ -129,6 +131,19 @@ def get_function( return function + def get_value( + self, + name: str, + *, + default: Optional[Any] = _sentinel, + ) -> Optional[Any]: + value = getattr(self.module, name, default) + + if value is _sentinel and default is _sentinel: + raise ValueError(f"no `{name}` value found") + + return value + @property @abstractmethod def module(self) -> ModuleType: