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

ProgressMeter.next! prints as many bars as updates (on Jupyter notebook)

Open davidbp opened this issue 7 years ago • 11 comments

Hello,

When I use ``ProgressMeter.next!(progressbar; showvalues = [(:epoch, epoch), (:acc, acc)])`

I get the following behaviour

Progress:   5%|██                                       |  ETA: 0:00:13
  epoch:  1
Progress:  10%|████                                     |  ETA: 0:00:11
  epoch:  2
Progress:  15%|██████                                   |  ETA: 0:00:09
  epoch:  3
Progress:  20%|████████                                 |  ETA: 0:00:08
  epoch:  4

I was expecting a single bar that changed, not multiple of them. I have tried with @showprogressand it works as expected. This is the output:

fit!(percep, X_train, y_train, 20, 0.001)
Progress: 100%|█████████████████████████████████████████| Time: 0:00:07

davidbp avatar May 28 '17 15:05 davidbp

I have the same problem in IJulia and it seems to come from showvalues.

damiendr avatar Nov 15 '17 08:11 damiendr

What version are you two running? If it's 0.5.1, can you try Pkg.pin("ProgressMeter", v"0.5.0")?

timholy avatar Nov 15 '17 13:11 timholy

Oh, wait, this seems like a special case. Can you provide a complete minimum working example?

timholy avatar Nov 15 '17 13:11 timholy

The problem occurs with both 0.5.0 and 0.5.1 — I have IJulia 1.6.2.

Here is a working example:

using ProgressMeter
p = Progress(100)
for i in 1:100
    update!(p, i; showvalues = [(:test, 1.0)])
    sleep(0.01)
end

Here as a notebook: https://gist.github.com/damiendr/4d932dfe60d8de17fbbe9a2d215edcfc#file-progressmeter-ipynb Github renders it just as it appears on my machine except that I have the text in colors.

damiendr avatar Nov 15 '17 13:11 damiendr

I have the same issue on IJulia whenever I try to print some variable besides just showing the progress bar.

juliohm avatar Mar 22 '18 06:03 juliohm

Dug into this since I was also hoping to have this work. Looks like it boils down to different behavior between notebook / REPL for: image and image

The same issue appears to be true of the Python version of this (print("line1"); print("\033[F",end=''); print("line2")) so its probably a general issue for Jupyter notebooks.

I'm guessing Jupyter writes the output line-by-line and there's no way to go back once its up. But maybe there's a way to control the size of the output buffer? Anyone familiar with this?

marius311 avatar Apr 06 '18 11:04 marius311

Would it help solve the problem if we printed everything on one line?

denizyuret avatar Sep 12 '18 06:09 denizyuret

If IJulia can't support the equivalent of terminal movement escape codes then one has to find a completely independent solution on IJulia. That will presumably involve learning about how Jupyter handles output to the browser.

timholy avatar Sep 12 '18 14:09 timholy

As pointed out, Python suffers from the same difficulty. In that case I was using tqdm, and was able to easily switch to their tqdm_notebook functionality, which uses ipywidgets to display a much nicer progress bar that worked well within the notebook.

mboratko avatar Sep 18 '18 17:09 mboratko

I'm surprised that it's still an issue. I tried to replace update!(p, i; showvalues = [(:test, 1.0)]) with

update!(p, i)
ProgressMeter.printover(p.output, "test: 1.0", p.color)

and indeed it's almost working. It shows the desired message for some time, but almost immediately it got overwritten with the default message. So, maybe, fixing https://github.com/timholy/ProgressMeter.jl/issues/33 could resolve this issue as well?

VPetukhov avatar Jul 10 '19 13:07 VPetukhov

Possibly related: https://github.com/timholy/ProgressMeter.jl/issues/271

3f6a avatar Aug 03 '23 14:08 3f6a