Running a @distributed for loop on a zipped variable fails?

Hi,

I’m trying to loop over a combination of parameters (N, f, o), and each iteration is also identified using an index (i). The code below works, but fails when using distributed with a bunch of cryptic error messages (see below).

Any idea how can I fix this?

Thanks!

│   f_rate_list = [0.005, 0.01, 0.05, 0.1, 0.5, 1.0]
│   o_rate_list = [5.0, 10.0, 50.0, 100.0]
│   N_reactor_list = [4, 9, 16, 25]
│   current_sim = 26040
│   params = [(N,f,o) for N in N_reactors_list, f in f_rate_list, o in o_rate_list]
│   nparams = length(params)
│   iis = range(0,nparams)
│   all_params = zip(params,iis)
│   i=0
│   for p in all_params # this works
│   │   N = p[1][1]
│   │   f = p[1][2]
│   │   o = p[1][3]
│   │   i = p[2]
│   │   println("N=$N f=$f o=$o i=$i")
│   end
│   @sync @distributed for p in all_params # this fails
│   │   N = p[1][1]
│   │   f = p[1][2]
│   │   o = p[1][3]
│   │   i = p[2]
│   │   println("N=$N f=$f o=$o i=$i")
│   end

Error messages:

Unhandled Task ERROR: MethodError: no method matching firstindex(::Base.Iterators.Zip{Tuple{Array{Tuple{Int64, Float64, Float64}, 3}, UnitRange{Int64}}})

Closest candidates are:
  firstindex(::Any, ::Any)
   @ Base abstractarray.jl:447
  firstindex(::Markdown.MD)
   @ Markdown ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Markdown/src/parse/parse.jl:27
  firstindex(::LaTeXStrings.LaTeXString)
   @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:108
  ...

Stacktrace:
 [1] macro expansion
   @ ./task.jl:479 [inlined]
 [2] (::Distributed.var"#177#179"{var"#77#79"{Int64}, Base.Iterators.Zip{Tuple{Array{Tuple{Int64, Float64, Float64}, 3}, UnitRange{Int64}}}})()
   @ Distributed ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Distributed/src/macros.jl:278
ERROR: LoadError: TaskFailedException

    nested task error: MethodError: no method matching firstindex(::Base.Iterators.Zip{Tuple{Array{Tuple{Int64, Float64, Float64}, 3}, UnitRange{Int64}}})

    Closest candidates are:
      firstindex(::Any, ::Any)
       @ Base abstractarray.jl:447
      firstindex(::Markdown.MD)
       @ Markdown ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Markdown/src/parse/parse.jl:27
      firstindex(::LaTeXStrings.LaTeXString)
       @ LaTeXStrings ~/.julia/packages/LaTeXStrings/ZtSdh/src/LaTeXStrings.jl:108
      ...

    Stacktrace:
     [1] macro expansion
       @ ./task.jl:479 [inlined]
     [2] (::Distributed.var"#177#179"{var"#77#79"{Int64}, Base.Iterators.Zip{Tuple{Array{Tuple{Int64, Float64, Float64}, 3}, UnitRange{Int64}}}})()
       @ Distributed ~/.julia/juliaup/julia-1.10.0+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Distributed/src/macros.jl:278
Stacktrace:
 [1] sync_end(c::Channel{Any})
   @ Base ./task.jl:448
 [2] macro expansion
   @ ./task.jl:480 [inlined]
 [3] run_line_reactions_new(N_reactors_list::Vector{Int64}, f_rate_list::Vector{Float64}, o_rate_list::Vector{Float64}, current_sim::Int64)
   @ Main ~/Desktop/flow-complexity/scripts/explore-test.jl:51
 [4] run_all_topologies()
   @ Main ~/Desktop/flow-complexity/scripts/explore-test.jl:81
 [5] top-level scope
   @ ~/Desktop/flow-complexity/scripts/explore-test.jl:90
in expression starting at /Users/alexandre/Desktop/flow-complexity/scripts/explore-test.jl:90

You might need to collect the zip iterator before proceeding.