openeo-python-client
openeo-python-client copied to clipboard
Context parameter in openeo.UDF.from_file() causes confusion
A user let us know that the following code does not pass the context to his UDF:
cube = cube.apply_neighborhood(
openeo.UDF.from_file("test_udf.py"),
size=[
{"dimension": "x", "unit": "px", "value": 32},
{"dimension": "y", "unit": "px", "value": 32}
],
overlap=[],
context={"test_variable": "Definitely not None"}
)
The solution was to pass the context in the from_file method instead:
cube = cube.apply_neighborhood(
openeo.UDF.from_file("test_udf.py", context={"test_variable": "Definitely not None"}),
size=[
{"dimension": "x", "unit": "px", "value": 32},
{"dimension": "y", "unit": "px", "value": 32}
],
overlap=[],
)
We should either:
- Make it clear that the context parameter should not be used when an UDF object is passed
- Merge the two context parameters in the process graph