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

Parameter encoding bug in run_udf with context #431

Closed
soxofaan opened this issue May 25, 2023 · 1 comment
Closed

Parameter encoding bug in run_udf with context #431

soxofaan opened this issue May 25, 2023 · 1 comment

Comments

@soxofaan
Copy link
Member

(bug reported by @mbuchhorn ). Minimal reproduction example

import openeo
from openeo.api.process import Parameter
from openeo.rest.udp import build_process_dict

connection = openeo.connect(...)

param = Parameter("foo_param")
s2_cube = connection.load_collection("SENTINEL2_L2A")

udf = openeo.UDF("print('hello world')", runtime="Python", context={"foo": foo_param})
cube = s2_cube.apply(process=udf)

print(json.dumps(build_process_dict(cube, parameters=[foo_param]), indent=2))

Fails with

TypeError: Object of type Parameter is not JSON serializable
@soxofaan
Copy link
Member Author

something like this works:

cube = s2_cube.apply(lambda x: x+ foo_param)

print(json.dumps(build_process_dict(cube, parameters=[foo_param]), indent=2))

so it has something to do with putting the param in the context of the UDF

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

1 participant