diff --git a/openeo_driver/ProcessGraphDeserializer.py b/openeo_driver/ProcessGraphDeserializer.py index 764ee652..81aee04b 100644 --- a/openeo_driver/ProcessGraphDeserializer.py +++ b/openeo_driver/ProcessGraphDeserializer.py @@ -1356,7 +1356,7 @@ def run_udf(args: dict, env: EvalEnv): if isinstance(data, SupportsRunUdf) and data.supports_udf(udf=udf, runtime=runtime): _log.info(f"run_udf: data of type {type(data)} has direct run_udf support") - return data.run_udf(udf=udf, runtime=runtime, context=context) + return data.run_udf(udf=udf, runtime=runtime, context=context, env=env) # TODO #114 add support for DriverVectorCube if isinstance(data, AggregatePolygonResult): diff --git a/openeo_driver/_version.py b/openeo_driver/_version.py index 80d0b55a..4a9f375d 100644 --- a/openeo_driver/_version.py +++ b/openeo_driver/_version.py @@ -1 +1 @@ -__version__ = "0.52.0a1" +__version__ = "0.53.0a1" diff --git a/openeo_driver/datacube.py b/openeo_driver/datacube.py index d526451e..f84b89ad 100644 --- a/openeo_driver/datacube.py +++ b/openeo_driver/datacube.py @@ -28,6 +28,25 @@ log = logging.getLogger(__name__) +class SupportsRunUdf(metaclass=abc.ABCMeta): + """ + Interface/Mixin for cube/result classes that (partially) support `run_udf` + """ + + # TODO: as there is quite some duplication between the current methods of this API: + # simplify it by just providing a single method: e.g. `get_udf_runner`, + # which returns None if run_udf is not supported, and returns a callable (to run the udf on the data) when it is supported. + + @abc.abstractmethod + def supports_udf(self, udf: str, *, runtime: str = "Python") -> bool: + """Check if UDF code is supported.""" + return False + + @abc.abstractmethod + def run_udf(self, udf: str, *, runtime: str = "Python", context: Optional[dict] = None, env: EvalEnv): + ... + + class DriverDataCube: """Base class for "driver" side raster data cubes.""" @@ -491,20 +510,3 @@ def get_model_metadata(self, directory: Union[str, Path]) -> Dict[str, Any]: def write_assets(self, directory: Union[str, Path]) -> Dict[str, StacAsset]: raise NotImplementedError - - -class SupportsRunUdf(metaclass=abc.ABCMeta): - """ - Interface for cube/result classes that (partially) support `run_udf` - """ - - @abc.abstractmethod - def supports_udf(self, udf: str, runtime: str = "Python") -> bool: - """Check if UDF code is supported.""" - return False - - @abc.abstractmethod - def run_udf( - self, udf: str, runtime: str = "Python", context: Optional[dict] = None - ): - ...