This function is still under development and depends heavily on test data in a specific format and whether or not the back-end provider exposes their UDF service endpoint or if you have setup a local UDF service (see notes). The openEO UDF API v0.1.0 had foreseen to ship data and code in a single message and to be interpretable by a computing service a specific format was designed. Usually this whole operation is neatly hidden within the back-end, but if you want to test and debug the code, you need to create such data first. Some examples are available at https://github.com/Open-EO/openeo-r-udf/tree/master/examples/data.

send_udf(
  data,
  code,
  host = "http://localhost",
  port = NULL,
  language = "R",
  debug = FALSE,
  user_context = NA,
  server_context = NA,
  download_info = FALSE,
  legacy = FALSE,
  ...
)

Arguments

data

file path or a list object with the UDF-API data object

code

a call object or a file path of the user defined code

host

URL to the UDF service

port

(optional) port of the UDF service host

language

programming language (R or Python) of the source code

debug

(optional) logical - Switch on / off debugging information

user_context

list - Context parameter that are shipped from the user into the udf_service

server_context

list - Context usually sent from the back-end to trigger certain settings

download_info

(optional) logical - Whether or not to print the time taken separately for the download

legacy

logical - Whether or not the legacy endpoint is used (default: FALSE)

...

parameters passed on to httr::content or to be more precise to jsonlite::fromJSON

Value

the textual JSON representation of the result

Details

Hint: If you use a local R UDF service you might want to debug using the 'browser()' function.

Note

The debug options are only available for the R-UDF service. The R UDF-API version has to be of version 0.1.0 (not the old alpha version). You might want to check https://github.com/Open-EO/openeo-r-udf#running-the-api-locally for setting up a local service for debugging.

Examples

if (FALSE) {
port = 5555
host = "http://localhost" 
script = quote({
  all_dim = names(dim(data))
  ndvi_result = st_apply(data, FUN = function(X,...) {
    (X[8]-X[4])/(X[8]+X[4])
  }, MARGIN = all_dim[-which(all_dim=="band")])

  all_dim = names(dim(ndvi_result))
  min_ndvi = st_apply(ndvi_result,FUN = min, MARGIN = all_dim[-which(all_dim=="t")])

  min_ndvi
})
result = send_udf(data = "hypercube.json",code = script,host=host,port=port)

}