Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDF debugging and logging #124

Closed
soxofaan opened this issue May 20, 2022 · 1 comment
Closed

UDF debugging and logging #124

soxofaan opened this issue May 20, 2022 · 1 comment
Assignees

Comments

@soxofaan
Copy link
Member

Debugging/logging in and around UDF usage is not straightforward at the moment.

some things to tackle:

@soxofaan soxofaan self-assigned this May 20, 2022
soxofaan added a commit to Open-EO/openeo-python-client that referenced this issue May 20, 2022
soxofaan added a commit to Open-EO/openeo-geopyspark-driver that referenced this issue May 20, 2022
jdries added a commit to Open-EO/openeo-geopyspark-driver that referenced this issue Jul 12, 2022
@jdries jdries assigned bossie and soxofaan and unassigned soxofaan Sep 7, 2022
bossie added a commit to Open-EO/openeo-python-client that referenced this issue Sep 15, 2022
Open-EO/openeo-python-driver#124

was: {
  "message": "{\"data\": 3, \"message\": \"len(array)\", \"code\": \"test_udf_logging\"}",
  "levelname": "DEBUG",
  "name": "openeo.udf.debug.user",
  "created": 1663225411.8968785,
  "filename": "<string>",
  "lineno": 7,
  "process": 15984,
  "user_id": "vdboschj",
  "req_id": "r-2e3b77a0d81040b38a1e3def9f8ca293"
}
bossie added a commit to Open-EO/openeo-python-client that referenced this issue Sep 15, 2022
bossie added a commit to Open-EO/openeo-geopyspark-driver that referenced this issue Sep 15, 2022
bossie added a commit to Open-EO/openeo-geopyspark-driver that referenced this issue Sep 15, 2022
bossie added a commit to Open-EO/openeo-geopyspark-driver that referenced this issue Sep 15, 2022
@bossie
Copy link
Collaborator

bossie commented Sep 15, 2022

Invoking this UDF will add inspect log entries:

# Load initial data cube.
s2_cube = connection.load_collection(
    "SENTINEL2_L2A",
    spatial_extent={"west": 4.00, "south": 51.04, "east": 4.10, "north": 51.1},
    temporal_extent=["2022-03-01", "2022-03-31"],
    bands=["B02", "B03", "B04"]
)

# UDF code (as inline string)
udf_code = """
from openeo.udf import XarrayDataCube
from openeo.udf.debug import inspect

def apply_datacube(cube: XarrayDataCube, context: dict) -> XarrayDataCube:
    array = cube.get_array()
    inspect(data=len(array), message="len(array)", code="test_udf_logging", level="warning")
    array.values = 0.0001 * array.values
    return cube
"""

# Create UDF helper object encapsulating the UDF code.
udf = openeo.UDF(code=udf_code, runtime="Python", data={"from_parameter": "x"})

# Pass UDF object as child process to `apply`.
rescaled = s2_cube.apply(process=udf)

rescaled.execute_batch(out_format="GTiff")

Their log level, message, data and code are properly returned by the batch jobs logs API:
udf_logs_response

@bossie bossie closed this as completed Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants