Skip to content

[Bioc-devel] mclapply and Vector objects

9 messages · Hahne, Florian, Michael Lawrence, Vincent Carey +2 more

#
Would it be possible to make mclapply aware of the Vector class?
Currently, the following line causes them to be coerced into a regular
list which could be rather expensive for instance in the case of
GrangesLists:
if (!is.vector(X) || is.object(X))
        X <- as.list(X)


I guess something like
if ((!is.vector(X) && !is(X, "Vector")) || is.object(X))
        X <- as.list(X)
would do the trick.

Or am I missing something obvious here?
Cheers,
Florian
#
Michael, I'm close to presenting something that i think will address all concerns, and am review this small flurry of emails to make sure. 

Would you please give me a quick explanation of that the above 'trick' accomplishes.  I'm still knocking around R's OO frameworks.

Also...
mclapply currently returns a vector of individual error messages as value if any process.  Are you suggesting perhaps mclapply should, in such cases, instead of warn, rather `stop` with a condition (batchCondition ), providing as additional attributes to the condition the vector conditions (try-errors) returned from each process.

If so, yeah, yeah, I like.... sounds great.... but would be a change in behaviour to mclapply.... though probably an improvement that no-one would object to.  

What we have now, like this:

x<-try(mclapply(1:5,simpleError('Hey!'),mc.silent=TRUE))
Warning message:
In mclapply(1:5, stop, simpleError("Hey!"), mc.silent = TRUE) :
  all scheduled cores encountered errors in user code
[1] "list"
[1] "character"
[1] "Error in lapply(X=S, FUN=FUN,...) : 1 Error: I warned You\n\n"



Instead, we are saying, mclapply should raise a batchError which would have as an attribute each individual core's simpleError, say, 'jobCondition'

What could be simpler?

It would then look like this:

x<-try(mclapply(1:5,simpleError('Hey!'),mc.silent=TRUE))
Error:
In x<-try(mclapply(1:5,simpleError('Hey!'),mc.silent=TRUE))
  all scheduled cores encountered errors in user code
[1] "batchError" "simpleError" "error" "condition"
[1] Error:
In mclapply(1:5, stop, simpleError("Hey!"), mc.silent = TRUE) :
  all scheduled cores encountered errors in user code
attr(,"class")
[1] "batchError" "simpleError" "error" "condition"
attr(,"condition")
<batchError  all scheduled cores encountered errors in user code>
attr(,"jobCondition")
		[,1]	[,2]	[,3]	[,4]	[,5]
jobid		1	2	3	4	5
message	Hey!	Hey!	Hey!	Hey!	Hey!
call		NULL	NULL	NULL	NULL	NULL


This would be sweet and simple.


~Malcolm
1 day later