From c4756e605790f376e0b86aca8256b3517d8242a7 Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Wed, 22 Nov 2023 20:34:07 +0100 Subject: [PATCH 1/4] context in udf --- R/processes.R | 12 ++---------- README.md | 4 ++-- .../03-change-detection/R-Client-bfast-brandenburg.R | 4 ++-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/R/processes.R b/R/processes.R index 3846b13..a871c47 100644 --- a/R/processes.R +++ b/R/processes.R @@ -900,14 +900,6 @@ run_udf <- Process$new( subtype = "string" ) ), - Parameter$new( - name = "names", - description = "List of names to define outputs from a reducer UDF", - schema = list( - type = "string", - subtype = "string" - ) - ), Parameter$new( name = "runtime", description = "A UDF runtime identifier available at the back-end.", @@ -935,7 +927,7 @@ run_udf <- Process$new( description = "The computed result.", schema = list(type = c("number", "null")) ), - operation = function(data, udf, names = c("default"), runtime = "R", version = NULL, context = NULL, job) { + operation = function(data, udf, runtime = "R", version = NULL, context = NULL, job) { if (runtime != "R") { stop("Only R runtime is supported.") } @@ -953,7 +945,7 @@ run_udf <- Process$new( user_function <- eval(func_parse) # reducer udf message("reducer function -> time") - data <- reduce_time(data, names = names, FUN = user_function) + data <- reduce_time(data, names = context, FUN = user_function) return(data) } else { # convert parsed string function to class function diff --git a/README.md b/README.md index 23bdf6c..5f2246a 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,7 @@ change_detection = "function(x) { }" # run udf -datacube_udf = p$run_udf(data = datacube_filtered, udf = change_detection, names = c("change_date", "change_magnitude")) +datacube_udf = p$run_udf(data = datacube_filtered, udf = change.detection, context = c("change_date", "change_magnitude")) # supported formats formats = list_file_formats() @@ -233,7 +233,7 @@ result = p$save_result(data = datacube_udf, format = formats$output$NetCDF) # Process and download data synchronously start.time <- Sys.time() -compute_result(graph = result, output_file = "change_detection.nc") +compute_result(graph = result, output_file = "detected_changes.nc") end.time <- Sys.time() time.taken <- end.time - start.time time.taken diff --git a/examples/03-change-detection/R-Client-bfast-brandenburg.R b/examples/03-change-detection/R-Client-bfast-brandenburg.R index b8c16c8..fed681c 100644 --- a/examples/03-change-detection/R-Client-bfast-brandenburg.R +++ b/examples/03-change-detection/R-Client-bfast-brandenburg.R @@ -57,7 +57,7 @@ change.detection = 'function(x) { }' # run udf -datacube_udf = p$run_udf(data = datacube_filtered, udf = change.detection, names = c("change_date", "change_magnitude")) +datacube_udf = p$run_udf(data = datacube_filtered, udf = change.detection, context = c("change_date", "change_magnitude")) # supported formats formats = list_file_formats() @@ -67,7 +67,7 @@ result = p$save_result(data = datacube_udf, format = formats$output$NetCDF) # Process and download data synchronously start.time <- Sys.time() -compute_result(graph = result, output_file = "change_detection.nc") +compute_result(graph = result, output_file = "detected_changes.nc") end.time <- Sys.time() time.taken <- end.time - start.time time.taken From 4d55ad44b8d53f776b10eed4ab5acd6599a22e61 Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Wed, 22 Nov 2023 20:39:44 +0100 Subject: [PATCH 2/4] context in udf --- .../R-Client-bfast-brandenburg.R | 2 +- man/load_stac.Rd | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 man/load_stac.Rd diff --git a/examples/03-change-detection/R-Client-bfast-brandenburg.R b/examples/03-change-detection/R-Client-bfast-brandenburg.R index fed681c..8bc32de 100644 --- a/examples/03-change-detection/R-Client-bfast-brandenburg.R +++ b/examples/03-change-detection/R-Client-bfast-brandenburg.R @@ -57,7 +57,7 @@ change.detection = 'function(x) { }' # run udf -datacube_udf = p$run_udf(data = datacube_filtered, udf = change.detection, context = c("change_date", "change_magnitude")) +datacube_udf = p$run_udf(data = datacube_filtered, udf = change.detection, context = c("change_date", "change_magnitude")) # supported formats formats = list_file_formats() diff --git a/man/load_stac.Rd b/man/load_stac.Rd new file mode 100644 index 0000000..a02f085 --- /dev/null +++ b/man/load_stac.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/processes.R +\docType{data} +\name{load_stac} +\alias{load_stac} +\title{load stac} +\format{ +An object of class \code{Process} (inherits from \code{R6}) of length 12. +} +\usage{ +load_stac +} +\description{ +load stac +} +\keyword{datasets} From db0797bd26c2c5e2a2b6d7c0c8e07e1cb275dd7c Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Wed, 22 Nov 2023 21:29:43 +0100 Subject: [PATCH 3/4] context in udf --- R/processes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/processes.R b/R/processes.R index a871c47..1bdb6a1 100644 --- a/R/processes.R +++ b/R/processes.R @@ -902,7 +902,7 @@ run_udf <- Process$new( ), Parameter$new( name = "runtime", - description = "A UDF runtime identifier available at the back-end.", + description = "A UDF runtime identifier availab le at the back-end.", schema = list( type = "string", subtype = "string" From 2efa521c2f8b3ab6985f672e4bf1674cea93ef87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brian=20P=CF=95ndi?= Date: Wed, 22 Nov 2023 23:29:30 +0100 Subject: [PATCH 4/4] Update processes.R --- R/processes.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/processes.R b/R/processes.R index 1bdb6a1..a871c47 100644 --- a/R/processes.R +++ b/R/processes.R @@ -902,7 +902,7 @@ run_udf <- Process$new( ), Parameter$new( name = "runtime", - description = "A UDF runtime identifier availab le at the back-end.", + description = "A UDF runtime identifier available at the back-end.", schema = list( type = "string", subtype = "string"