Using @everywhere include() from Distributed.jl?

I’ve got a Weave document (.jmd) and I’m using

@everywhere include("./utilities.jl")

There’s an error that says the remote machine is trying to load a file not in the current directory, but the same directory as on my local machine, which doesn’t exist on the remote machine.

documentation for @everywhere macro says:

  Similar to calling remotecall_eval(Main, procs, expr), but with two extra

  - `using` and `import` statements run on the calling process first, to ensure
    packages are precompiled.
  - The current source file path used by `include` is propagated to other processes.

I think the second feature is a misfeature. If I wanted it to read from the same path as on my local computer, I’d send it an absolute path… instead it takes the relative path, converts it to an absolute path, and sends that to the remote machine, which fails since my home directory is not mounted on the remote machine…

What’s the workaround? and should this be a bug?

At the moment, I’m trying to work around with Distributed.remotecall_eval(…) we’ll see how it goes.

From the same documentation, maybe you can try the next.

using Distributed
Distributed.remotecall_eval(Main, procs(), :(include("./utilities.jl")))

My guess is that in HPC environments, i.e. super computers, you would run @everywhere in the cluster as a script and probably all the machines would be configured similarly, including in terms of directories and filesystem structure.

Yes, the remotecall_eval trick sort of worked. It did get the file included, but then things borked because it’s a Weave.jl document… I’ve got a separate post on that topic. Note that remotecall_eval is not exported by Distributed and seems kind of less friendly.

I think the assumption that all machines are configured exactly the same is flawed. At the least it should be possible to override this behavior for include().

You can fill an issue in the JuliaLang repository, I think it would be a nice option.

Ok, I did that

1 Like