CDK-R / cdkr

Integrating R and the CDK
https://cdk-r.github.io/cdkr/
42 stars 27 forks source link

eval.desc fails with parLapply #30

Closed stanstrup closed 8 years ago

stanstrup commented 8 years ago

Following the example for "eval.desc"

smiles <- c('CCC', 'c1ccccc1', 'CC(=O)C')
mols <- sapply(smiles, parse.smiles)

dnames <- get.desc.names('topological')
descs <- eval.desc(mols, dnames, verbose=TRUE)

you can do

lapply(dnames,function(x){ require(rcdk); eval.desc(mols, x, verbose=FALSE)})

which works but this

cl <- makeCluster(detectCores()-1)
clusterExport(cl, "mols")
rcdk_desc <- parLapply(cl,dnames,function(x){ require(rcdk); eval.desc(mols, x, verbose=FALSE)})
stopCluster(cl)

fails with

Error in checkForRemoteErrors(val) : 
  3 nodes produced errors; first error: java.lang.NullPointerException

Applying over "mols" instead of "dnames" does not produce an error but all are NA.

I realize this is probably some java/parallel interaction but do you have any idea of a workaround?

rajarshi commented 8 years ago

Unfortunately, the CDK is not threadsafe (at least the version that is used in rcdk), so running it in parallel leads to all sorts of errors and is not advised.

egonw commented 5 years ago

It actually gives NAs no matter what... even for things where threadsafety should not matter (like molecular weight...)...