vbauerster / mpb

multi progress bar for Go cli applications
The Unlicense
2.29k stars 123 forks source link

Repeated non-complete bars #109

Closed Galzzly closed 1 year ago

Galzzly commented 2 years ago

On doing some testing on a utility that I have been building, I have found that Bars are being repeatedly rendered, such as:

Downloading [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Downloading [========================================================================>--------------------------------------------------------------------------------------------------------------------------------------------------] 2 / 6
Downloading [=============================================================================================================>-------------------------------------------------------------------------------------------------------------] 3 / 6
Downloading [=================================================================================================================================================>-------------------------------------------------------------------------] 4 / 6
Downloading [======================================================================================================================================================================================>------------------------------------] 5 / 6
Downloading  Done!
Extracting   Done!
Ingesting Intermediate  Done!
Ingesting Gold  Done!

I only render 4 bars for the tool in total - Downloading, Extracting, Ingesting Intermediate, and Ingesting Gold, only the totals are updated.

The bars are initialised as follows:

    p := mpb.New(mpb.PopCompletedMode())
    barDl := p.AddBar(
        int64(numFiles),
        mpb.BarFillerClearOnComplete(),
        mpb.PrependDecorators(
            decor.Name("Downloading", decor.WC{W: 11, C: decor.DidentRight}),
        ),
        mpb.AppendDecorators(
            decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
        ),
    )
    barExtract := p.AddBar(
        int64(numFiles),
        mpb.BarFillerClearOnComplete(),
        mpb.PrependDecorators(
            decor.Name("Extracting", decor.WC{W: 11, C: decor.DidentRight}),
        ),
        mpb.AppendDecorators(
            decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
        ),
    )
    barInter := p.AddBar(
        int64(numFiles),
        mpb.BarFillerClearOnComplete(),
        mpb.PrependDecorators(
            decor.Name("Ingesting Intermediate", decor.WC{W: 22, C: decor.DidentRight}),
        ),
        mpb.AppendDecorators(
            decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
        ),
    )
    barGold := p.AddBar(
        int64(5),
        mpb.BarFillerClearOnComplete(),
        mpb.PrependDecorators(
            decor.Name("Ingesting Gold", decor.WC{W: 14, C: decor.DidentRight}),
        ),
        mpb.AppendDecorators(
            decor.OnComplete(decor.CountersNoUnit("%d / %d"), "Done!"),
        ),
    )

When adding the bars to the container, I observe that there are the additional two 'Downloading' bars rendered, and additional ones added for unknown reasons as seen in the first example.

What I would like to see happen is the initial four bars rendered:

Downloading [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Extracting  [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Ingesting Intermediate [----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 6
Ingesting Gold [------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0 / 5

The bars increment per the bar.Increment() method, and once complete remove bars and say Done!

Galzzly commented 2 years ago

Could be linked to what has been described in #107

vbauerster commented 2 years ago

Can you please check with head master? Should be fixed.