We are trying to run a UDF with a vector cube as an input, but anything we try results in an error.
First, we tried to use the function apply_vectorcube:
{
"process_graph": {
"1": {
"process_id": "load_url",
"arguments": {
"format": "PARQUET",
"url": "https://zenodo.org/records/14513586/files/airquality.no2.o3.so2.pm10.pm2p5_4.annual_pnt_20150101_20231231_eu_epsg.3035_v20240718.parquet?download=1"
}
},
"run2": {
"process_id": "run_udf",
"arguments": {
"runtime": "Python",
"context": {
"time": [
"2020-01-01T00:00:00Z",
"2020-12-31T23:59:59Z"
],
"pollutant": "O3",
"station-type": "rural-background"
},
"data": {
"from_node": "1"
},
"udf": "# Filter station geoParquet file\nimport geopandas\nimport logging\nfrom openeo.udf import XarrayDataCube\n\n# Configure logging\nlogging.basicConfig(\n level=logging.INFO,\n format='%(message)s' # Simple format showing only the message\n)\nlogger = logging.getLogger(__name__)\n\ndef lnp(message):\n \"\"\"Log and print the message\"\"\"\n logger.info(message)\n #print(message)\n\ndef apply_vectorcube(geometries, cube, context: dict):\n lnp(geometries.head(10))\n lnp(f\"Input cube shape: {cube.shape}\")\n lnp(f\"Input cube dimensions: {cube.dims}\")\n lnp(f\"Input cube coordinates: {list(cube.coords.keys())}\")\n \n return (geometries, cube)",
"version": "3"
}
},
"save9": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "run2"
},
"format": "CSV"
},
"result": true
}
},
"parameters": []
}
We then get the error:
Server error: Python exception while evaluating processing graph: openeo.udf.OpenEoUdfException: No UDF found.
But it’s clearly there, it seems that it’s trying to detect the signature but fails. Then we tried an Xarray option:
{
"process_graph": {
"1": {
"process_id": "load_url",
"arguments": {
"format": "PARQUET",
"url": "https://zenodo.org/records/14513586/files/airquality.no2.o3.so2.pm10.pm2p5_4.annual_pnt_20150101_20231231_eu_epsg.3035_v20240718.parquet?download=1"
}
},
"run2": {
"process_id": "run_udf",
"arguments": {
"runtime": "Python",
"context": {
"time": [
"2020-01-01T00:00:00Z",
"2020-12-31T23:59:59Z"
],
"pollutant": "O3",
"station-type": "rural-background"
},
"data": {
"from_node": "1"
},
"udf": "# Filter station geoParquet file\nimport geopandas\nimport logging\nfrom openeo.udf import XarrayDataCube\n\n# Configure logging\nlogging.basicConfig(\n level=logging.INFO,\n format='%(message)s' # Simple format showing only the message\n)\nlogger = logging.getLogger(__name__)\n\ndef lnp(message):\n \"\"\"Log and print the message\"\"\"\n logger.info(message)\n #print(message)\n\ndef apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:\n # Print context for debugging\n lnp(f\"UDF CONTEXT: {context}\")\n \n # Get the DataArray and ensure the correct dimension order\n original_array = cube.get_array()\n lnp(f\"Input cube shape: {original_array.shape}\")\n lnp(f\"Input cube dimensions: {original_array.dims}\")\n lnp(f\"Input cube coordinates: {list(original_array.coords.keys())}\")\n\n return cube\n",
"version": "3"
}
},
"save9": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "run2"
},
"format": "CSV"
},
"result": true
}
},
"parameters": []
}
We then get a different error:
Server error: Python exception while evaluating processing graph: TypeError: object of type 'NoneType' has no len() (Upstream ref: 'r-25040209373640c18814ecded8c12d21')
Could it be that we are trying to do run_udf without wrapping it in any type of apply? However, it’s a vector cube, and no apply process at the moment supports those. Is there any working example of a vector UDF?