New to Julia Distribution and I have a question about pmap usage particularly as to it’s return value.
I have two functions I am calling with pmap. One is written to return a simple string value, the otherreturns a struct. Both appear to be working but both are returning “Any”.
The following is from the script I am running from my OSX laptop. My worker is Ubuntu 18.04. I’ll show the string return for now. Likely, the struct problem is similar.
#!/usr/bin/env julia
using Distributed
workers = ["haz@uno"]
@everywhere module Encounters
function createT()
return "Tccd"
end
end
T = pmap(Encounters.createT, [])
println(typeof(T))
Apologies, in my zeal to post the above, I missed the call to addprocs in my sloppy cut and paste. See the new improved below:
#!/usr/bin/env julia
using Distributed
workers = ["haz@uno"]
addprocs(workers; tunnel=true, exename=`julia`, dir="/home/haz", sshflags=`-p 2222`)`
@everywhere module Encounters
function createT()
return "Tccd"
end
end
T = pmap(Encounters.createT, [])
println(typeof(T))
julia> using Distributed
julia> addprocs(2);
julia> @everywhere module Encounters
function createT(x) # here you need a parameter
return "Tccd"
end
end
julia> @everywhere using .Encounters
julia> T = pmap(Encounters.createT, [1,2,3])
3-element Array{String,1}:
"Tccd"
"Tccd"
"Tccd"
help?> pmap
search: pmap promote_shape proportionmap typemax corspearman PermutedDimsArray
pmap(f, [::AbstractWorkerPool], c...; distributed=true, batch_size=1, on_error=nothing, retry_delays=[], retry_check=nothing) -> collection
Transform collection c by applying f to each element using available workers
and tasks.
you cannot apply f to each element if it is parameterless.