Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PondiB authored Nov 26, 2023
2 parents f40e758 + 2997cb5 commit d36a395
Show file tree
Hide file tree
Showing 14 changed files with 246 additions and 51 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/docker-compose-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: docker-compose-workflow
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run docker-compose
run: docker-compose up -d
27 changes: 27 additions & 0 deletions .github/workflows/docker-compose-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: docker-compose-workflow
on:
push:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: brianpondi/openeosits:latest

- name: Run docker-compose
run: docker-compose up -d
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Imports:
rstac,
caret,
randomForest,
sits
sits (>= 1.4.1)
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Collate:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ RUN Rscript -e "remotes::install_local('/opt/dockerfiles', dependencies=TRUE)"
CMD ["R", "-q", "--no-save", "-f /opt/dockerfiles/Dockerfiles/start.R"]

# Expose port
EXPOSE 8000
EXPOSE 8000
12 changes: 5 additions & 7 deletions Dockerfiles/start.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ library(openeosits)

aws.host <- Sys.getenv("AWSHOST")

if (aws.host == "") {
aws.host <- NULL
} else {
message("AWS host port id is:")
message(aws.host)
if (aws.host == ""){
aws.host = NULL
}else{
message("AWS host port id is:", aws.host)
}


config <- SessionConfig(api.port = 8000, host = "0.0.0.0", aws.ipv4 = aws.host)
config$workspace.path <- "/var/openeo/workspace"
createSessionInstance(config)
Session$startSession()
Session$startSession()
74 changes: 37 additions & 37 deletions R/Collection-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ 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
#'
#' @param ImageCollection Collection of class 'image collection'
#'
setCollection = function(ImageCollection) {
if (! gdalcubes:::is.image_collection(ImageCollection)) {
if (!gdalcubes:::is.image_collection(ImageCollection)) {
stop("Assigned data is not an image collection")
}

private$imageCollection = ImageCollection
private$imageCollection <- ImageCollection
self$setMetadata()
},

Expand All @@ -52,8 +51,7 @@ 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 = gdalcubes:::libgdalcubes_image_collection_info(private$imageCollection)$bands$name
)
Expand All @@ -72,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)
},

Expand All @@ -92,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),
Expand All @@ -124,29 +123,29 @@ 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 = "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",
Expand All @@ -157,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())
)
}
),
Expand All @@ -168,12 +167,13 @@ Collection <- R6Class(
)

#' @export
is.Collection = function(obj) {
is.Collection <- function(obj) {
return("Collection" %in% class(obj))
}


#' collections:
#'sentinel-s2-l2a
#' sentinel-2-l2a
SENTINEL_2_L2A <- Collection$new(
id = "SENTINEL-2-L2A",
title = "Sentinel 2 L2A",
Expand Down
2 changes: 2 additions & 0 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ addEndpoint = function() {
Session$assignProcess(load_collection)
Session$assignProcess(ml_regularize_data_cube)
Session$assignProcess(ml_fit_class_random_forest)
Session$assignProcess(ml_predict)
Session$assignProcess(save_ml_model)
Session$assignProcess(save_result)

# assign math processes
Expand Down
93 changes: 91 additions & 2 deletions R/processes.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ schema_format <- function(type, subtype = NULL, items = NULL) {
}



#' datacube_schema
#' @description Return a list with data cube description and schema
#'
Expand All @@ -46,6 +45,21 @@ datacube_schema <- function() {
#' return object for the processes
eo_datacube <- datacube_schema()

#' ml datacube_schema
#' @description Return a list with ml data cube 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. It has the name `predictions` and is of type `other`. If a single value is returned, the dimension has a single label with name `0`.",
schema = list(type = "object", subtype = "datacube")
)
return(info)
}

#' return object from ml pedict process
eo_ml_datacube <- ml_datacube_schema()


#' load collection
load_collection <- Process$new(
Expand Down Expand Up @@ -258,7 +272,7 @@ ml_fit_class_random_forest <- Process$new(
name = "seed",
description = "A randomization seed to use for the random sampling in training. If not given or `null`, no seed is used and results may differ on subsequent use.",
schema = list(
type = list("integer", NULL)
type = list("integer", "null")
),
optional = TRUE
)
Expand All @@ -277,6 +291,81 @@ ml_fit_class_random_forest <- Process$new(
}
)


#' 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("machine learning"),
summary = "Predict using ML",
parameters = list(
Parameter$new(
name = "data",
description = "The data cube containing the input features.",
schema = list(
type = "object",
subtype = "datacube"
)
),
Parameter$new(
name = "model",
description = "A ML model that was trained with one of the ML training processes such as ``ml_fit_class_random_forest()``.",
schema = list(
type = "object",
subtype = "ml-model"
)
),
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 = "array"
)
)
),
returns = eo_ml_datacube,
operation = function(data, model, dimensions = c("bands", "time"), job) {

#if (dimensions != "bands"){
# stop("The dimensions specified is not supported, only bands dimensions are supported currently.")
#}
# TO DO
}
)

#' save ml model
save_ml_model <- Process$new(
id = "save_ml_model",
description = "Saves a machine learning model as part of a batch job.The model will be accompanied by a separate STAC Item that implements the [ml-model extension](https://github.com/stac-extensions/ml-model).",
categories = as.array("machine learning", "import"),
summary = "Save a ML model",
parameters = list(
Parameter$new(
name = "data",
description = "The data to save.",
schema = list(
type = "object",
subtype = "ml-model"
)
),
Parameter$new(
name = "options",
description = "Additional parameters to create the file(s).",
schema = list(
type = "object"
),
optional = TRUE
)
),
returns = list(
description = "false if saving failed, true otherwise.",
schema = list(type = "boolean")
),
operation = function(data, format, options = NULL, job) {
# TO DO
}
)

#' save result
save_result <- Process$new(
id = "save_result",
Expand Down
4 changes: 2 additions & 2 deletions man/SENTINEL_2_L2A.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d36a395

Please sign in to comment.