diff --git a/.github/workflows/docker-compose-develop.yml b/.github/workflows/docker-compose-develop.yml index 8f961ce..9867770 100644 --- a/.github/workflows/docker-compose-develop.yml +++ b/.github/workflows/docker-compose-develop.yml @@ -11,5 +11,5 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 - - name: Run docker-compose - run: docker-compose up -d + - name: Run docker compose + run: docker compose up -d diff --git a/.github/workflows/docker-compose-main.yml b/.github/workflows/docker-compose-main.yml index 4c57f0b..9c68b71 100644 --- a/.github/workflows/docker-compose-main.yml +++ b/.github/workflows/docker-compose-main.yml @@ -23,5 +23,5 @@ jobs: push: true tags: brianpondi/openeocubes:latest - - name: Run docker-compose - run: docker-compose up -d + - name: Run docker compose + run: docker compose up -d diff --git a/DESCRIPTION b/DESCRIPTION index 70d2ddf..1f73a6c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ Imports: gdalcubes, rstac Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Collate: 'api_process_graphs.R' 'api_job.R' diff --git a/R/api.R b/R/api.R index 0a136cb..5a544e8 100644 --- a/R/api.R +++ b/R/api.R @@ -317,6 +317,8 @@ addEndpoint = function() { Session$assignProcess(multiply) Session$assignProcess(divide) Session$assignProcess(evi) +# assign ml processes + Session$assignProcess(ml_predict) } diff --git a/R/ml-processes.R b/R/ml-processes.R index b8a2438..7059755 100644 --- a/R/ml-processes.R +++ b/R/ml-processes.R @@ -3,4 +3,84 @@ NULL + + +#' ml_datacube_schema +#' @description Return a list with datacube description and schema +#' +#' @return datacube list +ml_datacube_schema <- function() { + info <- list( + description = "A data cube with the predicted values. It removes the specified dimensions and adds new dimension for the predicted values.", + schema = list(type = "object", subtype = "raster-cube") + ) + return(info) +} + +#' ml_model_schema +#' @description Return a list with datacube description and schema +#' +#' @return model list +ml_model_schema <- function() { + info <- list( + description = "A ML model that was trained with one of the ML training processes.", + schema = list(type = "object", subtype = "mlm-model") + ) + return(info) +} + +#' return objects for the processes +eo_datacube <- ml_datacube_schema() +ml_model <- ml_model_schema() + + #' TO DO : Implement machine learning processes +#' + + +#' ml_predict +ml_predict <- Process$new( + id = "ml_predict", + description = "Applies a machine learning model to a data cube of input features and returns the predicted values.", + categories = as.array("cubes"), + summary = "Predict using ML", + parameters = list( + Parameter$new( + name = "data", + description = "A data cube with bands.", + schema = list( + type = "object", + subtype = "raster-cube" + ) + ), + Parameter$new( + name = "model", + description = "The current name of the dimension.", + schema = ml_model, + optional = FALSE + ), + Parameter$new( + name = "dimensions", + description = "Zero or more dimensions that will be reduced by the model. Fails with a `DimensionNotAvailable` exception if one of the specified dimensions does not exist.", + schema = list( + type = list("string", "array") + ), + optional = FALSE + ) + ), + returns = eo_datacube, + operation = function(data, model, dimension = NULL) { + tryCatch({ + prediction <- gdalcubes::predict(aoi_cube, model) + print(prediction) + message("Prediction calculated ....") + message(gdalcubes::as_json(prediction)) + + return(prediction) + }, + error = function(e){ + message("Error in prediction: ") + message(conditionMessage(e)) + }) + } +) diff --git a/man/eo_datacube.Rd b/man/eo_datacube.Rd index d411bd9..62e1747 100644 --- a/man/eo_datacube.Rd +++ b/man/eo_datacube.Rd @@ -1,16 +1,22 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/processes.R +% Please edit documentation in R/processes.R, R/ml-processes.R \docType{data} \name{eo_datacube} \alias{eo_datacube} \title{return object for the processes} \format{ +An object of class \code{list} of length 2. + An object of class \code{list} of length 2. } \usage{ +eo_datacube + eo_datacube } \description{ return object for the processes + +return objects for the processes } \keyword{datasets} diff --git a/man/ml_datacube_schema.Rd b/man/ml_datacube_schema.Rd new file mode 100644 index 0000000..0b9deea --- /dev/null +++ b/man/ml_datacube_schema.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ml-processes.R +\name{ml_datacube_schema} +\alias{ml_datacube_schema} +\title{ml_datacube_schema} +\usage{ +ml_datacube_schema() +} +\value{ +datacube list +} +\description{ +Return a list with datacube description and schema +} diff --git a/man/ml_model_schema.Rd b/man/ml_model_schema.Rd new file mode 100644 index 0000000..cac03a8 --- /dev/null +++ b/man/ml_model_schema.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ml-processes.R +\name{ml_model_schema} +\alias{ml_model_schema} +\title{ml_model_schema} +\usage{ +ml_model_schema() +} +\value{ +model list +} +\description{ +Return a list with datacube description and schema +} diff --git a/man/ml_predict.Rd b/man/ml_predict.Rd new file mode 100644 index 0000000..4bb5696 --- /dev/null +++ b/man/ml_predict.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ml-processes.R +\docType{data} +\name{ml_predict} +\alias{ml_predict} +\title{TO DO : Implement machine learning processes} +\format{ +An object of class \code{Process} (inherits from \code{R6}) of length 12. +} +\usage{ +ml_predict +} +\description{ +ml_predict +} +\keyword{datasets}