Skip to content

Commit fc6bbe1

Browse files
committed
WIP
1 parent 9806537 commit fc6bbe1

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

docs/api-processbuilder.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
.. FYI this file is intended to be "included"
2-
from the ProcessBuilder class doc block
1+
.. FYI this file is intended to be inlined (with "include" RST directive)
2+
in the ProcessBuilder class doc block,
3+
which in turn is covered with autodoc/automodule from api-processes.rst.
34
45
56
The :py:class:`ProcessBuilder <openeo.processes.ProcessBuilder>` class
@@ -44,9 +45,9 @@ but some kind of *virtual placeholder*,
4445
a :py:class:`ProcessBuilder <openeo.processes.ProcessBuilder>` instance,
4546
that keeps track of the operations you intend to do on the EO data.
4647

47-
To make that more concrete, let's add type hints
48-
(which will make it easier to discover what we can do with the argument,
49-
depending on which editor or IDE you are using):
48+
To make that more concrete, it helps to add type hints
49+
which will make it easier to discover what you can do with the argument
50+
(depending on which editor or IDE you are using):
5051

5152
.. code-block:: python
5253

docs/api-processes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ and the callback functions match up:
6363
--------------------------------
6464

6565
.. FYI the ProcessBuilder docs are provided through its doc block
66-
with an "include" of "api-processbuilder.rst"
66+
with an RST "include" of "api-processbuilder.rst"
6767
6868
.. automodule:: openeo.processes
6969
:members: ProcessBuilder

docs/process_mapping.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import datetime
1010
import sys
1111
from textwrap import dedent
12+
import importlib
1213

1314
from openeo.internal.documentation import _process_registry
1415

@@ -38,11 +39,14 @@ def main():
3839
* - openEO process
3940
- openEO Python Client Method
4041
"""))
41-
42-
import openeo.rest.datacube
43-
import openeo.rest.vectorcube
44-
import openeo.rest.mlmodel
45-
import openeo.processes
42+
# Import some submodules to make sure `_process_registry` is populated
43+
for mod in [
44+
"openeo.rest.datacube",
45+
"openeo.rest.vectorcube",
46+
"openeo.rest.mlmodel",
47+
"openeo.processes",
48+
]:
49+
importlib.import_module(mod)
4650

4751
for process_id in sorted(_process_registry.keys()):
4852
functions = [x[0] for x in _process_registry[process_id]]

openeo/rest/datacube.py

+35-9
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ def aggregate_spatial(
845845
Parameter,
846846
VectorCube,
847847
],
848-
reducer: Union[str, PGNode, typing.Callable],
848+
reducer: Union[str, typing.Callable, PGNode],
849849
target_dimension: Optional[str] = None,
850850
crs: Optional[str] = None,
851851
context: Optional[dict] = None,
@@ -857,7 +857,20 @@ def aggregate_spatial(
857857
858858
:param geometries: a shapely geometry, a GeoJSON-style dictionary,
859859
a public GeoJSON URL, or a path (that is valid for the back-end) to a GeoJSON file.
860-
:param reducer: a callback function that creates a process graph, see :ref:`callbackfunctions`
860+
:param reducer: the "child callback":
861+
the name of a single openEO process,
862+
or a callback function as discussed in :ref:`callbackfunctions`,
863+
or a :py:class:`UDF <openeo.rest._datacube.UDF>` instance.
864+
865+
The callback should correspond to a process that
866+
receives an array of numerical values
867+
and returns a single numerical value.
868+
For example:
869+
870+
- ``"mean"`` (string)
871+
- :py:func:`absolute <openeo.processes.max>` (:ref:`predefined openEO process function <openeo_processes_functions>`)
872+
- ``lambda data: data.min()`` (function or lambda)
873+
861874
:param target_dimension: The new dimension name to be used for storing the results.
862875
:param crs: The spatial reference system of the provided polygon.
863876
By default longitude-latitude (EPSG:4326) is assumed.
@@ -1323,12 +1336,12 @@ def count_time(self) -> "DataCube":
13231336

13241337
@openeo_process
13251338
def aggregate_temporal(
1326-
self,
1327-
intervals: List[list],
1328-
reducer: Union[str, PGNode, typing.Callable],
1329-
labels: Optional[List[str]] = None,
1330-
dimension: Optional[str] = None,
1331-
context: Optional[dict] = None,
1339+
self,
1340+
intervals: List[list],
1341+
reducer: Union[str, typing.Callable, PGNode],
1342+
labels: Optional[List[str]] = None,
1343+
dimension: Optional[str] = None,
1344+
context: Optional[dict] = None,
13321345
) -> "DataCube":
13331346
"""
13341347
Computes a temporal aggregation based on an array of date and/or time intervals.
@@ -1338,7 +1351,20 @@ def aggregate_temporal(
13381351
If the dimension is not set, the data cube is expected to only have one temporal dimension.
13391352
13401353
:param intervals: Temporal left-closed intervals so that the start time is contained, but not the end time.
1341-
:param reducer: A reducer to be applied on all values along the specified dimension. The reducer must be a callable process (or a set processes) that accepts an array and computes a single return value of the same type as the input values, for example median.
1354+
:param reducer: the "child callback":
1355+
the name of a single openEO process,
1356+
or a callback function as discussed in :ref:`callbackfunctions`,
1357+
or a :py:class:`UDF <openeo.rest._datacube.UDF>` instance.
1358+
1359+
The callback should correspond to a process that
1360+
receives an array of numerical values
1361+
and returns a single numerical value.
1362+
For example:
1363+
1364+
- ``"mean"`` (string)
1365+
- :py:func:`absolute <openeo.processes.max>` (:ref:`predefined openEO process function <openeo_processes_functions>`)
1366+
- ``lambda data: data.min()`` (function or lambda)
1367+
13421368
:param labels: Labels for the intervals. The number of labels and the number of groups need to be equal.
13431369
:param dimension: The temporal dimension for aggregation. All data along the dimension will be passed through the specified reducer. If the dimension is not set, the data cube is expected to only have one temporal dimension.
13441370
:param context: Additional data to be passed to the reducer. Not set by default.

0 commit comments

Comments
 (0)