Open-EO / openeo-r-client

R client package for working with openEO backends

Home Page:https://open-eo.github.io/openeo-r-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coercion issue in 1.2.0

m-mohr opened this issue · comments

When running graph for a procedure that has already worked, now I get the following warning:

Warning messages:
1: In is.environment(value) || is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
2: In is.environment(value) || is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
3: In is.environment(value) || is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'

And when in compute_results:

Cannot set given object for argument 'GeoJSON': class logical not supportedWarning messages:
1: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
2: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
3: In length(self$getValue()) == 0 || is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
4: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
5: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
6: In length(self$getValue()) == 0 || is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'

This is for writing a JSON file, I also tried a Tiff :

Cannot match the value to any of the parameter selection (AnyOf)
HTTP 500 Internal Server Error.
• SERVER-ERROR: Failed to process synchronously on backend vito: OpenEoApiError("[400] ProcessParameterRequired: Process 'n/a' parameter 'data' is required. (ref: 20e73d0c-9ded-4502-832c-6cde90ef0a3f)")Warning messages:
1: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
2: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
3: In length(self$getValue()) == 0 || is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
4: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
5: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
6: In length(self$getValue()) == 0 || is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
7: In is.environment(value) || is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
8: In is.environment(value) || is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'

We've seen this also in another forum post, so seems to be a bug in the R client that many people struggle with.

4a71ee5 - There I had made adaptions already regarding checking the length of R6 objects. Those changes are already in the latest CRAN release.

I've seen this again in Huriels code, which is using 1.2.1. Maybe he can post his example code here so that you can reproduce it.

Yes, I keep receiving this warning after starting a job. To look into the code, you can check any of the 3 codes in the "src" directory of this github repo:

https://github.com/hurielreichel/s5p-viewer/tree/main/src

Are there advances on this case? I still keep receiving these warnings, and actually they compromise an important tryCatch() from my side...

Oh, I had hoped this would be solved with 1.2.2 - @flahn ?

@hurielreichel I have done something here, but as I could not reproduce the problem. I don't know if it is fixed. I can have another look at this, but I need from you a minimal example when the issue appears, as well as information which Operating System you use and which R packages / R version.

.... and actually they compromise an important tryCatch() from my side...

if this warnings are just of cosmetical nature and don't affect processing and the results in any kind, you can consider using suppressWarnings() at least that should stop compromising your tryCatch, as errors are still thrown.

R version 4.2.1
openeo version 1.2.2

The warnings I get

Warning messages:
1: In is.environment(value) || !is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
2: In is.environment(value) || !is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
3: In is.environment(value) || !is.na(value) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
4: In is.environment(value) || !is.na(value) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
5: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
6: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
7: In length(self$getValue()) == 0 || is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
8: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 4 > 1' in coercion to 'logical(1)'
9: In !is.environment(self$getValue()) && is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
10: In length(self$getValue()) == 0 || is.na(self$getValue()) :
'length(x) = 2 > 1' in coercion to 'logical(1)'
Operation was aborted by an application callbackNo job id specified.

Script :

library(openeo)
library(raster)
library(sf)
library(geojsonsf)
library(rjson)
library(ggplot2)

con = connect(host = "https://openeo.cloud")
collections = list_collections()
processes = list_processes()
login()
p = processes()

# very small test
w = 6.09
s = 46.15
e = 6.11
n = 46.17

## time extent
date1 = "2018-07-01"
date2 = "2018-10-31"

## cloud cover value (>=)
value = 0.5

# acquire data for the extent
datacube_no2 = p$load_collection(
               id = "SENTINEL_5P_L2",
               spatial_extent = list(west = w, south = s, east = e, north = n),
               temporal_extent=c(date1, date2),
               bands=c("NO2")
             )

datacube = p$load_collection(
               id = "SENTINEL_5P_L2",
               spatial_extent = list(west = w, south = s, east = e, north = n),
               temporal_extent=c(date1, date2),
               bands=c("CLOUD_FRACTION")
             )

# mask for cloud cover
threshold_ <- function(data, context) {

  threshold <- p$gte(data[1], value)
  return(threshold)
}

# apply the threshold to the cube
cloud_threshold <- p$apply(data = datacube, process = threshold_)

# mask the cloud cover with the calculated mask
datacube <- p$mask(datacube_no2, cloud_threshold)

# interpolate where nodata
interpolate = function(data,context) {
  return(p$array_interpolate_linear(data = data))
}

datacube = p$apply_dimension(process = interpolate,
               data = datacube, dimension = "t"
               )

# compress spatial dimension
lon = c(w, e)
lat = c(s, n)

bbox_df = data.frame(lon, lat)

pol = st_polygon(
  list(
    cbind(
      bbox_df$lon[c(1,2,2,1,1)],
      bbox_df$lat[c(1,1,2,2,1)])
  )
)
polygons = st_sfc(pol, crs=4326)
polygons = st_sf(polygons)

# add any attribute as a workaround
polygons$anAttribute <- 4

# aggregate spatially
datacube_mean <- p$aggregate_spatial(data = datacube, reducer = function(data, context) { p$mean(data) }, geometries = polygons)
datacube_max <- p$aggregate_spatial(data = datacube, reducer = function(data, context) { p$max(data) }, geometries = polygons)

# graph results
graph = as(datacube_mean,"Graph")
compute_result(graph = graph, output_file = "data/time-series-mean.json")

graph = as(datacube_max,"Graph")
compute_result(graph = graph, output_file = "data/time-series-max.json")

Yeah, for now I'll use suppressWarning(), thanks for the comment. But anyway it should be good fix this I'd say

Yeah, for now I'll use suppressWarning(), thanks for the comment. But anyway it should be good fix this I'd say

For sure, as it was also observed in #130!

R version 4.2.1
openeo version 1.2.2

Thanks. But which operating system do you use? Unix, macOS, Windows? That would help to look for different runtime behavior, in case I cannot reproduce the problem with my current set up.

I noticed this warning / output:

Operation was aborted by an application callbackNo job id specified.

I'm not sure whether this is the R clients or back-ends message.

AH, yeah... sorry.. I'm on Ubuntu 22.04.1 LTS

Here's another user reporting these coercion issues:
https://discuss.eodc.eu/t/sentinel2-l1c-ard-processing-no-data-found/503