openeo-python-client icon indicating copy to clipboard operation
openeo-python-client copied to clipboard

Context parameter in openeo.UDF.from_file() causes confusion

Open JeroenVerstraelen opened this issue 1 year ago • 6 comments

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

JeroenVerstraelen avatar Dec 18 '23 14:12 JeroenVerstraelen