Thanks for the answers!
I am trying to load some files on all workers, but I am not sure how to do it properly.
Considering the example in the first post, I changed the contents of ParallelTest.jl
to:
__precompile__(false)
module ParallelTest
using Distributed
@everywhere using Pkg
@everywhere Pkg.activate(".")
@everywhere include("$(@__DIR__)/parallel.jl")
@everywhere using .PMod
greet() = print("Hello World!")
end # module
and added another file parallel.jl
in the src
directory containting:
module PMod
println("loaded")
end # module PMod
I managed to load the module successfully, but I get redefinition warnings for the module loaded in parallel.
(v0.7) pkg> activate .
julia> using Distributed
julia> addprocs(2)
2-element Array{Int64,1}:
2
3
julia> using ParallelTest
[ Info: Precompiling ParallelTest [0e712700-ac5e-11e8-3696-ef47f8f04c4e]
loaded
From worker 3: loaded
From worker 2: loaded
From worker 2: WARNING: replacing module PMod.
WARNING: replacing module PMod.
From worker 2: loadedWARNING: replacing module PMod.
From worker 3: WARNING: replacing module PMod.
loaded
loaded
From worker 2: WARNING: replacing module PMod.
From worker 2: loaded
From worker 3: loaded
From worker 3: WARNING: replacing module PMod.
From worker 3: loaded
I also tried to use using .PMod
instead of @everywhere using .PMod
, but I get a LoadError
saying that PMod
is not defined. I think that the problem is that on the workers it’s in the global scope, while on the master process is inside a module.