For Pluto.jl, I’m trying to pass a struct from a module on the main process to a distributed worker (Return a `Rich` object instead of `Dict` for `show_richest` by rikhuijzer · Pull Request #2139 · fonsp/Pluto.jl · GitHub). Currently, this doesn’t work so
NamedTuples are passed. To fix that, the following is a MWE of what I would like to do:
using Distributed: Distributed, @everywhere const Distributed_expr = :( Base.loaded_modules[Base.PkgId(Base.UUID("8ba89e20-285c-5b6f-9357-94700520ee1b"), "Distributed")] ) pid = Distributed.remotecall_eval(Main, 1, quote $(Distributed_expr).addprocs(1) |> first end) module M struct T x::Int end f(x::Int) = T(x) end @everywhere pid using .M t = M.f(1) @info t Distributed.remotecall_eval(Main, [pid], quote @info M.plus_one($t) end)
This gives various errors currently. Anyone knows how to get something like this to work?
The main problem is that, in Pluto, the distributed workers all load
include(...). This works, but when you pass a struct from the main process to a remote worker, then it will fail with errors such as
ERROR: MethodError: no method matching f(::Pluto.PlutoRunner.Rich) Closest candidates are: f(::Main.PlutoRunner.Rich) at REPL:1