Error when adding "rds" data as the resource

Hi all,

I have uploaded an rds file into opal and added links to the resource.

From the client, the data can be accessed but the format can not be transformed.

> builder <- DSI::newDSLoginBuilder()
> builder$append(server="s2",  url = "http://192.168.56.101:8080/", token = "DA1GFgwECYA38DmXndmJlaUmjjN4bxPB", driver = "OpalDriver")
> 
> logindata <- builder$build()
> datasources <- DSI::datashield.login(logins = logindata)
> 
> datashield.assign.resource(datasources,symbol="res",resource = "omics.opal1")
> datashield.assign.expr(conns = datasources,  symbol = "rse", expr = quote(as.resource.object(res)))
> 
> datashield.errors()
> $s2
> [1] "Command 'as.resource.object(res)' failed on 's2': Error while evaluating 'is.null(base::assign('rse', value={resourcer::as.resource.object(res)}))' -> Error in load(path, envir = private$.env) : \n  bad restore file magic number (file may be corrupted) -- no data loaded\n"

Any opinions were appreciated.

Regards,

Hank

Hi,

It looks like you have declared a RData file although it is a RDS one. Loading a RDS file with load() will fail as reported by the error message. The RDS file needs to be read by readRDS(). These are different data file “resources”.

FYI, this is a test script to validate your resource outside of a context of Datashield + Opal, simpler to debug:

library(resourcer)
x <- installed.packages()
class(x)
saveRDS(x, file = "/tmp/x.rds")
res <- newResource(url = "file:///tmp/x.rds", format = "matrix")
client <- newResourceClient(res)
class(client)
as.resource.object(client)

Another tip for debugging is to verify what is the class of the symbol you have assigned in Datashield with ds.class("res"), it will tell you whether it is the appropriate resource client.

Yannick

Hi Yannick,

ds.class(x = "res", datasources = datasources)
  Aggregated (exists("res")) [===========================================================] 100% / 1s
  Aggregated (classDS("res")) [==========================================================] 100% / 1s
$s2
[1] "RDataFileResourceClient" "FileResourceClient"      "ResourceClient"          "R6"                     

This shows that opal indeed read the data in the format of “rData”. How can I tell opal using another reader?

Regards,

Hank

It’s not Opal that reads the resource, it is the “resourcer” package. In Opal you only see some parameters to build the resource object.

In your case, edit the resource reference in Opal and select Category: Data file and Type: RDS file - Opal, save and try again.

Yannick

Hi Yannick,

I do not have the option of “RDS file - Opal”. My opal is 3.0.3, resourcer is 1.0.1 Is this due to the low version?

Regards, Hank

RDS support was added in resourcer 1.1.0 which is available in the CRAN.

You can install the new version from the Administration > R > Packages page.

Yannick