From 320fc624594a795d1fb1c60e194bc5641695934c Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Sat, 28 Oct 2023 21:17:23 +0200 Subject: [PATCH 1/5] remotes and start R update --- Dockerfile | 4 ++-- Dockerfiles/start.R | 4 ++++ R/Collection-class.R | 2 +- man/SENTINEL_2_L2A.Rd | 4 ++-- man/eo_ml_datacube.Rd | 16 ++++++++++++++++ man/ml_datacube_schema.Rd | 14 ++++++++++++++ 6 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 man/eo_ml_datacube.Rd create mode 100644 man/ml_datacube_schema.Rd diff --git a/Dockerfile b/Dockerfile index 2be75b9..80a0044 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,8 @@ ENV TZ=Etc/UTC RUN apt-get install -y libnetcdf-dev libcurl4-openssl-dev libcpprest-dev doxygen graphviz libsqlite3-dev libboost-all-dev RUN apt-get update && apt-get install -y libproj-dev libgdal-dev -# Install devtools package -RUN R -e "install.packages('devtools')" +# Install devtools and remotes +RUN R -e "install.packages(c('devtools', 'remotes'))" # Install gdalcubes package RUN R -e "install.packages('gdalcubes')" diff --git a/Dockerfiles/start.R b/Dockerfiles/start.R index b72ed20..57a7533 100644 --- a/Dockerfiles/start.R +++ b/Dockerfiles/start.R @@ -1,3 +1,7 @@ +# Install package from GitHub +if(!require(openeosits)){ + remotes::install_github("Open-Earth-Monitor/openeosits", ref = "develop", dependencies=TRUE, force = TRUE) +} # Start service library(openeosits) diff --git a/R/Collection-class.R b/R/Collection-class.R index 995396e..11a66b2 100644 --- a/R/Collection-class.R +++ b/R/Collection-class.R @@ -51,7 +51,7 @@ Collection <- R6Class( private$metadata = list( extent = extent(private$imageCollection), - bands = NULL #gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name + bands = list() #gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name ) }, diff --git a/man/SENTINEL_2_L2A.Rd b/man/SENTINEL_2_L2A.Rd index cb56b15..7c4a841 100644 --- a/man/SENTINEL_2_L2A.Rd +++ b/man/SENTINEL_2_L2A.Rd @@ -4,7 +4,7 @@ \name{SENTINEL_2_L2A} \alias{SENTINEL_2_L2A} \title{collections: -sentinel-s2-l2a} +sentinel-2-l2a} \format{ An object of class \code{Collection} (inherits from \code{R6}) of length 13. } @@ -13,6 +13,6 @@ SENTINEL_2_L2A } \description{ collections: -sentinel-s2-l2a +sentinel-2-l2a } \keyword{datasets} diff --git a/man/eo_ml_datacube.Rd b/man/eo_ml_datacube.Rd new file mode 100644 index 0000000..b25af0e --- /dev/null +++ b/man/eo_ml_datacube.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/processes.R +\docType{data} +\name{eo_ml_datacube} +\alias{eo_ml_datacube} +\title{return object from ml pedict process} +\format{ +An object of class \code{list} of length 2. +} +\usage{ +eo_ml_datacube +} +\description{ +return object from ml pedict process +} +\keyword{datasets} diff --git a/man/ml_datacube_schema.Rd b/man/ml_datacube_schema.Rd new file mode 100644 index 0000000..a226a88 --- /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/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 ml data cube description and schema +} From 59b4b2f599a80049f61224f5f53c7e32763354a2 Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Sat, 28 Oct 2023 21:32:30 +0200 Subject: [PATCH 2/5] dockerfile refactor --- Dockerfile | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 80a0044..2ecbd03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,30 @@ FROM r-base:4.3.0 -# Install software dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common cmake g++ git supervisor wget +# Set the timezone ENV TZ=Etc/UTC -RUN apt-get install -y libnetcdf-dev libcurl4-openssl-dev libcpprest-dev doxygen graphviz libsqlite3-dev libboost-all-dev -RUN apt-get update && apt-get install -y libproj-dev libgdal-dev + +# Install software dependencies +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + software-properties-common \ + cmake \ + g++ \ + git \ + supervisor \ + wget \ + libnetcdf-dev \ + libcurl4-openssl-dev \ + libcpprest-dev \ + doxygen \ + graphviz \ + libsqlite3-dev \ + libboost-all-dev \ + libproj-dev \ + libgdal-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install FreeType +RUN apt-get update && apt-get install -y libfreetype6-dev + # Install devtools and remotes RUN R -e "install.packages(c('devtools', 'remotes'))" From a62d99e312cc02e3a963f1215ae3b46e0561a5df Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Sat, 28 Oct 2023 22:46:06 +0200 Subject: [PATCH 3/5] update R version --- Dockerfile | 9 ++------- Dockerfiles/start.R | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ecbd03..b6de09e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM r-base:4.3.0 +FROM r-base:4.3.1 # Set the timezone ENV TZ=Etc/UTC @@ -19,12 +19,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ libsqlite3-dev \ libboost-all-dev \ libproj-dev \ - libgdal-dev \ - && rm -rf /var/lib/apt/lists/* - -# Install FreeType -RUN apt-get update && apt-get install -y libfreetype6-dev - + libgdal-dev # Install devtools and remotes RUN R -e "install.packages(c('devtools', 'remotes'))" diff --git a/Dockerfiles/start.R b/Dockerfiles/start.R index 57a7533..acad699 100644 --- a/Dockerfiles/start.R +++ b/Dockerfiles/start.R @@ -1,5 +1,6 @@ # Install package from GitHub if(!require(openeosits)){ + message("openeosits not installed, installing....") remotes::install_github("Open-Earth-Monitor/openeosits", ref = "develop", dependencies=TRUE, force = TRUE) } # Start service @@ -10,8 +11,8 @@ aws.host <-Sys.getenv("AWSHOST") if (aws.host == ""){ aws.host = NULL }else{ - message("AWS host port id is:") - message(aws.host) + message("AWS host port id is:", aws.host) + } From 3fb1452444d0d05eeca08794560e01a815aa0c93 Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Sat, 28 Oct 2023 22:57:29 +0200 Subject: [PATCH 4/5] specify sits version --- DESCRIPTION | 2 +- Dockerfile | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8b62b23..29ddce4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -45,7 +45,7 @@ Imports: rstac, caret, randomForest, - sits + sits (== 1.4.1) Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 Collate: diff --git a/Dockerfile b/Dockerfile index b6de09e..62ebafe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,9 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ libproj-dev \ libgdal-dev +# Install libfreetype6 +RUN apt-get install -y libfreetype6-dev + # Install devtools and remotes RUN R -e "install.packages(c('devtools', 'remotes'))" From 116156057ac5493f60c85a2a8e324d0024268447 Mon Sep 17 00:00:00 2001 From: Brian Pondi Date: Sun, 29 Oct 2023 21:01:43 +0100 Subject: [PATCH 5/5] update collections class --- DESCRIPTION | 2 +- Dockerfile | 52 +++++++++-------------------- Dockerfiles/start.R | 5 --- R/Collection-class.R | 78 +++++++++++++++++++++++--------------------- 4 files changed, 57 insertions(+), 80 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 29ddce4..46f6f9a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -45,7 +45,7 @@ Imports: rstac, caret, randomForest, - sits (== 1.4.1) + sits (>= 1.4.1) Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 Collate: diff --git a/Dockerfile b/Dockerfile index 62ebafe..ac6f88e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,51 +1,29 @@ -FROM r-base:4.3.1 +FROM r-base:4.3.0 -# Set the timezone +# Install software dependencies +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common cmake g++ git supervisor wget ENV TZ=Etc/UTC +RUN apt-get install -y libnetcdf-dev libcurl4-openssl-dev libcpprest-dev doxygen graphviz libsqlite3-dev libboost-all-dev +RUN apt-get update && apt-get install -y libproj-dev libgdal-dev -# Install software dependencies -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - software-properties-common \ - cmake \ - g++ \ - git \ - supervisor \ - wget \ - libnetcdf-dev \ - libcurl4-openssl-dev \ - libcpprest-dev \ - doxygen \ - graphviz \ - libsqlite3-dev \ - libboost-all-dev \ - libproj-dev \ - libgdal-dev - -# Install libfreetype6 -RUN apt-get install -y libfreetype6-dev - -# Install devtools and remotes -RUN R -e "install.packages(c('devtools', 'remotes'))" +# Install devtools package +RUN R -e "install.packages('devtools')" # Install gdalcubes package RUN R -e "install.packages('gdalcubes')" -# Install sits package -RUN R -e "install.packages('sits')" - -# Install other necessary packages +# install other necessary packages RUN apt-get install -y libsodium-dev libudunits2-dev -RUN R -e "install.packages(c('plumber', 'useful', 'ids', 'R6', 'sf', 'stars','rstac','bfast', 'geojsonsf', 'torch'))" +RUN Rscript -e "install.packages(c('plumber', 'useful', 'ids', 'R6', 'sf', 'rstac','bfast'))" -# Create directories +# create directories RUN mkdir -p /opt/dockerfiles/ && mkdir -p /var/openeo/workspace/ && mkdir -p /var/openeo/workspace/data/ -# Install packages from the local directory +# install packages from local directory COPY ./ /opt/dockerfiles/ -RUN R -e "remotes::install_local('/opt/dockerfiles', dependencies = TRUE)" +RUN Rscript -e "remotes::install_local('/opt/dockerfiles',dependencies=TRUE)" -# CMD or entrypoint for startup -CMD ["R", "-q", "--no-save", "-f", "/opt/dockerfiles/Dockerfiles/start.R"] +# cmd or entrypoint for startup +CMD ["R", "-q", "--no-save", "-f /opt/dockerfiles/Dockerfiles/start.R"] -# Expose the port -EXPOSE 8000 +EXPOSE 8000 \ No newline at end of file diff --git a/Dockerfiles/start.R b/Dockerfiles/start.R index acad699..eadef27 100644 --- a/Dockerfiles/start.R +++ b/Dockerfiles/start.R @@ -1,8 +1,3 @@ -# Install package from GitHub -if(!require(openeosits)){ - message("openeosits not installed, installing....") - remotes::install_github("Open-Earth-Monitor/openeosits", ref = "develop", dependencies=TRUE, force = TRUE) -} # Start service library(openeosits) diff --git a/R/Collection-class.R b/R/Collection-class.R index 11a66b2..f6210d4 100644 --- a/R/Collection-class.R +++ b/R/Collection-class.R @@ -22,10 +22,9 @@ Collection <- R6Class( #' @param description Short description of the collection #' initialize = function(id = NA, title = NA, description = NA) { - - self$id = id - self$title = title - self$description = description + self$id <- id + self$title <- title + self$description <- description }, #' @description Add image collection to the collection class object @@ -33,7 +32,11 @@ Collection <- R6Class( #' @param ImageCollection Collection of class 'image collection' #' setCollection = function(ImageCollection) { - private$imageCollection = ImageCollection + if (!gdalcubes:::is.image_collection(ImageCollection)) { + stop("Assigned data is not an image collection") + } + + private$imageCollection <- ImageCollection self$setMetadata() }, @@ -48,10 +51,9 @@ Collection <- R6Class( #' @description add extent and bands to the metadata of the collection object #' setMetadata = function() { - - private$metadata = list( + private$metadata <- list( extent = extent(private$imageCollection), - bands = list() #gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name + bands = gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name ) }, @@ -68,12 +70,11 @@ Collection <- R6Class( #' @return converted bandlist #' getEoBands = function() { - - list = list() - bands = as.list(self$getMetadata()$bands) - list = lapply(bands, function(x) { - append(list, list(name = x)) - }) + list <- list() + bands <- as.list(self$getMetadata()$bands) + list <- lapply(bands, function(x) { + append(list, list(name = x)) + }) return(list) }, @@ -88,29 +89,31 @@ Collection <- R6Class( license = "proprietary", extent = list( spatial = list( - bbox = list(list(self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, - self$getMetadata()$extent$right, self$getMetadata()$extent$top)) + bbox = list(list( + self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, + self$getMetadata()$extent$right, self$getMetadata()$extent$top + )) ), temporal = list( interval = list(list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1)) ) ), - links = list( - list( - rel = "self", - href = paste(Session$getConfig()$base_url, "collections", self$id, sep = "/") - ), - list( - rel = "parent", - href = paste(Session$getConfig()$base_url, "collections", sep = "/") - )) + links = list( + list( + rel = "self", + href = paste(Session$getConfig()$base_url, "collections", self$id, sep = "/") + ), + list( + rel = "parent", + href = paste(Session$getConfig()$base_url, "collections", sep = "/") + ) + ) ) }, #' @description List extended metadata for the collection handler #' collectionInfoExtended = function() { - list( stac_version = Session$getConfig()$stac_version, stac_extensions = list(Session$getConfig()$stac_extensions), @@ -120,8 +123,10 @@ Collection <- R6Class( license = "proprietary", extent = list( spatial = list( - bbox = list(list(self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, - self$getMetadata()$extent$right, self$getMetadata()$extent$top)) + bbox = list(list( + self$getMetadata()$extent$left, self$getMetadata()$extent$bottom, + self$getMetadata()$extent$right, self$getMetadata()$extent$top + )) ), temporal = list( interval = list(list(self$getMetadata()$extent$t0, self$getMetadata()$extent$t1)) @@ -129,20 +134,18 @@ Collection <- R6Class( ), links = list(list( rel = "root", - href = paste(Session$getConfig()$base_url, "collections", sep = "/")) - ), + href = paste(Session$getConfig()$base_url, "collections", sep = "/") + )), "cube:dimensions" = list( x = list( type = "spatial", axis = "x", - extent = list(self$getMetadata()$extent$left, self$getMetadata()$extent$right - ) + extent = list(self$getMetadata()$extent$left, self$getMetadata()$extent$right) ), y = list( type = "spatial", axis = "y", - extent = list(self$getMetadata()$extent$bottom, self$getMetadata()$extent$top - ) + extent = list(self$getMetadata()$extent$bottom, self$getMetadata()$extent$top) ), t = list( type = "temporal", @@ -153,7 +156,7 @@ Collection <- R6Class( values = list(self$getMetadata()$bands) ) ), - summaries = list(constellation = list(""), 'eo:bands' = self$getEoBands()) + summaries = list(constellation = list(""), "eo:bands" = self$getEoBands()) ) } ), @@ -164,12 +167,13 @@ Collection <- R6Class( ) #' @export -is.Collection = function(obj) { +is.Collection <- function(obj) { return("Collection" %in% class(obj)) } + #' collections: -#'sentinel-2-l2a +#' sentinel-2-l2a SENTINEL_2_L2A <- Collection$new( id = "SENTINEL-2-L2A", title = "Sentinel 2 L2A",