JuliaLogging / ProgressLogging.jl

MIT License
50 stars 8 forks source link

Support for parallel maps? #29

Closed juliohm closed 4 years ago

juliohm commented 4 years ago

I am considering the package for a simulation script. Does it already support parallel maps like the progress_pmap function from ProgressMeter.jl?

tkf commented 4 years ago

There is https://juliafolds.github.io/Transducers.jl/dev/manual/#Transducers.withprogress

using Transducers
tcollect(Map(f), withprogress(xs))

or equivalently

using ThreadsX
ThreadsX.map(f, withprogress(xs))

might work. withprogress is also usable with Distributed.jl:

using Transducers
dcollect(Map(f), withprogress(xs))

They use ProgressLogging behind the scene.

juliohm commented 4 years ago

Nice, I should be using Transducers.jl instead of the lower level packages then. Is there a way to print variables in the loop with dcollect(Map(f), withprogress(xs))?

tkf commented 4 years ago

You can put Map(x -> (@show(x); x)) anywhere in the transducer chain. Like

dcollect(Map(x -> (@show(x); x)) |> Filter(p) |> Map(f), withprogress(xs))
juliohm commented 4 years ago

Nice, will try to rewrite my scripts accordingly. :)