Is there a way to transfer a module definition to a worker without it being defined in a file or inside an @everywhere
expression.
For example:
# Assume this happens in a context where it would be impractical to insert an @everywhere
julia> module A
export f
f() = 1
end
A
julia> using Distributed
julia> addprocs(1)
1-element Vector{Int64}:
2
julia> @everywhere using .A
ERROR: On worker 2:
UndefVarError: `A` not defined
julia> Distributed.remotecall_eval(Main, 2, :(using $A))
ERROR: On worker 2:
UndefVarError: `A` not defined
julia> remotecall_fetch(2, A) do m
using m
end
ERROR: syntax: "using" expression not at top level
The reason why I want this has to do with interfacing with an existing tool which I don’t have the power to change.
I can probably work in the @everywhere
before the module definition somehow if that is the only way.