Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showprogress setting #59

Open
carstenbauer opened this issue Feb 28, 2024 · 3 comments
Open

showprogress setting #59

carstenbauer opened this issue Feb 28, 2024 · 3 comments

Comments

@carstenbauer
Copy link
Member

https://github.com/timholy/ProgressMeter.jl is essentially thread safe.

@carstenbauer
Copy link
Member Author

carstenbauer commented Mar 1, 2024

Brainstorming further, this could maybe be a Pkg extension: On loading ProgressMeter.jl we enable setting an option showprogress=true which automatically calls next! for each task/iteration.

p = Progress(100);
tforeach(1:100) do i
    sleep(rand())
    next!(p)
end

Of course, people could always do this themselves, especially if they have to load ProgressMeter manually anyways.

@MasonProtter
Copy link
Member

We could open a PR with ProgressMeter.jl to fix their implementation of @showprogress to make it extensible.

Currently, they detect just based on the AST if the mapping function is allowed:

julia> @macroexpand @showprogress map(f, 1:10)
:(ProgressMeter.progress_map(f, 1:10, progress = ProgressMeter.Progress(ProgressMeter.ncalls(map, (f, 1:10))), mapfun = map))

julia> @macroexpand @showprogress tmap(f, 1:10)
ERROR: ArgumentError: Final argument to @showprogress must be a for loop, comprehension, map, reduce, or pmap; got tmap(f, 1:10)
Stacktrace:

This really should instead be checked when the types are known, not during macroexpansion I think.

@carstenbauer
Copy link
Member Author

Sounds like a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants