@@ -14,11 +14,11 @@ import FileIO
14
14
function checkexceptions (x:: Any , t:: Type = Any, args... )
15
15
for i in eachindex (x)
16
16
if isa (x[i], Exception)
17
- @error (" Execution failed for one of the runs (run # $(i) ) with exception error $(typeof (x[i])) !" )
17
+ @error (" Execution failed for one of the runs (run $(i) out of $( length (x) ) ) with exception error $(typeof (x[i])) !" )
18
18
@error (" Failing input parameter set: $(args[1 ][i]) " )
19
- throw (TypeError ( :RobustPmap , t, x[i]))
19
+ throw (ErrorException ( " Run failed with exception error $( typeof ( x[i])) ! " ))
20
20
elseif ! isa (x[i], t)
21
- @error (" Execution failed for one of the runs (run # $(i) ) " )
21
+ @error (" Execution failed for one of the runs (run $(i) out of $( length (x)) ) producing an expected output of type $( typeof (x[i])) ! " )
22
22
@error (" Failing input parameter set: $(args[1 ][i]) " )
23
23
throw (TypeError (:RobustPmap , t, x[i]))
24
24
end
@@ -27,14 +27,14 @@ function checkexceptions(x::Any, t::Type=Any, args...)
27
27
end
28
28
29
29
" Robust pmap call"
30
- function rpmap (f:: Function , args... ; t:: Type = Any)
30
+ function rpmap (f:: Function , args... ; t:: Type = Any, checkoutputs :: Bool = true )
31
31
x = Distributed. pmap (f, args... ; on_error= x-> x)
32
- checkexceptions (x, t, args... )
33
- return convert (Vector {t}, x)
32
+ checkoutputs && checkexceptions (x, t, args... )
33
+ return convert (Array {t}, x) # x can be either a matrix or vector
34
34
end
35
35
36
36
" Robust pmap call with checkpoints"
37
- function crpmap (f:: Function , checkpointfrequency:: Int , filerootname:: AbstractString , args... ; t:: Type = Any)
37
+ function crpmap (f:: Function , checkpointfrequency:: Int , filerootname:: AbstractString , args... ; t:: Type = Any, checkoutputs :: Bool = true )
38
38
fullresult = t[]
39
39
hashargs = hash (args)
40
40
if checkpointfrequency <= 0
@@ -47,7 +47,7 @@ function crpmap(f::Function, checkpointfrequency::Int, filerootname::AbstractStr
47
47
if isfile (filename)
48
48
partialresult = FileIO. load (filename, " partialresult" )
49
49
else
50
- partialresult = rpmap (f, map (x-> x[r], args)... ; t= t)
50
+ partialresult = rpmap (f, map (x-> x[r], args)... ; t= t, checkoutputs = checkoutputs )
51
51
FileIO. save (filename, " partialresult" , partialresult)
52
52
end
53
53
append! (fullresult, partialresult)
0 commit comments