Open-EO / openeo-python-client

Python client API for OpenEO
https://open-eo.github.io/openeo-python-client/
Apache License 2.0
143 stars 36 forks source link

Update UDF signature docs for apply_datacube also supporting xarray.DataArray #534

Open soxofaan opened 4 months ago

soxofaan commented 4 months ago

Triggered from discussing #533 with @VictorVerhaert : the docs on UDF signatures (https://open-eo.github.io/openeo-python-client/udf.html#module-openeo.udf.udf_signatures) should be updated to newly added xarray.DataArray support (#310)

I wanted do it naively by introducing Union[XarrayDataCube, xarray.DataArray] in https://github.com/Open-EO/openeo-python-client/blob/7ce92925dd9544ff116b14c0339de203f854ec27/openeo/udf/udf_signatures.py#L30

but then realized that that is actually more confusing, as the user is not expected to use Union there.

The user should pick one of

def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
#or 
def apply_datacube(cube: xarray.DataArray, context: dict) -> xarray.DataArray:

but defining it like that in udf_signatures.py is not going to work (first form will be overwritten by second).

We probably have to port udf_signatures.py from a python file to a RestructuredText file in the docs

HansVRP commented 3 months ago

I want to bump this issue, since I stumbled over a similar unclarity on how UDF currently tackle working with the input data (automatic conversion if needed)