parLapply is unable to call a function in a custom package using clusterExport(cl, "func")
.
func <- function(x) {
output <- myPkg::myFunc(
file = x,
path = "/local/path"
)
output
}
vector = c("file1", "file2")
cluster <- makeCluster(10)
clusterEvalQ(cluster, library(myPkg))
clusterExport(cluster, "func")
parLapply(cluster, vector, func)
parLapply
reports
Error in checkForRemoteErrors(val) :
2 nodes produced errors; first error: argument “func” is missing, with no default
Note that “myFunc” replies on many other functions in the custom package, although I would think clusterEvalQ
would pick them up without exporting to the cluster.