Skip to content

Error in checkForRemoteErrors(val) with sfClusterApplyLB()

2 messages · Marine Regis, Roger Bivand

#
Hello,



I'm trying to run a code that uses the snowfall package. Here is the structure of my code.



sfInit(parallel=T, cpus = 5, slaveOutfile="ErrorMessage.txt")

sfExportAll()

sfLibrary(rgdal)

sfLibrary(raster)

sfLibrary(sp)

sfLibrary(rgeos)

sfLibrary(snowfall)



system.time( sfClusterApplyLB(1:10, function(k) {

  sfCat(paste("Iteration ", k), sep="\n")

if (......) {

} else {

if (class(ob1)=="SpatialCollections") {

        ob2 <- ob1 at lineobj

      } else if (class(ob1)=="SpatialLines") {

        ob2 <- ob1

      }

ob3 <- data.frame(length_m=sapply(1:length(ob2), function(l) gLength(ob2 [l, ])))

.....

}

.....

}

sfStop()



The problem is that the code returns the error message:

Error in checkForRemoteErrors(val) :

  one node produced an error: object 'ob2' not found
Warning messages:

1: In searchCommandline(parallel, cpus = cpus, type = type, socketHosts = socketHosts,  :

  Unknown option on commandline: --file

2: In searchCommandline(parallel, cpus = cpus, type = type, socketHosts = socketHosts,  :

  Unknown option on commandline: MASTER

3: In searchCommandline(parallel, cpus = cpus, type = type, socketHosts = socketHosts,  :

  Unknown option on commandline: PORT

4: In searchCommandline(parallel, cpus = cpus, type = type, socketHosts = socketHosts,  :

  Unknown option on commandline: OUT

5: In searchCommandline(parallel, cpus = cpus, type = type, socketHosts = socketHosts,  :

  Unknown option on commandline: SNOWLIB

 socketHosts,  :

  Unknown option on commandline: SNOWLIB

tion on commandline: SNOWLIB


The code works when I use a simple loop for(k in 1:10) {} instead of sfClusterApplyLB(1:10, function(k) {}.



Why do I obtain this error message ? I am completely novice in using snowfall package. So any advices are appreciated.



Thanks a lot for your time.


Marine
#
On Thu, 28 Apr 2016, Marine Regis wrote:

            
Avoid snowfall unless you know that the code runs in general. The problem 
seems to be with your if conditions - you assume that ob1 is either a 
SpatialCollections object and has a lineobj slot, or that ob1 is a 
SpatialLines object, in both cases yielding ob2 as a SpatialLines object.

You do not check that ob1 is neither SpatialLines nor SpatialCollections, 
or if SpatialCollections that it has a lineobj slot. You need a further 
step where ob2 is initialised as NULL, and tested after the attempts to 
assign lines, branching on is.null(ob2).

Your data are likely not the same as those of the authors of the code you 
are trying to run, and they didn't write to take account of situations 
they didn't encounter.

Roger