Term.jl icon indicating copy to clipboard operation
Term.jl copied to clipboard

ProgressBar Issues

Open nathanrboyer opened this issue 2 years ago • 4 comments

MWE: Adjust inputs to slightly strain your machine. I am running in VSCode for Windows.

using GLMakie, Term, Term.Progress

f1(x) = for i in 1:x; println(i); end; sleep(4)
f2(x) = collect(1:x)
f3(x) = lines(1:x, 1:x)

function main(x, y, z)
    progressbar = ProgressBar(; columns=:minimal, columns_kwargs = Dict(:SpinnerColumn => Dict(:spinnertype => :circle)))
    output = with(progressbar) do
        job1 = addjob!(progressbar, description = "Running Function 1")
        start!(job1)
        yield()
        sleep(0.001)
        f1(x)
        stop!(job1)

        job2 = addjob!(progressbar, description = "Running Function 2")
        start!(job2)
        yield()
        sleep(0.001)
        f2(y)
        stop!(job2)

        job3 = addjob!(progressbar, description = "Running Function 3")
        start!(job3)
        yield()
        sleep(0.001)
        f3(z)
        stop!(job3)

        "Output"
    end
    return output
end

main(40, 1E9, 1E5)
  1. job1 spinner appears but does not spin.
  2. job1 checkmark does not appear until both job1 and job2 are complete.
  3. job2 spinner does not appear. The text and checkmark only appear once finished.
  4. job3 does not appear at all including text, spinner, and checkmark.
  5. The output text lines above the top of the REPL window are deleted.
  6. output does not appear.

Same behavior whether I use yield() or sleep(0.001). image

nathanrboyer avatar Jun 21 '22 17:06 nathanrboyer

working on it: https://github.com/FedeClaudi/Term.jl/pull/124

FedeClaudi avatar Jun 22 '22 08:06 FedeClaudi

Hi,

Sorry for the delay in getting back to you. There were a few issues with threading and the timing between when jobs were stopped and the progress bar display updated. It works fine in the development branch with this code:

using Term, Term.Progress

f1(x) = for i in 1:x; println(i); end; sleep(0)
f2(x) = collect(1:x)
f3(x) = collect(1:x).^2

function main(x, y, z)
    progressbar = ProgressBar(; columns=:minimal,  columns_kwargs = Dict(:SpinnerColumn => Dict(:spinnertype => :circle)))
    output = with(progressbar) do
        job1 = addjob!(progressbar, description = "Running Function 1")
        f1(x)
        stop!(job1)

        job2 = addjob!(progressbar, description = "Running Function 2")
        f2(y)
        stop!(job2)

        job3 = addjob!(progressbar, description = "Running Function 3")
        f3(z)
        stop!(job3)

        "Output"
        println("Output2")
    end
    return output
end




main(50, 1E9, 1E5)

https://user-images.githubusercontent.com/17436313/182002672-13501e69-8f8e-4f29-9314-9eedf13ff8f7.mov

I think don't understand 5: if I say call f1 with x=100 so that a few lines are scrolled above the terminal's height, I can scroll back up and find them. For issue 6, that was a bug due to a typo, will be fixed in the next release

FedeClaudi avatar Jul 30 '22 22:07 FedeClaudi

Great, thanks. I think issue #5 I was having is not a term issue.

nathanrboyer avatar Jul 31 '22 01:07 nathanrboyer

I still get the same behavior described in my first post on the master branch.

With your code on the 1.0.3 branch, I get the following static steps: image image image

With my code on the 1.0.3 branch, I get the following static steps: image image image

There is no spinning at any point and my terminal text is still cut off when I scroll back up: image

nathanrboyer avatar Aug 04 '22 17:08 nathanrboyer

I'll close this for now as new versions have been released and ProgressBar has been re-worked somewhat. Please get in touch if it's still an issue.

FedeClaudi avatar Feb 21 '23 00:02 FedeClaudi