Open jonathom opened 2 years ago
We could allow from_parameter/from_node in the process_id property. Or we need a process to run another process by name. Something like call_user_func in PHP or something like var x = 'mean'; x([1,2])
in JS.
This is not going to be a API v1.x thing I guess?
No, unfortunately, this would be 2.0.
A 1.0 compatible solution to implement this kind of pluggable "callback" feature, I think:
reduce_dimension
of the parent graph ({"process_id": "foo", "namespace": "user", ...}
)not very scalable and nor maintainable, but it could work
For the use case where you want to have a "variable" process id, I think the solution that integrates best without a breaking change would be to create a new process that allows calling another process.
So if you'd need something like this:
{
"process_graph": {
"load": {
"process_id": "load_collection",
"arguments": {
"id": "COPERNICUS_30",
"spatial_extent": null,
"temporal_extent": null
}
},
"reduce": {
"process_id": "reduce_dimension",
"arguments": {
"reducer": {
"process_graph": {
"stat": {
"process_id": { "from_parameter": "method" }, // <-- this is not possible, but useful
"arguments": {
"data": { "from_parameter": "data" }
},
"result": true
}
}
},
"dimension": "bands",
"data": { "from_node": "load" }
},
"result": true
}
}
}
Instead, with a new process (e.g. call_process(string id, object arguments) : any
) you could achieve this as follows:
{
"process_graph": {
"load": {
"process_id": "load_collection",
"arguments": {
"id": "COPERNICUS_30",
"spatial_extent": null,
"temporal_extent": null
}
},
"reduce": {
"process_id": "reduce_dimension",
"arguments": {
"reducer": {
"process_graph": {
"stat": {
"process_id": "call_process",
"arguments": {
"id": {
"from_parameter": "method"
},
"arguments": {
"data": {
"from_parameter": "data"
}
}
},
"result": true
}
}
},
"dimension": "bands",
"data": {
"from_node": "load"
}
},
"result": true
}
},
"parameters": [
{
"schema": {
"type": "string",
"enum": [
"mean",
"max",
"min"
]
},
"name": "method",
"description": "Choose a method for the statistic you want to compute."
}
]
}
Is that feasible to implement?
PR with a proposal: https://github.com/Open-EO/openeo-processes/pull/307
My current preference goes rather to allowing:
"process_id": { "from_parameter": "method" }
rather than having to do run_process. Both options require backend compatibility, but I don't see one being more breaking than the other. The run_process option has the downside of more complexity IMO.
Very biased, but importing or using such process graphs would basically break the Model Builder / Editor and most of the JS tooling and implementing this feature throughour the JS ecosystem would - I assume right now - take about a week of implementation time while a new process would ba about 2/3 hours effort on my side. Not sure how difficult this is on the back-end side to implement run_process. Just pointing it out here, not necesarrily a strong vote for any of the solutions.
While trying to create a graph for an observed pixel composite (/processes#271) it came up that it is currently not possible to run a process graph inside another process graph. This occurred because we tried to pass a user-input process graph into an
apply_dimension
process were it should be executed.Take a look at the following process graph. The parameter
timestep_selector
should replace themax
reducer that is only used as a placeholder inside theapply_dimension
process. Instead ofmax
, different process graphs should be executable, depending on input, e.g.min
,median
.