Unexpected R server error?

I’ve got a odd error message when I tried to execute ds.assign(toAssign = 'D$TOTAL_8AM*5', newobj="var1"):

Command 'D$TOTAL_8AM*5' failed on 'SERVER.A': Unexpected R server error: eval failed, request status: R parser: syntax error

I can run some basic functions like ds.dim, ds.mean, ds.histogram, but once I try to run ds.assign or other assign functions like ds.asCharacter I get that error. Stranger still, all the functions which worked up until then no longer execute properly, R just runs indefinitely until I interrupt it, if I run the login command again those functions work once more.

I’ve tried using ds.assign whilst signed into the training servers and that works fine, that error message only turns up on my own servers.

Has anyone encountered this before?

Hi Jack,

My guess is that the number 8 at that specific place of the name of the variable causes this issue. Have you tried to upload the variable in your servers with a different name? e.g. call it “TOTAL_eightAM” just to check.

Thanks for the suggestion but I have the same variable on the training servers and it worked fine there. That error comes up when ds.assign is used on anything really.

Jack,

May I ask, which version of DataSHIELD are you using?

Stuart

dsBaseClient v6.0.1

DSI v1.1.0

DSOpal v1.1.0

Jack,

I am trying to reproduce the issue you are seeing, but no luck so far. I has been suggested to try:

  • Move the ‘*5’ to the start of the expression, e.g. ‘5*D$TOTAL_8AM’
  • Try first assigning ‘D$TOTAL_8AM’ to a root variable (not with D), without the “_8”.

Stuart

Hi Stuart,

I’ve tried your suggestions but I’m still stuck with that error. I would stress that the exact same code works when I’m signed into the training servers so I’m confident that the my toAssign value is valid. I’ll update this question if I find a solution.

Cheers,

Jack

For anyone interested in this topic, I’ve found a solution. I needed to terminate several R sessions which had failed to close, as the terminate action in Opal was not functioning it was necessary to revert back to a earlier snapshot of the server. I believe the problem started when I added a new assign method which I called is_in, this was an R script I defined as:

function(x, v){

y = ifelse(x %in% v, 1, 0)

return(y)

}

It may have been a mistake to use a newline in the script box. I ran the command

subset(ds.listServersideFunctions()$serverside.assign.functions, is.na(package))

and the value appeared as

function(x, v){\ny = ifelse(x %in% v, 1, 0)\nreturn(y)\n}

perhaps this was the cause of R parser: syntax error. I think this error prevented my R sessions from terminating properly.

Hi,

I have added your is_in function code (with the newlines, both as an aggregate and assign functions) on the opal-demo server and the following DS code is working as expected:

library(DSOpal)
builder <- newDSLoginBuilder()
builder$append(server = "study1", url = "https://opal-demo.obiba.org", user = "administrator", password = "password", table = "CNSIM.CNSIM1", driver = "OpalDriver")
logindata <- builder$build()

conns <- datashield.login(logins = logindata, assign = T)

subset(datashield.methods(conns, type = "aggregate"), is.na(package))
datashield.aggregate(conns, quote(is_in(2, D$GENDER)))

subset(datashield.methods(conns, type = "assign"), is.na(package))
datashield.assign(conns, symbol = "x", quote(is_in(2, D$GENDER)))

datashield.logout(conns)

Using newlines in the function’s R script is valid. Have a look at your R server’s log file (can be downloaded from Opal at Administration > R page), if there are any R errors reported.

Yannick

1 Like

Hum… correction, sometimes it works, sometimes it does not and the R server breaks… I am going to check.

I guess you’re right about the newline; I’ve tried looking in the logs but I don’t see anything that could illuminate the problem. In any case, however the issue first arose, reverting to an earlier snapshot certainly fixed it.

Now it works… The problem was that while trying to reproduce Patricia’s problem, I pasted her R script as-is and I got “R parser: syntax error”. It happens that if you look carefully, her script contains windows weird quotes:


> subset(datashield.methods(conns, type = "aggregate"), is.na(package))
           name      type  class                                                          value package version server
1  DANGER_Error aggregate script                    function() {\n  stop(“SERVER::ERR:0001”)\n}    <NA>    <NA> study1
36        is_in aggregate script function(x, v) {\n  y = ifelse(x %in% v, 1, 0)\n  return(y)\n}    <NA>    <NA> study1

Those non-ascii quotes are not supported, it makes the R parser error. I replaced them by the ascii’s double quotes " and it works.

Note that when calling for a custom R function, all the custom R functions are applied to the R server session environment (because one function could call another one). Then despite the function called is correct, another one could be wrong.

Yannick

1 Like