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

[RFC] add support for multiple simultaneous progressbars #157

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
13308f8
WIP
MarcMush May 25, 2020
ea86d04
[WIP] working version
MarcMush May 25, 2020
e9e10cf
add test_parallel.jl
MarcMush Jun 25, 2020
5f1bb27
Merge branch 'marc/parallelprogress' into marc/parallel_update
MarcMush Jun 25, 2020
68d4de7
(WIP) add parallel update!
MarcMush Jun 25, 2020
3284c08
first working version
MarcMush Jul 10, 2020
eea66f2
some tidying
MarcMush Aug 12, 2021
7699a87
merge from master
MarcMush Aug 12, 2021
5f2b17c
add parallel support for ProgressTresh and ProgressUnknown
MarcMush Aug 12, 2021
f522aec
add support for no main progressbar in MultipleProgress
MarcMush Aug 12, 2021
f48fb98
fixes
MarcMush Aug 12, 2021
5838982
add tests for MultipleProgress
MarcMush Aug 12, 2021
83123b1
restore tests
MarcMush Aug 12, 2021
fa22215
fixes for julia 0.7
MarcMush Aug 12, 2021
7c64cd2
better error handling and hopefully better codecov
MarcMush Aug 13, 2021
03f8b1c
fix typo
MarcMush Aug 13, 2021
a2a08d9
first working version of multiple progresses from a vector
MarcMush Aug 13, 2021
e90a6a0
on hold
MarcMush Aug 16, 2021
cfa53bc
add support for offset in ProgressUnknown
MarcMush Aug 16, 2021
2c83e23
add support for offset in ProgressUnknown
MarcMush Aug 16, 2021
e27702c
add test for cancel with offset and keep
MarcMush Aug 16, 2021
5023b72
Merge branch 'offsetUnknown' into moremultiple
MarcMush Aug 16, 2021
81608b2
allow any AbstractProgress in MultipleProgress
MarcMush Aug 16, 2021
dac02dd
fixes and doc
MarcMush Aug 16, 2021
191737f
fixes
MarcMush Aug 16, 2021
91a0abf
fix CI hopefully
MarcMush Aug 16, 2021
56827f7
doc changes [skip-ci]
MarcMush Aug 17, 2021
009dd01
merge #216
MarcMush Sep 20, 2021
a5c5b2c
additional sleep time for CI
MarcMush Sep 20, 2021
ce8ff75
fix ParallelProgress example
MarcMush Jun 3, 2023
4cbbf85
change from vector to dict to store and reference progresses
MarcMush Aug 31, 2023
c6721e4
add a test with dicts
MarcMush Aug 31, 2023
5323a17
Merge branch 'master' of https://github.com/timholy/ProgressMeter.jl.…
MarcMush Aug 31, 2023
99df291
add tests for main key error
MarcMush Aug 31, 2023
be0826a
add test for duplicate key
MarcMush Aug 31, 2023
f9ba27a
tweak test
MarcMush Aug 31, 2023
5437ce6
0.7 compat
MarcMush Aug 31, 2023
74f3b95
update README.md
MarcMush Sep 2, 2023
d8977ef
improve codecov
MarcMush Sep 3, 2023
639bceb
fix tests
MarcMush Sep 3, 2023
9a1df84
tests
MarcMush Sep 3, 2023
69b13a1
fix
MarcMush Sep 3, 2023
3156d04
Merge branch 'master'
MarcMush Oct 22, 2023
4330155
Merge branch 'master' into parallelprogress
MarcMush Jul 12, 2024
7094dd3
way too many changes for one commit
MarcMush Jul 13, 2024
5c21f5d
update readme
MarcMush Jul 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/ProgressMeter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ module ProgressMeter
using Printf: @sprintf
using Distributed

export Progress, ProgressThresh, ProgressUnknown, BarGlyphs, next!, update!, cancel, finish!, @showprogress, progress_map, progress_pmap, ijulia_behavior
export Progress, ProgressThresh, ProgressUnknown, BarGlyphs, next!, update!, cancel,
finish!, @showprogress, progress_map, progress_pmap, ijulia_behavior,
MultipleProgress, ParallelProgress, addprogress!

"""
`ProgressMeter` contains a suite of utilities for displaying progress
Expand Down Expand Up @@ -192,19 +194,28 @@ mutable struct ProgressUnknown <: AbstractProgress
spinner::Bool # show a spinner
output::IO # output stream into which the progress is written
numprintedvalues::Int # num values printed below progress in last iteration
offset::Int # position offset of progress bar (default is 0)
enabled::Bool # is the output enabled
showspeed::Bool # should the output include average time per iteration
check_iterations::Int
prev_update_count::Int
threads_used::Vector{Int}
end

function ProgressUnknown(;dt::Real=0.1, desc::AbstractString="Progress: ", color::Symbol=:green, spinner::Bool=false, output::IO=stderr, enabled::Bool = true, showspeed::Bool = false)
function ProgressUnknown(;
dt::Real=0.1,
desc::AbstractString="Progress: ",
color::Symbol=:green,
spinner::Bool=false,
output::IO=stderr,
offset::Integer=0,
enabled::Bool = true,
showspeed::Bool = false)
CLEAR_IJULIA[] = clear_ijulia()
reentrantlocker = Threads.ReentrantLock()
tinit = tlast = time()
printed = false
ProgressUnknown(false, reentrantlocker, dt, 0, 0, false, tinit, tlast, printed, desc, color, spinner, output, 0, enabled, showspeed, 1, 1, Int[])
ProgressUnknown(false, reentrantlocker, dt, 0, 0, false, tinit, tlast, printed, desc, color, spinner, output, 0, offset, enabled, showspeed, 1, 1, Int[])
end

ProgressUnknown(dt::Real, desc::AbstractString="Progress: ",
Expand Down Expand Up @@ -398,9 +409,12 @@ spinner_char(p::ProgressUnknown, spinner::AbstractVector{<:AbstractChar}) =
spinner_char(p::ProgressUnknown, spinner::AbstractString) =
p.done ? spinner_done : spinner[nextind(spinner, 1, p.spincounter % length(spinner))]

function updateProgress!(p::ProgressUnknown; showvalues = (), truncate_lines = false, valuecolor = :blue, desc = p.desc,
ignore_predictor = false, spinner::Union{AbstractChar,AbstractString,AbstractVector{<:AbstractChar}} = spinner_chars)
function updateProgress!(p::ProgressUnknown; showvalues = (), truncate_lines = false,
valuecolor = :blue, desc = p.desc, ignore_predictor = false,
spinner::Union{AbstractChar,AbstractString,AbstractVector{<:AbstractChar}} = spinner_chars,
offset::Integer = p.offset, keep = (offset == 0))
!p.enabled && return
p.offset = offset
p.desc = desc
if p.done
if p.printed
Expand All @@ -417,10 +431,15 @@ function updateProgress!(p::ProgressUnknown; showvalues = (), truncate_lines = f
sec_per_iter = elapsed_time / p.counter
msg = @sprintf "%s (%s)" msg speedstring(sec_per_iter)
end
print(p.output, "\n" ^ (p.offset + p.numprintedvalues))
move_cursor_up_while_clearing_lines(p.output, p.numprintedvalues)
printover(p.output, msg, p.color)
printvalues!(p, showvalues; color = valuecolor, truncate = truncate_lines)
println(p.output)
if keep
println(p.output)
else
print(p.output, "\r\u1b[A" ^ (p.offset + p.numprintedvalues))
end
flush(p.output)
end
return
Expand All @@ -443,9 +462,11 @@ function updateProgress!(p::ProgressUnknown; showvalues = (), truncate_lines = f
sec_per_iter = elapsed_time / p.counter
msg = @sprintf "%s (%s)" msg speedstring(sec_per_iter)
end
print(p.output, "\n" ^ (p.offset + p.numprintedvalues))
move_cursor_up_while_clearing_lines(p.output, p.numprintedvalues)
printover(p.output, msg, p.color)
printvalues!(p, showvalues; color = valuecolor, truncate = truncate_lines)
print(p.output, "\r\u1b[A" ^ (p.offset + p.numprintedvalues))
flush(p.output)
# Compensate for any overhead of printing. This can be
# especially important if you're running over a slow network
Expand Down Expand Up @@ -1045,4 +1066,6 @@ function ncalls(mapfun::Function, map_args)
end
end

include("parallel_progress.jl")

end
Loading