Iβm using Julia 1.0.3. How do I get JuliaDB with work with parallel procs? When I run the below code I get an error that the package is not available on worker 2.
Code:
using Distributed
while length(procs()) < 2
addprocs(1) # add worker processes
end
@everywhere using JuliaDB
const jobs = RemoteChannel(()->Channel{Int}(32))
const results = RemoteChannel(()->Channel{Tuple}(32))
#set local variables
n = 1
@everywhere function do_work(jobs, results) # define work function everywhere
while true
job_id = take!(jobs)
exec_time = rand()
sleep(exec_time) # simulates elapsed time doing actual work
put!(results, (job_id, exec_time, myid()))
#########################################################
#########################################################
#load file
tblDT = loadtable("C:/JL/New_Test/DT_INT.csv",indexcols=[1,2])
#########################################################
#########################################################
end
end
function make_jobs(n)
for i in 1:n
put!(jobs, i)
println("make jobs ",i)
end
end
@async make_jobs(n) # feed the jobs channel with "n" jobs
for p in workers() # start tasks on the workers to process requests in parallel
remote_do(do_work, p, jobs, results)
println("p workers ",p)
end
@elapsed while n > 0 # print out results
job_id, exec_time, where = take!(results)
println("$job_id finished in $(round(exec_time; digits=2)) seconds on worker $where")
global n = n - 1
end
Error Message:
ERROR: LoadError: On worker 2:
ArgumentError: Package JuliaDB not found in current path:
- Run `import Pkg; Pkg.add("JuliaDB")` to install the JuliaDB package.
require at .\loading.jl:823
eval at .\boot.jl:319
#116 at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\process_messages.jl:276
run_work_thunk at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\process_messages.jl:56
run_work_thunk at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\process_messages.jl:65
#102 at .\task.jl:259
#remotecall_wait#154(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Distributed.Worker, ::Module, ::Varar{Any,N} where N) at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\remotecall.jl:421
remotecall_wait(::Function, ::Distributed.Worker, ::Module, ::Vararg{Any,N} where N) at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Disributed\src\remotecall.jl:412
#remotecall_wait#157(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function, ::Int64, ::Module, ::Vararg{Any,N} wher N) at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\remotecall.jl:433
remotecall_wait(::Function, ::Int64, ::Module, ::Vararg{Any,N} where N) at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\emotecall.jl:433
(::getfield(Distributed, Symbol("##163#165")){Module,Expr})() at .\task.jl:259
...and 1 more exception(s).
Stacktrace:
[1] sync_end(::Array{Any,1}) at .\task.jl:226
[2] macro expansion at .\task.jl:245 [inlined]
[3] remotecall_eval(::Module, ::Array{Int64,1}, ::Expr) at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\macros.jl:206
[4] top-level scope at C:\Users\julia\AppData\Local\Julia-1.0.3\share\julia\stdlib\v1.0\Distributed\src\macros.jl:190
in expression starting at C:\JL\MultiThreads0001.jl:7