|
28 | 28 | log = logging.getLogger(__name__)
|
29 | 29 |
|
30 | 30 |
|
| 31 | +class SupportsRunUdf(metaclass=abc.ABCMeta): |
| 32 | + """ |
| 33 | + Interface/Mixin for cube/result classes that (partially) support `run_udf` |
| 34 | + """ |
| 35 | + |
| 36 | + # TODO: as there is quite some duplication between the current methods of this API: |
| 37 | + # simplify it by just providing a single method: e.g. `get_udf_runner`, |
| 38 | + # which returns None if run_udf is not supported, and returns a callable (to run the udf on the data) when it is supported. |
| 39 | + |
| 40 | + @abc.abstractmethod |
| 41 | + def supports_udf(self, udf: str, *, runtime: str = "Python") -> bool: |
| 42 | + """Check if UDF code is supported.""" |
| 43 | + return False |
| 44 | + |
| 45 | + @abc.abstractmethod |
| 46 | + def run_udf(self, udf: str, *, runtime: str = "Python", context: Optional[dict] = None, env: EvalEnv): |
| 47 | + ... |
| 48 | + |
| 49 | + |
31 | 50 | class DriverDataCube:
|
32 | 51 | """Base class for "driver" side raster data cubes."""
|
33 | 52 |
|
@@ -491,20 +510,3 @@ def get_model_metadata(self, directory: Union[str, Path]) -> Dict[str, Any]:
|
491 | 510 |
|
492 | 511 | def write_assets(self, directory: Union[str, Path]) -> Dict[str, StacAsset]:
|
493 | 512 | raise NotImplementedError
|
494 |
| - |
495 |
| - |
496 |
| -class SupportsRunUdf(metaclass=abc.ABCMeta): |
497 |
| - """ |
498 |
| - Interface for cube/result classes that (partially) support `run_udf` |
499 |
| - """ |
500 |
| - |
501 |
| - @abc.abstractmethod |
502 |
| - def supports_udf(self, udf: str, runtime: str = "Python") -> bool: |
503 |
| - """Check if UDF code is supported.""" |
504 |
| - return False |
505 |
| - |
506 |
| - @abc.abstractmethod |
507 |
| - def run_udf( |
508 |
| - self, udf: str, runtime: str = "Python", context: Optional[dict] = None |
509 |
| - ): |
510 |
| - ... |
|
0 commit comments