Code loading with workers and modules

I’m a bit lost on how to load code into worker processes. I’m getting the error:

KeyError: key [mypackagename] [502b64d0-c436-11e9-3033-a3ceb19233e3] not found

This is resulting from a pmap call inside a function in an unregistered package, and the function running in parallel needs to refer to the package.

The environment of the master process is not passed to the workers. The recommended workaround in this situation is to use the JULIA_PROJECT environment variable, or to use --project in exeflags when creating the workers.

1 Like

Okay so addprocs(exeflags="--project"). Thanks!

Hmm, that didn’t work.

Did you try @everywhere include(“your_package.jl”) and @everywhere using .your_package ?
“your_package.jl” should include inside it all the other files needed for your package.

1 Like

I do

using Distributed
@everywhere begin
	using Pkg
	Pkg.activate(".")
	Pkg.instantiate()
end
3 Likes

Should probably read addprocs(exeflags="--project=.") I am guessing.

1 Like

Thanks all!

I ended up with

currentworkers = addprocs(exeflags="--project")
@everywhere using <modulename>