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

JSON serialization bug with if_ #470

Closed
soxofaan opened this issue Sep 8, 2023 · 4 comments
Closed

JSON serialization bug with if_ #470

soxofaan opened this issue Sep 8, 2023 · 4 comments

Comments

@soxofaan
Copy link
Member

soxofaan commented Sep 8, 2023

issue reported by @mbuchhorn

minimal reproduction snippet:

import openeo
from openeo.processes import if_

cube = connection.load_collection("CGLS_GDMP300_V1_GLOBAL")
cube = if_(True, cube, cube)
cube = cube.apply_dimension(process=openeo.UDF(code="def x(): pass"), dimension='t')

cube.print_json()
# - > TypeError: Object of type UDF is not JSON serializable

Dropping the if_ line makes it work again

@soxofaan
Copy link
Member Author

soxofaan commented Sep 8, 2023

workaround with current version of python client is to replace the cube = if_(True, cube, cube) with

cube = cube.process(process_id="if", arguments={"value": True, "accept": cube, "reject": cube})

@mbuchhorn
Copy link

This UDP with same _if and UDF call works: https://github.com/integratedmodelling/OpenEO-UDP-UDF-catalogue/blob/main/UDP/UDP_CORINE_arable_mask.py

only difference: "apply_dimension" instead of apply in the not working version

@soxofaan
Copy link
Member Author

soxofaan commented Sep 8, 2023

@mbuchhorn no it's the other if_ in your original failing code:

cube = if_(gte(param_year, 2015), datacube1, datacube2)

This (with apply iso apply_dimension) also fails:

cube = connection.load_collection("CGLS_GDMP300_V1_GLOBAL")
cube = if_(True, cube, cube)
cube = cube.apply(process=openeo.UDF(code="def x(): pass"))

@soxofaan soxofaan changed the title JSON serializaion bug with if_ JSON serialization bug with if_ Sep 8, 2023
soxofaan added a commit that referenced this issue Sep 8, 2023
and improve type annotations along the way
related to #470 and Open-EO/openeo-api#510
soxofaan added a commit that referenced this issue Sep 8, 2023
@soxofaan
Copy link
Member Author

soxofaan commented Sep 8, 2023

fixed (will be included in next release 0.23.0)

@soxofaan soxofaan closed this as completed Sep 8, 2023
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