Open-EO / openeo-odc

Functions to map an openEO process graph to a job based on OpenDataCube and Xarray functions.
Apache License 2.0
1 stars 3 forks source link

Add support for single param process. #11

Closed sophieherrmann closed 3 years ago

sophieherrmann commented 3 years ago

This solves the issue with the apply process as mentioned here https://github.com/openEOPlatform/architecture-docs/issues/74

clausmichele commented 3 years ago

I've just tried with the same process graph, now sqrt appears, but from_parameter is not resolved:

loadcollection1_0 = oeop.load_collection(odc_cube=cube, **{'product': 'S2_L2A_T32TPS', 'dask_chunks': {'time': 'auto', 'x': 1000, 'y': 1000}, 'x': (11.074, 11.137), 'y': (46.125, 46.181), 'time': ['2017-07-01T00:00:00Z', '2017-07-07T23:59:59'], 'measurements': ['B04_10m', 'B03_10m', 'B02_10m']})
min1_2 = oeop.min(**{'data': loadcollection1_0, 'dimension': 'time'})
reducedimension2_1 = oeop.reduce_dimension(**{'data': min1_2, 'dimension': 't', 'reducer': {}})
sqrt1_4 = oeop.sqrt(**{'x': {'from_parameter': 'x'}})
apply1_3 = oeop.apply(**{'data': sqrt1_4, 'process': {'from_node': 'sqrt1_4'}, 'context': ''})
saveresult1_5 = oeop.save_result(**{'data': apply1_3, 'format': 'GTiff', 'options': {}})
clausmichele commented 3 years ago

There is still a minor issue, the sqrt process doesn't have any keyword parameter, so the code currently produced: sqrt1_4 = oeop.sqrt(**{'x': reducedimension2_1}) returns the following error:

sqrt1_4 = oeop.sqrt(**{'x': reducedimension2_1})
  File "/home/mclaus@eurac.edu/anaconda3/envs/odc_dev/lib/python3.6/site-packages/openeo_processes/utils.py", line 102, in fun_wrapper
    return cls_fun(*args, **kwargs)
TypeError: exec_xar() got an unexpected keyword argument 'x'

instead, this would work: sqrt1_4 = oeop.sqrt(reducedimension2_1)

sophieherrmann commented 3 years ago

This is an error in the openeo-python-processes implementation. There is already a PR which will fix this https://github.com/Open-EO/openeo-processes-python/pull/30 - I plan to merge that branch during the next days. So I think we can keep the change in this repo.